IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 10, 2004, 9:34:49 AM (22 years ago)
Author:
harman
Message:

Added support for psF32 types

File:
1 edited

Legend:

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

    r2674 r2684  
    1111*  @author  Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
    14 *  @date  $Date: 2004-12-09 21:00:39 $
     13*  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
     14*  @date  $Date: 2004-12-10 19:34:49 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121#include "psTest.h"
    2222
    23 #define PRINT_MATRIX(IMAGE)                         \
    24 for(psS32 i=0; i<IMAGE->numRows; i++) {             \
    25     for(psS32 j=0; j<IMAGE->numCols; j++) {         \
    26         if(IMAGE->type.type == PS_TYPE_F64) {       \
    27             printf("%lf ", IMAGE->data.F64[i][j]);  \
    28         } else {                                    \
    29             printf("%f ", IMAGE->data.F32[i][j]);   \
    30         }                                           \
    31     }                                               \
    32     printf("\n");                                   \
    33 }                                                   \
    34 printf("\n")
     23#define TOLERANCE 0.000001
     24
     25#define CHECK_MATRIX(IMAGE)                                                                                  \
     26for(psU32 i=0; i<IMAGE->numRows; i++) {                                                                  \
     27    for(psU32 j=0; j<IMAGE->numCols; j++) {                                                              \
     28        if(IMAGE->type.type == PS_TYPE_F64) {                                                            \
     29            if(fabs(IMAGE->data.F64[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
     30                printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j,                 \
     31                       IMAGE->data.F64[i][j], truthMatrix[i][j]);                                        \
     32            }                                                                                            \
     33        } else if(IMAGE->type.type == PS_TYPE_F32){                                                      \
     34            if(fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
     35                printf("%lf\n", fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j])),                              \
     36                printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j,                  \
     37                       IMAGE->data.F32[i][j], truthMatrix[i][j]);                                        \
     38            }                                                                                            \
     39        }                                                                                                \
     40    }                                                                                                    \
     41}
     42
    3543
    3644psS32 main( psS32 argc, char* argv[] )
     
    3846    psImage * tempImage = NULL;
    3947
     48    double truthMatrix[3][3] = {{1, 4, 7},
     49                                {2, 5, 8},
     50                                {3, 6, 9}};
    4051
    4152    // Test A - Create input and output images
     
    6374    inImageF32->data.F32[2][1] = 8;
    6475    inImageF32->data.F32[2][2] = 9;
    65     PRINT_MATRIX(inImage);
    66     PRINT_MATRIX(inImageF32);
    6776    printFooter(stdout, "psMatrix", "Create input and output images", true);
    6877
     
    7281    tempImage = outImage;
    7382    outImage = psMatrixTranspose(outImage, inImage);
    74     PRINT_MATRIX(outImage);
     83    CHECK_MATRIX(outImage);
    7584    if (outImage->type.dimen != PS_DIMEN_IMAGE) {
    7685        printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n");
     
    8190    tempImage = outImageF32;
    8291    outImageF32 = psMatrixTranspose(outImageF32, inImageF32);
    83     PRINT_MATRIX(outImageF32);
     92    CHECK_MATRIX(outImageF32);
    8493    if (outImageF32->type.dimen != PS_DIMEN_IMAGE) {
    8594        printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
     
    94103    psImage *outImageNull = NULL;
    95104    outImageNull = psMatrixTranspose(outImageNull, inImage);
    96     PRINT_MATRIX(outImageNull);
     105    CHECK_MATRIX(outImageNull);
    97106
    98107    psImage *outImageNullF32 = NULL;
    99108    outImageNullF32 = psMatrixTranspose(outImageNullF32, inImageF32);
    100     PRINT_MATRIX(outImageNullF32);
     109    CHECK_MATRIX(outImageNullF32);
    101110    printFooter(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image", true);
    102111
Note: See TracChangeset for help on using the changeset viewer.