Changeset 2684
- Timestamp:
- Dec 10, 2004, 9:34:49 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix01.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix01.c
r2674 r2684 11 11 * @author Ross Harman, MHPCC 12 12 * 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 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 #include "psTest.h" 22 22 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) \ 26 for(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 35 43 36 44 psS32 main( psS32 argc, char* argv[] ) … … 38 46 psImage * tempImage = NULL; 39 47 48 double truthMatrix[3][3] = {{1, 4, 7}, 49 {2, 5, 8}, 50 {3, 6, 9}}; 40 51 41 52 // Test A - Create input and output images … … 63 74 inImageF32->data.F32[2][1] = 8; 64 75 inImageF32->data.F32[2][2] = 9; 65 PRINT_MATRIX(inImage);66 PRINT_MATRIX(inImageF32);67 76 printFooter(stdout, "psMatrix", "Create input and output images", true); 68 77 … … 72 81 tempImage = outImage; 73 82 outImage = psMatrixTranspose(outImage, inImage); 74 PRINT_MATRIX(outImage);83 CHECK_MATRIX(outImage); 75 84 if (outImage->type.dimen != PS_DIMEN_IMAGE) { 76 85 printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n"); … … 81 90 tempImage = outImageF32; 82 91 outImageF32 = psMatrixTranspose(outImageF32, inImageF32); 83 PRINT_MATRIX(outImageF32);92 CHECK_MATRIX(outImageF32); 84 93 if (outImageF32->type.dimen != PS_DIMEN_IMAGE) { 85 94 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); … … 94 103 psImage *outImageNull = NULL; 95 104 outImageNull = psMatrixTranspose(outImageNull, inImage); 96 PRINT_MATRIX(outImageNull);105 CHECK_MATRIX(outImageNull); 97 106 98 107 psImage *outImageNullF32 = NULL; 99 108 outImageNullF32 = psMatrixTranspose(outImageNullF32, inImageF32); 100 PRINT_MATRIX(outImageNullF32);109 CHECK_MATRIX(outImageNullF32); 101 110 printFooter(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image", true); 102 111
Note:
See TracChangeset
for help on using the changeset viewer.
