IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2007, 6:14:33 PM (19 years ago)
Author:
gusciora
Message:

Added tabular file of all psLib functions in Chapter 6 of the SDRS (Data
Manipulation). Most of the test file changes in this check-in are fairly
cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/tap_psSparse.c

    r12607 r13123  
    1010    plan_tests(26);
    1111
    12 //    diag("psSparse() tests");
    13 
    1412    // test psSparseSolve for a simple normal example matrix
    1513    {
    1614        psMemId id = psMemGetId();
    1715
    18 //        diag ("solve a normalized matrix equation with psSparseSolve");
     16        //solve a normalized matrix equation with psSparseSolve
    1917
    2018        // the basic equation is Ax = b
     
    2826        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    2927
    30         for (int i = 0; i < 100; i++)
    31         {
     28        for (int i = 0; i < 100; i++) {
    3229            psSparseMatrixElement (matrix, i, i, 1.0);
    3330            if (i + 1 < 100) {
     
    3835        // incoming matrix elements do not need to be in order; sort before
    3936        // applying sparse matrix
    40         psSparseResort (matrix);
     37        psSparseResort(matrix);
    4138
    4239        psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
     
    4643        }
    4744
    48         psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
    49 
    50         for (int i = 0; i < 100; i++)
    51         {
    52             psSparseVectorElement (matrix, i, bVec->data.F32[i]);
     45        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
     46
     47        for (int i = 0; i < 100; i++) {
     48            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
    5349        }
    5450
     
    5955
    6056        // solve for normalization terms (need include local sky?)
    61         psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
     57        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
    6258
    6359        // measure stdev between xFit and xRes
     
    8985        psMemId id = psMemGetId();
    9086
    91 //        diag ("solve a non-normalized matrix equation with psSparseSolve");
    92 
     87        //solve a non-normalized matrix equation with psSparseSolve
    9388        // the basic equation is Ax = b
    94 
    9589        // create a matrix A with diagonals of 1 and a small number of off diagonal elements.
    9690        // construct a vector x, construct the corresponding vector b by multiplication. solve
     
    10195        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    10296
    103         for (int i = 0; i < 100; i++)
    104         {
     97        for (int i = 0; i < 100; i++) {
    10598            psSparseMatrixElement (matrix, i, i, 5.0);
    10699            if (i + 1 < 100) {
     
    111104        // incoming matrix elements do not need to be in order; sort before
    112105        // applying sparse matrix
    113         psSparseResort (matrix);
     106        psSparseResort(matrix);
    114107
    115108        psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
     
    119112        }
    120113
    121         psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
    122 
    123         for (int i = 0; i < 100; i++)
    124         {
    125             psSparseVectorElement (matrix, i, bVec->data.F32[i]);
     114        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
     115
     116        for (int i = 0; i < 100; i++) {
     117            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
    126118        }
    127119
     
    132124
    133125        // solve for normalization terms (need include local sky?)
    134         psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
     126        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
    135127
    136128        // measure stdev between xFit and xRes
     
    173165        psMemId id = psMemGetId();
    174166
    175 //        diag ("solve a simple, small matrix equation ");
     167        //solve a simple, small matrix equation
    176168
    177169        // the basic equation (Ax = b) is:
     
    192184        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    193185
    194         psSparseMatrixElement (matrix, 0, 0, 1.0);
    195         psSparseMatrixElement (matrix, 1, 1, 1.0);
    196         psSparseMatrixElement (matrix, 1, 0, 0.1);
    197         psSparseResort (matrix);
     186        psSparseMatrixElement(matrix, 0, 0, 1.0);
     187        psSparseMatrixElement(matrix, 1, 1, 1.0);
     188        psSparseMatrixElement(matrix, 1, 0, 0.1);
     189        psSparseResort(matrix);
    198190
    199191        // border region has a width of 1:
     
    244236
    245237        // supply the fVec and gVec data to the border
    246         for (int i = 0; i < Nrows; i++)
    247         {
    248             psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
    249         }
    250         for (int i = 0; i < Nborder; i++)
    251         {
    252             psSparseBorderElementG (border, i, gVec->data.F32[i]);
     238        for (int i = 0; i < Nrows; i++) {
     239            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
     240        }
     241        for (int i = 0; i < Nborder; i++) {
     242            psSparseBorderElementG(border, i, gVec->data.F32[i]);
    253243        }
    254244
     
    262252        psVector *xFit = NULL;
    263253        psVector *yFit = NULL;
    264         psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
     254        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
    265255        is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]);
    266256        is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]);
     
    283273        psMemId id = psMemGetId();
    284274
    285 //        diag ("solve a simple, small matrix equation ");
     275        // solve a simple, small matrix equation
    286276
    287277        // the basic equation (Ax = b) is:
     
    302292        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    303293
    304         for (int i = 0; i < Nrows; i++)
    305         {
    306             psSparseMatrixElement (matrix, i, i, 1.0);
     294        for (int i = 0; i < Nrows; i++) {
     295            psSparseMatrixElement(matrix, i, i, 1.0);
    307296            if (i + 1 < Nrows) {
    308                 psSparseMatrixElement (matrix, i + 1, i, 0.1);
    309             }
    310         }
    311         psSparseResort (matrix);
     297                psSparseMatrixElement(matrix, i + 1, i, 0.1);
     298            }
     299        }
     300        psSparseResort(matrix);
    312301
    313302        // border region has a width of 1:
     
    349338
    350339        // supply the fVec and gVec data to the border
    351         for (int i = 0; i < Nrows; i++)
    352         {
    353             psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
    354         }
    355         for (int i = 0; i < Nborder; i++)
    356         {
    357             psSparseBorderElementG (border, i, gVec->data.F32[i]);
     340        for (int i = 0; i < Nrows; i++) {
     341            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
     342        }
     343        for (int i = 0; i < Nborder; i++) {
     344            psSparseBorderElementG(border, i, gVec->data.F32[i]);
    358345        }
    359346
     
    367354        psVector *xFit = NULL;
    368355        psVector *yFit = NULL;
    369         psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
     356        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
    370357
    371358        // measure stdev between xFit and xRef
Note: See TracChangeset for help on using the changeset viewer.