IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3291


Ignore:
Timestamp:
Feb 18, 2005, 2:43:32 PM (21 years ago)
Author:
evanalst
Message:

Update psVectorToMatrix and psMatrixToVector for type psF32.

Location:
trunk/psLib/test/dataManip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMatrix07.c

    r3264 r3291  
    1616 *  @author  Ross Harman, MHPCC
    1717 *
    18  *  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
    19  *  @date  $Date: 2005-02-17 19:26:25 $
     18 *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2005-02-19 00:43:32 $
    2020 *
    2121 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3939        } else if(IMAGE->type.type == PS_TYPE_F32){                                                      \
    4040            if(fabs(IMAGE->data.F32[i][j]-TRUTH[i][j]) > TOLERANCE) {                                    \
    41                 printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j,                  \
     41                printf("Matrix values at element %d, %d don't agree %f vs %f\n", i, j,                  \
    4242                       IMAGE->data.F32[i][j], TRUTH[i][j]);                                              \
    4343            }                                                                                            \
     
    5454        }                                                                                                \
    5555    } else if(VECTOR->type.type == PS_TYPE_F32){                                                         \
    56         if(fabs(VECTOR->data.F32[i]-truthVector[i]) > TOLERANCE) {                                       \
     56        if(fabs(VECTOR->data.F32[i]-truthVector_32[i]) > TOLERANCE) {                                       \
    5757            printf("Vector values at element %d don't agree %f vs %lf\n", i,                             \
    5858                   VECTOR->data.F32[i], truthVector[i]);                                                 \
     
    6565{
    6666    psVector *v1 = NULL;
     67    psVector *v1_32 = NULL;
    6768    psVector *tempVector = NULL;
     69    psVector *tempVector_32 = NULL;
    6870    psImage *tempImage = NULL;
     71    psImage *tempImage_32 = NULL;
    6972    psImage *m1 = NULL;
     73    psImage *m1_32 = NULL;
    7074    psVector *v2 = NULL;
     75    psVector *v2_32 = NULL;
    7176    psVector *v3 = NULL;
     77    psVector *v3_32 = NULL;
    7278    psImage *m2 = NULL;
     79    psImage *m2_32 = NULL;
    7380    psImage *m3 = NULL;
     81    psImage *m3_32 = NULL;
    7482    psImage *m4 = NULL;
     83    psImage *m4_32 = NULL;
    7584    psImage *badImage = NULL;
    76 
    77     double truthVector[3] = {0.0, 1.0, 2.0};
    78     double truthMatrix[3][1] = {{0.0}, {1.0}, {2.0}};
     85    psImage *badImage_32 = NULL;
     86
     87    psF64 truthVector[3] = {0.0, 1.0, 2.0};
     88    psF32 truthVector_32[3] = {0.0, 1.0, 2.0};
     89    psF64 truthMatrix[3][1] = {{0.0}, {1.0}, {2.0}};
     90    psF32 truthMatrix_32[3][1] = {{0.0}, {1.0}, {2.0}};
    7991
    8092    // Test A - Create input and output images
    8193    printPositiveTestHeader(stdout, "psMatrix", "Create input and output images and vectors");
    8294    v1 = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
     95    v1_32 = (psVector*)psVectorAlloc(3, PS_TYPE_F32);
    8396    m1 = (psImage*)psImageAlloc(1, 3, PS_TYPE_F64);
     97    m1_32 = (psImage*)psImageAlloc(1,3,PS_TYPE_F32);
    8498    v2 = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
     99    v2_32 = (psVector*)psVectorAlloc(3,PS_TYPE_F32);
    85100    m2 = (psImage*)psImageAlloc(1, 3, PS_TYPE_F64);
     101    m2_32 = (psImage*)psImageAlloc(1,3,PS_TYPE_F32);
    86102    m3 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64);
     103    m3_32 = (psImage*)psImageAlloc(3,1,PS_TYPE_F32);
    87104    m4 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64);
     105    m4_32 = (psImage*)psImageAlloc(3,1,PS_TYPE_F32);
    88106    badImage = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64);
     107    badImage_32 = (psImage*)psImageAlloc(2,2,PS_TYPE_F32);
    89108    m1->data.F64[0][0] = 0.0;
    90109    m1->data.F64[1][0] = 1.0;
    91110    m1->data.F64[2][0] = 2.0;
     111    m1_32->data.F32[0][0] = 0.0;
     112    m1_32->data.F32[1][0] = 1.0;
     113    m1_32->data.F32[2][0] = 2.0;
    92114    v2->data.F64[0] = 0.0;
    93115    v2->data.F64[1] = 1.0;
    94116    v2->data.F64[2] = 2.0;
    95117    v2->n = 3;
     118    v2_32->data.F32[0] = 0.0;
     119    v2_32->data.F32[1] = 1.0;
     120    v2_32->data.F32[2] = 2.0;
     121    v2_32->n = 3;
    96122    m4->data.F64[0][0] = 0.0;
    97123    m4->data.F64[0][1] = 1.0;
    98124    m4->data.F64[0][2] = 2.0;
     125    m4_32->data.F32[0][0] = 0.0;
     126    m4_32->data.F32[0][1] = 1.0;
     127    m4_32->data.F32[0][2] = 2.0;
    99128    printFooter(stdout, "psMatrix", "Create input and output images and vectors", true);
    100 
    101129
    102130    // Test B - Convert matrix to PS_DIMEN_VECTOR vector
     
    106134    CHECK_VECTOR(v1);
    107135    if(v1->type.dimen != PS_DIMEN_VECTOR) {
    108         printf("Error: Resulting image is not PS_DIMEN_VECTOR\n");
     136        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_VECTOR");
     137        return 1;
    109138    } else if(v1 != tempVector) {
    110         printf("Error: Return pointer not equal to output argument pointer\n");
     139        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     140        return 2;
     141    }
     142    tempVector_32 = v1_32;
     143    v1_32 = psMatrixToVector(v1_32, m1_32);
     144    CHECK_VECTOR(v1_32);
     145    if(v1_32->type.dimen != PS_DIMEN_VECTOR) {
     146        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_VECTOR");
     147        return 1;
     148    } else if(v1_32 != tempVector_32) {
     149        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     150        return 2;
    111151    }
    112152    printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_VECTOR vector", true);
     
    116156    printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null image input argument",
    117157                            "Invalid operation: inImage or its data is NULL.", 0);
     158    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error.");
    118159    v1 = psMatrixToVector(v1, NULL);
     160    if(v1 != NULL) {
     161        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with NULL input");
     162        return 3;
     163    }
     164    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error.");
     165    v1_32 = psMatrixToVector(v1_32, NULL);
     166    if(v1_32 != NULL) {
     167        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with NULL input");
     168        return 3;
     169    }
    119170    printFooter(stdout, "psMatrix", "Attempt to use null image input argument", true);
    120171
     
    123174    printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector");
    124175    v3 = psVectorAlloc(3, PS_TYPE_F64);
     176    tempVector = v3;
    125177    v3->type.dimen = PS_DIMEN_TRANSV;
    126178    psMatrixToVector(v3, m4);
    127179    CHECK_VECTOR(v3);
    128180    if(v3->type.dimen != PS_DIMEN_TRANSV) {
    129         printf("Error: Resulting image is not PS_DIMEN_TRANSV\n");
     181        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_TRANSV");
     182        return 4;
    130183    } else if(v3 != tempVector) {
    131         printf("Error: Return pointer not equal to output argument pointer\n");
     184        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     185        return 5;
     186    }
     187    v3_32 = psVectorAlloc(3, PS_TYPE_F32);
     188    tempVector_32 = v3_32;
     189    v3_32->type.dimen = PS_DIMEN_TRANSV;
     190    psMatrixToVector(v3_32, m4_32);
     191    CHECK_VECTOR(v3_32);
     192    if(v3_32->type.dimen != PS_DIMEN_TRANSV) {
     193        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_TRANSV");
     194        return 6;
     195    } else if(v3_32 != tempVector_32) {
     196        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     197        return 7;
    132198    }
    133199    printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector", true);
     
    137203    printNegativeTestHeader(stdout,"psMatrix", "Improper image size",
    138204                            "Image does not have dim with 1 col or 1 row: (2 x 2).", 0);
    139     psMatrixToVector(v1, badImage);
     205    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     206    if(psMatrixToVector(v1, badImage) != NULL ) {
     207        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with improper sizes");
     208        return 8;
     209    }
     210    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     211    if(psMatrixToVector(v1_32, badImage_32) != NULL ) {
     212        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with improper sizes");
     213        return 9;
     214    }
    140215    printFooter(stdout, "psMatrix", "Improper image size", true);
    141216
     
    147222    CHECK_MATRIX(m2,truthMatrix);
    148223    if(m2->type.dimen != PS_DIMEN_IMAGE) {
    149         printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
     224        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE");
     225        return 10;
    150226    } else if(m2 != tempImage) {
    151         printf("Error: Return pointer not equal to output argument pointer\n");
     227        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     228        return 11;
     229    }
     230    tempImage_32 = m2_32;
     231    m2_32 = psVectorToMatrix(m2_32, v2_32);
     232    CHECK_MATRIX(m2_32,truthMatrix_32);
     233    if(m2_32->type.dimen != PS_DIMEN_IMAGE) {
     234        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE");
     235        return 10;
     236    } else if(m2_32 != tempImage_32) {
     237        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     238        return 11;
    152239    }
    153240    printFooter(stdout, "psMatrix", "Convert PS_DIMEN_VECTOR vector to matrix", true);
     
    157244    printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input vector argument",
    158245                            "Invalid operation: inVector or its data is NULL.", 0);
    159     psVectorToMatrix(m2, NULL);
     246    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     247    if(psVectorToMatrix(m2, NULL) != m2) {
     248        psError(PS_ERR_UNKNOWN,true,"Did not return output image");
     249        return 12;
     250    }
     251    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     252    if(psVectorToMatrix(m2_32, NULL) != m2_32) {
     253        psError(PS_ERR_UNKNOWN,true,"Did not return output image");
     254        return 13;
     255    }
    160256    printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true);
    161257
     
    168264    CHECK_MATRIX(m3, truthMatrix);
    169265    if(m3->type.dimen != PS_DIMEN_IMAGE) {
    170         printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
     266        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE");
     267        return 14;
    171268    } else if(m3 != tempImage) {
    172         printf("Error: Return pointer not equal to output argument pointer\n");
     269        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     270        return 15;
     271    }
     272    v2_32->type.dimen = PS_DIMEN_TRANSV;
     273    tempImage_32 = m3_32;
     274    psVectorToMatrix(m3_32, v2_32);
     275    CHECK_MATRIX(m3_32, truthMatrix_32);
     276    if(m3_32->type.dimen != PS_DIMEN_IMAGE) {
     277        psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE");
     278        return 16;
     279    } else if(m3_32 != tempImage_32) {
     280        psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer");
     281        return 17;
    173282    }
    174283    printFooter(stdout, "psMatrix", "Convert PS_DIMEN_TRANSV vector to matrix", true);
     
    184293    psFree(m3);
    185294    psFree(m4);
     295    psFree(m1_32);
     296    psFree(v1_32);
     297    psFree(m2_32);
     298    psFree(v2_32);
     299    psFree(v3_32);
     300    psFree(m3_32);
     301    psFree(m4_32);
    186302    psFree(badImage);
     303    psFree(badImage_32);
    187304    if( psMemCheckLeaks(0, NULL, stdout, false) != 0) {
    188305        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
  • trunk/psLib/test/dataManip/verified/tst_psMatrix07.stderr

    r3127 r3291  
     1<DATE><TIME>|<HOST>|I|main
     2    Following should generate an error.
    13<DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO)
    24    Unallowable operation: psImage inImage or its data is NULL.
     5<DATE><TIME>|<HOST>|I|main
     6    Following should generate an error.
     7<DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO)
     8    Unallowable operation: psImage inImage or its data is NULL.
     9<DATE><TIME>|<HOST>|I|main
     10    Following should generate error message
    311<DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO)
    412    Image does not have dim with 1 col or 1 row: (2 x 2).
     13<DATE><TIME>|<HOST>|I|main
     14    Following should generate error message
     15<DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO)
     16    Image does not have dim with 1 col or 1 row: (2 x 2).
     17<DATE><TIME>|<HOST>|I|main
     18    Following should generate an error message
    519<DATE><TIME>|<HOST>|E|psVectorToMatrix (FILE:LINENO)
    620    Unallowable operation: psVector inVector or its data is NULL.
     21<DATE><TIME>|<HOST>|I|main
     22    Following should generate an error message
     23<DATE><TIME>|<HOST>|E|psVectorToMatrix (FILE:LINENO)
     24    Unallowable operation: psVector inVector or its data is NULL.
Note: See TracChangeset for help on using the changeset viewer.