Changeset 1347 for trunk/psLib/test/dataManip/tst_psMatrix05.c
- Timestamp:
- Jul 29, 2004, 5:13:08 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix05.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix05.c
r1073 r1347 1 1 /** @file tst_psMatrix_05.c 2 *3 * @brief Test driver for psMatrix multiplication function4 *5 * This test driver contains the following tests for psMatrix test point 5:6 * A) Create input and output images7 * B) Multiply images8 * C) Free input and output images9 *10 * @author Ross Harman, MHPCC11 *12 * @version $Revision: 1.2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06-23 23:00:17$14 *15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii16 *17 */2 * 3 * @brief Test driver for psMatrix multiplication function 4 * 5 * This test driver contains the following tests for psMatrix test point 5: 6 * A) Create input and output images 7 * B) Multiply images 8 * C) Free input and output images 9 * 10 * @author Ross Harman, MHPCC 11 * 12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-30 03:13:08 $ 14 * 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 16 * 17 */ 18 18 19 19 #include "pslib.h" … … 22 22 #define PRINT_MATRIX(IMAGE) \ 23 23 for(int i=0; i<IMAGE->numRows; i++) { \ 24 for(int j=0; j<IMAGE->numCols; j++) { \25 printf("%f ", IMAGE->data.F64[i][j]); \26 } \27 printf("\n"); \28 }29 30 31 int main( int argc,32 char* argv[])24 for(int j=0; j<IMAGE->numCols; j++) { \ 25 printf("%f ", IMAGE->data.F64[i][j]); \ 26 } \ 27 printf("\n"); \ 28 } 29 30 31 int main( int argc, 32 char* argv[] ) 33 33 { 34 psImage * outImage = NULL;34 psImage * outImage = NULL; 35 35 psImage *inImage1 = NULL; 36 36 psImage *inImage2 = NULL; 37 38 37 38 39 39 // 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);55 printFooter( stdout, "psMatrix", "Create input and output images", true);56 57 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 ); 55 printFooter( stdout, "psMatrix", "Create input and output images", true ); 56 57 58 58 // 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);63 64 59 printPositiveTestHeader( stdout, "psMatrix", "Multiply images" ); 60 psMatrixMultiply( outImage, inImage1, inImage2 ); 61 PRINT_MATRIX( outImage ); 62 printFooter( stdout, "psMatrix", "Multiply images", true ); 63 64 65 65 // Test C - Free input and output images 66 printPositiveTestHeader(stdout, "psMatrix", "Free input and output images"); 67 psFree(outImage); 68 psFree(inImage1); 69 psFree(inImage2); 70 psMemCheckLeaks(0, NULL, stdout); 71 int nBad = psMemCheckCorruption(0); 72 if(nBad) { 73 printf("ERROR: Found %d bad memory blocks\n", nBad); 74 } 75 printFooter(stdout, "psMatrix" ,"Free input and output images", true); 76 66 printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" ); 67 psFree( outImage ); 68 psFree( inImage1 ); 69 psFree( inImage2 ); 70 int nLeaks = psMemCheckLeaks( 0, NULL, stdout ); 71 if ( nLeaks != 0 ) { 72 printf( "ERROR: Found %d memory leaks\n", nLeaks ); 73 } 74 int nBad = psMemCheckCorruption( 0 ); 75 if ( nBad ) { 76 printf( "ERROR: Found %d bad memory blocks\n", nBad ); 77 } 78 printFooter( stdout, "psMatrix" , "Free input and output images", true ); 79 77 80 return 0; 78 81 }
Note:
See TracChangeset
for help on using the changeset viewer.
