IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17567


Ignore:
Timestamp:
May 7, 2008, 1:12:13 PM (18 years ago)
Author:
eugene
Message:

various test fixes and cleanups

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

Legend:

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

    r17529 r17567  
    55    psVectorHistogram(): uniform histograms
    66    psVectorHistogram(): generic histograms
    7  *****************************************************************************/
     7*****************************************************************************/
    88#include <stdio.h>
    99#include <string.h>
     
    6767        for (int i=0;i<numBins+1;i++) {
    6868            myBounds->data.F32[i] = lower + ((higher - lower) / (float) numBins) *
    69                                     (float) i;
     69                (float) i;
    7070        }
    7171        psHistogram *myHist = psHistogramAllocGeneric(myBounds);
     
    134134        skip_start(myHist == NULL, 1, "Skipping tests because psVectorHistogram() returned NULL");
    135135
    136         // we need to explicitly count the number in each bin.  we can fool ourselves with rounding
    137         // otherwise
    138 
    139136        bool errorFlag = false;
    140137        for (int i = 0; i < numBins; i++) {
    141           int nValues = 0;
    142           for (int j = 0; j < myData->n; j++) {
    143             // XXX EAM : need to get rules right.  which boundary is inclusive, which is exclusive?
    144             if (myData->data.F32[j] <= myHist->bounds->data.F32[i]) continue;
    145             if (myData->data.F32[j] > myHist->bounds->data.F32[i+1]) continue;
    146             nValues ++;
    147           }
    148           if (myHist->nums->data.F32[i] != nValues) {
    149             diag("Bin number %d bounds: (%.2f - %.2f) data (%.2f) should be (%2d)\n",
    150                  i,
    151                  myHist->bounds->data.F32[i],
    152                  myHist->bounds->data.F32[i+1],
    153                  myHist->nums->data.F32[i], nValues);
    154             errorFlag = true;
    155           }
     138
     139            // we need to explicitly count the number in each bin.  we can fool ourselves with
     140            // rounding otherwise
     141            int nValues = 0;
     142            for (int j = 0; j < myData->n; j++) {
     143                // valid bin: bound[bin] <= value < bound[bin+1]
     144                if (myData->data.F32[j] < myHist->bounds->data.F32[i]) continue;
     145                if (myData->data.F32[j] >= myHist->bounds->data.F32[i+1]) continue;
     146                nValues ++;
     147            }
     148            if (myHist->nums->data.F32[i] != nValues) {
     149                diag("Bin number %d bounds: (%.2f - %.2f) data (%.2f) should be (%2d)\n",
     150                     i,
     151                     myHist->bounds->data.F32[i],
     152                     myHist->bounds->data.F32[i+1],
     153                     myHist->nums->data.F32[i], nValues);
     154                errorFlag = true;
     155            }
    156156        }
    157157        ok(!errorFlag, "psVectorHistogram() correctly set the histogram");
     
    189189        bool errorFlag = false;
    190190        for (int i = 0;i < numBins;i++) {
    191             if (i < numBins/2) {
    192                 if (fabs(myHist->nums->data.F32[i] - (NUM_DATA/numBins)) > ERROR_TOLERANCE) {
    193                     diag("Bin number %d bounds: (%6.3f - %6.3f) data (%f) should be (%.2f)\n", i,
    194                          myHist->bounds->data.F32[i],
    195                          myHist->bounds->data.F32[i + 1],
    196                          myHist->nums->data.F32[i], (float) (NUM_DATA/numBins));
    197                     errorFlag = true;
    198                 }
    199             } else {
    200                 if (fabs(myHist->nums->data.F32[i]) > ERROR_TOLERANCE) {
    201                     diag("Bin number %d bounds: (%6.3f - %6.3f) data (%f) should be (%.2f)\n", i,
    202                          myHist->bounds->data.F32[i],
    203                          myHist->bounds->data.F32[i + 1],
    204                          myHist->nums->data.F32[i], 0.0);
    205                     errorFlag = true;
    206                 }
    207             }
     191
     192            // we need to explicitly count the number in each bin.  we can fool ourselves with
     193            // rounding otherwise
     194            int nValues = 0;
     195            for (int j = 0; j < myData->n; j++) {
     196                // valid bin: bound[bin] <= value < bound[bin+1]
     197                if (myMask->data.U8[j] == 1) continue;
     198                if (myData->data.F32[j] < myHist->bounds->data.F32[i]) continue;
     199                if (myData->data.F32[j] >= myHist->bounds->data.F32[i+1]) continue;
     200                nValues ++;
     201            }
     202            if (myHist->nums->data.F32[i] != nValues) {
     203                diag("Bin number %d bounds: (%6.3f - %6.3f) data (%f) should be (%.2f)\n", i,
     204                     myHist->bounds->data.F32[i],
     205                     myHist->bounds->data.F32[i + 1],
     206                     myHist->nums->data.F32[i], (float) (NUM_DATA/numBins));
     207                errorFlag = true;
     208            }
    208209        }
    209210        ok(!errorFlag, "psVectorHistogram() correctly set the histogram");
     
    226227        }
    227228        ok(false == psVectorHistogram(NULL, myData, NULL, NULL, 0),
    228           "psVectorHistogram() returned FALSE with a NULL psHistogram input");
     229           "psVectorHistogram() returned FALSE with a NULL psHistogram input");
    229230        psFree(myData);
    230231        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    239240        psHistogram *myHist = psHistogramAlloc(lower, higher, numBins);
    240241        ok(true == psVectorHistogram(myHist, NULL, NULL, NULL, 0),
    241           "psVectorHistogram() returns TRUE with a NULL input array");
     242           "psVectorHistogram() returns TRUE with a NULL input array");
    242243        psFree(myHist);
    243244        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    253254        psHistogram *myHist = psHistogramAlloc(lower, higher, numBins);
    254255        ok(true == psVectorHistogram(myHist, NULL, NULL, NULL, 0),
    255           "psVectorHistogram() returns TRUE with an empty input array");
     256           "psVectorHistogram() returns TRUE with an empty input array");
    256257        psFree(myHist);
    257258        psFree(myData);
     
    301302        skip_start(rc == false, 1, "Skipping tests because psVectorHistogram() returned FALSE");
    302303        for (int i=0;i<numBins;i++) {
    303             psF32 expected = ((float) NUM_DATA) / ((float) numBins);
    304             if (fabs(myHist->nums->data.F32[i] - expected) > ERROR_TOLERANCE) {
     304
     305            // we need to explicitly count the number in each bin.  we can fool ourselves with
     306            // rounding otherwise
     307            int nValues = 0;
     308            for (int j = 0; j < myData->n; j++) {
     309                // valid bin: bound[bin] <= value < bound[bin+1]
     310                if (myData->data.F32[j] < myHist->bounds->data.F32[i]) continue;
     311                if (myData->data.F32[j] >= myHist->bounds->data.F32[i+1]) continue;
     312                nValues ++;
     313            }
     314            if (myHist->nums->data.F32[i] != nValues) {
    305315                diag("Bin number %d bounds: (%.2f - %.2f): data: (%.2f) should be (%.2f)\n", i,
    306316                     myHist->bounds->data.F32[i],
    307317                     myHist->bounds->data.F32[i+1],
    308                      myHist->nums->data.F32[i], expected);
     318                     myHist->nums->data.F32[i], nValues);
    309319                errorFlag = true;
    310320            }
    311321        }
    312         ok(!errorFlag, "psVectorHistogram() correctly initialized the bins");
     322        ok(!errorFlag, "psVectorHistogram() correctly set the bins");
    313323        skip_end();
    314324        psFree(myData);
  • trunk/psLib/test/math/tap_psMatrix02.c

    r13124 r17567  
    1212 *  @author  Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2007-05-02 04:20:06 $
     14 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     15 *  @date  $Date: 2008-05-07 23:12:13 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2828{
    2929    psLogSetFormat("HLNM");
    30     plan_tests(11);
     30    plan_tests(23);
    3131
    3232    // Input pointer same as output pointer
     
    3434    // a requirement.  However, we should probably fix the case where the input
    3535    // image equals the output image.
    36     if (0) {
     36    {
    3737        psMemId id = psMemGetId();
    3838        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    39         ok(psMatrixTranspose(inImage, inImage) == NULL, "psMatrixTranspose(): inImage = outImage results in NULL");
    40         ok(psMemGetRefCounter(inImage) == 1, "psMatrixTranspose(): the output image was freed on an error.");
     39        ok(psMatrixTranspose(inImage, inImage) == NULL, "psMatrixTranspose(): inImage == outImage results in NULL");
    4140        psFree(inImage);
    4241        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    5049        psImage *nullImage = NULL;
    5150        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    52         psMemIncrRefCounter(outImage);
    5351        ok(psMatrixTranspose(outImage, nullImage) == NULL, "psMatrixTranspose(): inImage = NULL results in NULL return");
    54         ok(psMemGetRefCounter(outImage) == 1, "psMatrixTranspose(): the output image was freed on an error.");
    5552        psFree(outImage);
    5653        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    5754    }
    5855
    59 
    6056    // Incorrect type for input pointer
    61     // Merge with tap_psMatrix01.c, get rid of this test (redundant)
    6257    {
    6358        psMemId id = psMemGetId();
     59        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
    6460        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    65         psImage *badImage1 = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
    66         psMemIncrRefCounter(outImage);
    67         ok(psMatrixTranspose(outImage, badImage1) == NULL, "psMatrixTranspose(): inImage = outImage results in NULL return");
    68         ok(psMemGetRefCounter(outImage) == 1, "the output image was freed on the error.");
     61        ok(psMatrixTranspose(outImage, inImage) == NULL, "psMatrixTranspose(): inImage wrong type (U8) results in NULL return");
    6962        psFree(outImage);
    70         psFree(badImage1);
     63        psFree(inImage);
    7164        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    7265    }
    7366
     67    // Incorrect type for input pointer
     68    {
     69        psMemId id = psMemGetId();
     70        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_S32);
     71        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     72        ok(psMatrixTranspose(outImage, inImage) == NULL, "psMatrixTranspose(): inImage wrong type (S32) results in NULL return");
     73        psFree(outImage);
     74        psFree(inImage);
     75        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     76    }
    7477
    7578    // Incorrect type for output pointer
     
    7780        psMemId id = psMemGetId();
    7881        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    79         psImage *badImage1 = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
    80         badImage1 = psMatrixTranspose(badImage1, inImage);
    81         ok(badImage1 != NULL, "psMatrixTranspose() results in non-NULL return");
     82        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_U8);
     83        outImage = psMatrixTranspose(outImage, inImage);
     84        ok(outImage != NULL, "psMatrixTranspose() results in non-NULL return");
     85
    8286        // check that the type was changed.
    83         ok(badImage1->type.type == PS_TYPE_F64, "the output type was changed to F64");
     87        ok(outImage->type.type == PS_TYPE_F64, "the output type was changed to F64");
    8488        psFree(inImage);
    85         psFree(badImage1);
     89        psFree(outImage);
    8690        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    8791    }
    8892
    89 
    90     // Matrix not square for output pointer
    91     // XXX: We should probably do more here.
     93    // output target matrix not square (Nx > Ny) for output pointer
    9294    {
    9395        psMemId id = psMemGetId();
    9496        psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    95         psImage *badImage2 = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
    96         ok(psMatrixTranspose(badImage2, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
     97        psImage *outImage = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
     98        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
     99        ok(outImage->numCols == 3, "psMatrixTranspose(): output matrix dimensions match input");
     100        ok(outImage->numRows == 3, "psMatrixTranspose(): output matrix dimensions match input");
    97101        psFree(inImage);
    98         psFree(badImage2);
     102        psFree(outImage);
     103        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     104    }
     105
     106    // input matrix not square (Nx < Ny)
     107    {
     108        psMemId id = psMemGetId();
     109        psImage *inImage = (psImage*)psImageAlloc(2, 3, PS_TYPE_F64);
     110        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     111        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
     112        ok(outImage->numCols == 3, "psMatrixTranspose(): output matrix dimensions match input");
     113        ok(outImage->numRows == 2, "psMatrixTranspose(): output matrix dimensions match input");
     114        psFree(inImage);
     115        psFree(outImage);
     116        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     117    }
     118
     119    // input matrix not square (Nx > Ny)
     120    {
     121        psMemId id = psMemGetId();
     122        psImage *inImage = (psImage*)psImageAlloc(3, 2, PS_TYPE_F64);
     123        psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     124        ok(psMatrixTranspose(outImage, inImage) != NULL, "psMatrixTranspose(): non-square matrix results in non-NULL");
     125        ok(outImage->numCols == 2, "psMatrixTranspose(): output matrix dimensions match input");
     126        ok(outImage->numRows == 3, "psMatrixTranspose(): output matrix dimensions match input");
     127        psFree(inImage);
     128        psFree(outImage);
    99129        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    100130    }
  • trunk/psLib/test/math/tap_psPolyFit2D.c

    r13337 r17567  
    424424            psMemId id = psMemGetId();
    425425            bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, xS32, y);
    426             ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set x vector to incorrect type");
     426            ok(rc == true, "psVectorFitPolynomial2D() returned TRUE: x vector may be S32");
    427427            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    428428        }
     
    433433            psMemId id = psMemGetId();
    434434            bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, yS32);
    435             ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set y vector to incorrect type");
     435            ok(rc == true, "psVectorFitPolynomial2D() returned TRUE: y vector may be S32");
    436436            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    437437        }
  • trunk/psLib/test/math/tap_psPolyFit3D.c

    r13337 r17567  
    476476            psMemId id = psMemGetId();
    477477            bool rc = psVectorFitPolynomial3D(myPoly, mask, MASK_VALUE, f, fErr, xS32, y, z);
    478             ok(rc == false, "psVectorFitPolynomial3D() returned FALSE: Set x vector to incorrect type");
     478            ok(rc == true, "psVectorFitPolynomial3D() returned TRUE: x vector may be S32");
    479479            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    480480        }
     
    485485            psMemId id = psMemGetId();
    486486            bool rc = psVectorFitPolynomial3D(myPoly, mask, MASK_VALUE, f, fErr, x, yS32, z);
    487             ok(rc == false, "psVectorFitPolynomial3D() returned FALSE: Set y vector to incorrect type");
     487            ok(rc == true, "psVectorFitPolynomial3D() returned TRUE: y vector may be S32");
    488488            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    489489        }
     
    494494            psMemId id = psMemGetId();
    495495            bool rc = psVectorFitPolynomial3D(myPoly, mask, MASK_VALUE, f, fErr, x, y, zS32);
    496             ok(rc == false, "psVectorFitPolynomial3D() returned FALSE: Set z vector to incorrect type");
     496            ok(rc == true, "psVectorFitPolynomial3D() returned TRUE: z vector may be S32");
    497497            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    498498        }
  • trunk/psLib/test/math/tap_psPolyFit4D.c

    r17515 r17567  
    536536            psMemId id = psMemGetId();
    537537            bool rc = psVectorFitPolynomial4D(myPoly, mask, MASK_VALUE, f, fErr, xS32, y, z, t);
    538             ok(rc == false, "psVectorFitPolynomial4D() returned FALSE: Set x vector to incorrect type");
     538            ok(rc == true, "psVectorFitPolynomial4D() returned TRUE: x vector may be S32");
    539539            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    540540        }
     
    545545            psMemId id = psMemGetId();
    546546            bool rc = psVectorFitPolynomial4D(myPoly, mask, MASK_VALUE, f, fErr, x, yS32, z, t);
    547             ok(rc == false, "psVectorFitPolynomial4D() returned FALSE: Set y vector to incorrect type");
     547            ok(rc == true, "psVectorFitPolynomial4D() returned TRUE: y vector may be S32");
    548548            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    549549        }
     
    554554            psMemId id = psMemGetId();
    555555            bool rc = psVectorFitPolynomial4D(myPoly, mask, MASK_VALUE, f, fErr, x, y, zS32, t);
    556             ok(rc == false, "psVectorFitPolynomial4D() returned FALSE: Set z vector to incorrect type");
     556            ok(rc == true, "psVectorFitPolynomial4D() returned TRUE: z vector may be S32");
    557557            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    558558        }
     
    563563            psMemId id = psMemGetId();
    564564            bool rc = psVectorFitPolynomial4D(myPoly, mask, MASK_VALUE, f, fErr, x, y, z, tS32);
    565             ok(rc == false, "psVectorFitPolynomial4D() returned FALSE: Set t vector to incorrect type");
     565            ok(rc == true, "psVectorFitPolynomial4D() returned TRUE: t vector may be S32");
    566566            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    567567        }
Note: See TracChangeset for help on using the changeset viewer.