IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9991


Ignore:
Timestamp:
Nov 14, 2006, 4:30:22 PM (19 years ago)
Author:
magnier
Message:

adding psSparseBorder APIs (ifdef-ed out)

Location:
trunk/psLib/src/math
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psSparse.c

    r9730 r9991  
    5656    PS_ASSERT_INT_NONNEGATIVE(j, false);
    5757
     58    // EAM : this is now a fatal error
    5859    if (i < j) {
    59         psLogMsg(__func__, PS_LOG_WARN, "i=%d, j=%d refers to a sub-diagonal element; values switched.\n", i, j);
    60         int temp = i;
    61         i = j;
    62         j = temp;
     60        // psError(PS_ERR_UNKNOWN, true, "i=%d, j=%d refers to a sub-diagonal element. not allowed!");
     61        psAbort (__func__, "i=%d, j=%d refers to a sub-diagonal element. not allowed!");
     62        return false;
    6363    }
    6464
     
    209209    return true;
    210210}
     211
     212# if (0)
     213
     214    /*** psSparseBorder Functions : these are used to solve a matrix equation of the form:
     215      A x = f  where A is partitioned into:
     216      A = |S B| where Q is a low-rank square matrix (N<20)
     217          |B Q| and B is a rectangular band (technically this is B and B^T)
     218      and S is a sparse matrix. 
     219    */
     220
     221    static void psSparseBorderFree(psSparse *sparse)
     222{
     223    if (!sparse) {
     224        return;
     225    }
     226    psFree(sparse->Bij);
     227    psFree(sparse->Qii);
     228    return;
     229}
     230
     231// allocate a sparse matrix container for Nrows, with Nelem slots allocated
     232psSparseBorder *psSparseBorderAlloc (int Nrows, int Nelem)
     233{
     234    psSparseBorder *sparse = (psSparseBorder *)psAlloc(sizeof(psSparseBorder));
     235    psMemSetDeallocator(sparse, (psFreeFunc) psSparseBorderFree);
     236
     237    sparse->Nrows = Nrows;
     238    sparse->Nelem = Nelem;
     239
     240    sparse->Bij = psImageAlloc(Nelem, Nrows, PS_DATA_F32);
     241    psInitImage (sparse->Bij, 0.0);
     242
     243    sparse->Qii = psImageAlloc(Nrows, Nrows, PS_DATA_F32);
     244    psInitImage (sparse->Qii, 0.0);
     245
     246    return sparse;
     247}
     248
     249// add elements to sparse->Qii
     250bool psSparseBorderMatrixElement(psSparseBorder *sparse, int i, int j, float value)
     251{
     252    PS_ASSERT_PTR_NON_NULL(sparse, false);
     253    PS_ASSERT_PTR_NON_NULL(sparse->Qii, false);
     254    PS_ASSERT_INT_NONNEGATIVE(i, false);
     255    PS_ASSERT_INT_NONNEGATIVE(j, false);
     256
     257    // check i,j against sparse->Qii->nX,nY
     258    sparse->Qii->data.F32[i][j] = value;
     259    return true;
     260}
     261
     262// add elements to sparse->Bij
     263bool psSparseBorderVectorElement(psSparseBorder *sparse, int i, int j, float value)
     264{
     265    PS_ASSERT_PTR_NON_NULL(sparse, false);
     266    PS_ASSERT_PTR_NON_NULL(sparse->Qii, false);
     267    PS_ASSERT_INT_NONNEGATIVE(i, false);
     268    PS_ASSERT_INT_NONNEGATIVE(j, false);
     269
     270    sparse->Bij->data.F32[i][j] = value;
     271    return true;
     272}
     273# endif /* gene's dev work */
  • trunk/psLib/src/math/psSparse.h

    r7551 r9991  
    6565                       );
    6666
     67# if (0)
     68    // The border elements of a sparse matrix equation:
     69    // A = |S B| where Q is a low-rank square matrix (N<20)
     70    //     |B Q| and B is a rectangular band (technically this is B and B^T)
     71    typedef struct
     72    {
     73        psImage *Bij;                      // Aij contains the populated elements of the matrix
     74        psImage *Qii;                      // Bfj contains the elements of the vector Bf
     75        int Nelem;                         // Number of elements (long dimension of Bij, 0-j)
     76        int Nrows;                         // Number of rows (size of Qii)
     77    }
     78psSparseBorder;
     79
     80
     81// allocate a sparse matrix structure
     82psSparse *psSparseBorderAlloc(int Nrows, int Nelem);
     83
     84// add a new matrix element
     85// user should only add elements above the diagonal
     86bool psSparseBorderMatrixElement(psSparse *sparse, // Matrix to which to add
     87                                 int i, int j, // Matrix indices at which to add
     88                                 float value  // Value to add
     89                                );
     90
     91// define a new sparse matrix equation vector element
     92void psSparseBorderVectorElement(psSparse *sparse, // Matrix to which to add
     93                                 int i, int j, // Index to add
     94                                 float value // Value to add
     95                                );
     96# endif /* gene's dev work */
     97
    6798#endif /* PS_SPARSE_H */
Note: See TracChangeset for help on using the changeset viewer.