IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

adding psSparseBorder APIs (ifdef-ed out)

File:
1 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 */
Note: See TracChangeset for help on using the changeset viewer.