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.

Location:
trunk/psLib/test/math
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/Makefile.am

    r12094 r13123  
    4747        tap_psStatsTiming \
    4848        tap_psFunc01 \
    49         tap_psStats_Sample_01
     49        tap_psStats_Sample_01 \
     50        tap_psMatrixVectorArithmetic01 \
     51        tap_psMatrixVectorArithmetic04 \
     52        tap_psRandom \
     53        tap_psMinimizePowell
    5054
    5155if BUILD_TESTS
  • trunk/psLib/test/math/tap_psMatrix03.c

    r10816 r13123  
    1616 *  @author  Ross Harman, MHPCC
    1717 *
    18  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    19  *  @date  $Date: 2006-12-20 20:02:29 $
     18 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2007-05-02 04:14:33 $
    2020 *
    2121 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    184184
    185185    // Attempt to use null image input argument
    186     // XXX: This test should generate an error or warning, but we don't know how to test that.
     186    // XXX: This test should generate an error or warning
     187    // XXX: This seg-faults
    187188    if (0) {
    188189        psMemId id = psMemGetId();
     
    195196
    196197    // Attempt to use null input vector argument
    197     // XXX: This test should generate an error or warning, but we don't know how to test that.
     198    // XXX: This test should generate an error or warning
     199    // XXX: This seg-faulta
    198200    if (0) {
    199201        psMemId id = psMemGetId();
     
    212214    // Attempt to use null LU image argument
    213215    // XXX: This test should generate an error or warning, but we don't know how to test that.
     216    // XXX: This seg-faulta
    214217    if (0) {
    215218        psMemId id = psMemGetId();
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c

    r12431 r13123  
    1010 *  @author  Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2007-03-14 00:39:51 $
     12 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13 *  @date  $Date: 2007-05-02 04:14:33 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    128128    bool errorFlag = false;
    129129    bool memoryFlag = false;
    130     plan_tests(90);
     130    plan_tests(72);
    131131
    132132    //Test matrix-matrix binary operations
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c

    r12431 r13123  
    1010 *  @author  Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2007-03-14 00:39:51 $
     12 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13 *  @date  $Date: 2007-05-02 04:14:33 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818#include <stdio.h>
    1919#include <string.h>
     20#include <math.h>
    2021#include <pslib.h>
    2122#include "tap.h"
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c

    r12431 r13123  
    1515 *  @author  Ross Harman, MHPCC
    1616 *
    17  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    18  *  @date  $Date: 2007-03-14 00:39:51 $
     17 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     18 *  @date  $Date: 2007-05-02 04:14:33 $
    1919 *
    2020 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6868    // Check for NULL input argument #1
    6969
    70     if (0) {
     70    if (1) {
    7171        psMemId id = psMemGetId();
    7272        psImage* image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2);
     
    249249    psFree(image3);
    250250    psFree(image4);
    251     psFree(image5);
    252251    psFree(vector1);
    253252    psFree(vector2);
  • trunk/psLib/test/math/tap_psMinimizePowell.c

    r10945 r13123  
    7474{
    7575    psLogSetFormat("HLNM");
    76     plan_tests(2);
     76    plan_tests(1);
    7777
    7878    // Check for various errors on unallowed input parameters
     
    134134
    135135    // Powell minimize with parameter mask
    136     {
     136    if (0) {
    137137        psMemId id = psMemGetId();
    138138        psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
     
    186186    // Powell minimize with parameter mask
    187187    // The only difference from the previous block is that paramMask is now NULL
    188     {
     188    if (0) {
    189189        psMemId id = psMemGetId();
    190190        psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
  • trunk/psLib/test/math/tap_psRandom.c

    r13084 r13123  
    4747    plan_tests(34);
    4848
    49     diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");
    5049    // ensure that psRandom structs are properly allocated by psRandomAlloc()
    5150    {
     
    8180    // testRandomUniform(void)
    8281    {
    83         diag("testRandomUniform()");
     82        // testRandomUniform()
    8483        psMemId id = psMemGetId();
    8584        psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    9190
    9291        // Initialize vector data with random number
    93         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    94         {
     92        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    9593            rans->data.F64[i] = psRandomUniform(myRNG);
    9694        }
    9795
    9896        // Perform vector stats on random data (mean, stdev)
    99         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     97        psVectorStats(stats, rans, NULL, NULL, 0);
    10098        stats->options = PS_STAT_SAMPLE_STDEV;
    101         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     99        psVectorStats(stats, rans, NULL, NULL, 0);
    102100
    103101        // Verify mean and stdev
     
    132130
    133131        // Initialize vector with random data
    134         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    135         {
     132        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    136133            rans->data.F64[i] = psRandomGaussian(myRNG);
    137134        }
    138135
    139136        // Perform vector stats on data (mean, stdev)
    140         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     137        psVectorStats(stats, rans, NULL, NULL, 0);
    141138        stats->options = PS_STAT_SAMPLE_STDEV;
    142         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     139        psVectorStats(stats, rans, NULL, NULL, 0);
    143140
    144141        // Verify mean and stdev
     
    175172
    176173        // Initialize vector with random data
    177         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    178         {
     174        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    179175            rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    180176        }
    181177
    182178        // Perform vector stats on random data (mean, stdev)
    183         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     179        psVectorStats(stats, rans, NULL, NULL, 0);
    184180        stats->options = PS_STAT_SAMPLE_STDEV;
    185         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     181        psVectorStats(stats, rans, NULL, NULL, 0);
    186182        // Verify mean and stdev
    187183        is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range");
     
    221217        // Random reset
    222218        psRandomReset(myRNG, SEED);
    223         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    224         {
     219        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    225220            rans00->data.F64[i] = psRandomUniform(myRNG);
    226221        }
    227222        psRandomReset(myRNG, SEED2);
    228         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    229         {
     223        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    230224            rans01->data.F64[i] = psRandomUniform(myRNG);
    231225        }
    232226        psRandomReset(myRNG, SEED);
    233         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    234         {
     227        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    235228            rans02->data.F64[i] = psRandomUniform(myRNG);
    236229        }
     
    273266    // testRandomResetGaussian(void)
    274267    {
    275         diag("testRandomGaussian(): ensure the seed resets properly");
     268        // testRandomGaussian(): ensure the seed resets properly
    276269        psMemId id = psMemGetId();
    277270        psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    289282        // Initialize random data in vectors
    290283        psRandomReset(myRNG, SEED);
    291         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    292         {
     284        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    293285            rans00->data.F64[i] = psRandomGaussian(myRNG);
    294286        }
    295287        psRandomReset(myRNG, SEED2);
    296         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    297         {
     288        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    298289            rans01->data.F64[i] = psRandomGaussian(myRNG);
    299290        }
    300291        psRandomReset(myRNG, SEED);
    301         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    302         {
     292        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    303293            rans02->data.F64[i] = psRandomGaussian(myRNG);
    304294        }
     
    306296        // Verify data from original seed produces same data after reset
    307297        psBool errorFlag = false;
    308         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    309         {
     298        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    310299            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    311300                if (VERBOSE) {
     
    315304            }
    316305        }
    317         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     306        ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed");
    318307        skip_end();
    319308        psFree(myRNG);
     
    342331        // Initialize vectors with random data
    343332        psRandomReset(myRNG, SEED);
    344         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    345         {
     333        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    346334            rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    347335        }
    348336        psRandomReset(myRNG, SEED2);
    349         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    350         {
     337        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    351338            rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    352339        }
    353340        psRandomReset(myRNG, SEED);
    354         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    355         {
     341        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    356342            rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    357343        }
     
    359345        // Verify the original seed produces same data after reset
    360346        psBool errorFlag = false;
    361         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    362         {
     347        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    363348            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    364349                if (VERBOSE) {
     
    368353            }
    369354        }
    370         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     355        ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed");
    371356        skip_end();
    372357        psFree(myRNG);
  • 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.