Changeset 2688
- Timestamp:
- Dec 10, 2004, 10:54:34 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix05.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix05.c
r2392 r2688 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 1-22 21:00:21$12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-10 20:54:34 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include "psTest.h" 21 21 22 #define PRINT_MATRIX(IMAGE) \ 23 for(psS32 i=0; i<IMAGE->numRows; i++) { \ 24 for(psS32 j=0; j<IMAGE->numCols; j++) { \ 25 printf("%f ", IMAGE->data.F64[i][j]); \ 26 } \ 27 printf("\n"); \ 22 #define TOLERANCE 0.000001 23 24 #define CHECK_MATRIX(IMAGE) \ 25 for(psU32 i=0; i<IMAGE->numRows; i++) { \ 26 for(psU32 j=0; j<IMAGE->numCols; j++) { \ 27 if(IMAGE->type.type == PS_TYPE_F64) { \ 28 if(fabs(IMAGE->data.F64[i][j]-truthMatrix[i][j]) > TOLERANCE) { \ 29 printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j, \ 30 IMAGE->data.F64[i][j], truthMatrix[i][j]); \ 31 } \ 32 } else if(IMAGE->type.type == PS_TYPE_F32){ \ 33 if(fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j]) > TOLERANCE) { \ 34 printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j, \ 35 IMAGE->data.F32[i][j], truthMatrix[i][j]); \ 36 } \ 37 } \ 38 } \ 28 39 } 29 40 … … 35 46 psImage *inImage1 = NULL; 36 47 psImage *inImage2 = NULL; 48 psImage * outImage32 = NULL; 49 psImage *inImage132 = NULL; 50 psImage *inImage232 = NULL; 51 52 double truthMatrix[3][3] = {{ 8.000000, 20.000000}, 53 {-4.000000, 11.000000}}; 54 55 37 56 38 57 39 58 // Test A - Create input and output images 40 printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" ); 41 outImage = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 ); 42 inImage1 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 ); 43 inImage2 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 ); 44 inImage1->data.F64[ 0 ][ 0 ] = 2; 45 inImage1->data.F64[ 0 ][ 1 ] = 3; 46 inImage1->data.F64[ 1 ][ 0 ] = -1; 47 inImage1->data.F64[ 1 ][ 1 ] = 2; 48 inImage2->data.F64[ 0 ][ 0 ] = 4; 49 inImage2->data.F64[ 0 ][ 1 ] = 1; 50 inImage2->data.F64[ 1 ][ 0 ] = 0; 51 inImage2->data.F64[ 1 ][ 1 ] = 6; 52 PRINT_MATRIX( inImage1 ); 53 printf( "\n" ); 54 PRINT_MATRIX( inImage2 ); 59 printPositiveTestHeader(stdout, "psMatrix", "Create input and output images"); 60 outImage = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64); 61 inImage1 = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64); 62 inImage2 = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64); 63 inImage1->data.F64[0][0] = 2; 64 inImage1->data.F64[0][1] = 3; 65 inImage1->data.F64[1][0] = -1; 66 inImage1->data.F64[1][1] = 2; 67 inImage2->data.F64[0][0] = 4; 68 inImage2->data.F64[0][1] = 1; 69 inImage2->data.F64[1][0] = 0; 70 inImage2->data.F64[1][1] = 6; 71 outImage32 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32); 72 inImage132 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32); 73 inImage232 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32); 74 inImage132->data.F32[0][0] = 2; 75 inImage132->data.F32[0][1] = 3; 76 inImage132->data.F32[1][0] = -1; 77 inImage132->data.F32[1][1] = 2; 78 inImage232->data.F32[0][0] = 4; 79 inImage232->data.F32[0][1] = 1; 80 inImage232->data.F32[1][0] = 0; 81 inImage232->data.F32[1][1] = 6; 55 82 printFooter( stdout, "psMatrix", "Create input and output images", true ); 56 83 57 84 58 85 // Test B - Multiply images 59 printPositiveTestHeader( stdout, "psMatrix", "Multiply images" ); 60 psMatrixMultiply( outImage, inImage1, inImage2 ); 61 PRINT_MATRIX( outImage ); 62 printFooter( stdout, "psMatrix", "Multiply images", true ); 86 printPositiveTestHeader(stdout, "psMatrix", "Multiply images"); 87 psMatrixMultiply(outImage, inImage1, inImage2); 88 CHECK_MATRIX(outImage); 89 psMatrixMultiply(outImage32, inImage132, inImage232); 90 CHECK_MATRIX(outImage32); 91 printFooter(stdout, "psMatrix", "Multiply images", true); 63 92 64 93 65 94 // Test C - Free input and output images 66 95 printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" ); 67 psFree( outImage ); 68 psFree( inImage1 ); 69 psFree( inImage2 ); 96 psFree(outImage); 97 psFree(inImage1); 98 psFree(inImage2); 99 psFree(outImage32); 100 psFree(inImage132); 101 psFree(inImage232); 70 102 psS32 nLeaks = psMemCheckLeaks( 0, NULL, stdout, false ); 71 103 if ( nLeaks != 0 ) {
Note:
See TracChangeset
for help on using the changeset viewer.
