Changeset 2690
- Timestamp:
- Dec 10, 2004, 11:06:26 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix06.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix06.c
r2392 r2690 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 21:06:26 $ 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 30 41 31 psS32 main( psS32 argc, 32 char* argv[] ) 42 psS32 main(psS32 argc, char* argv[]) 33 43 { 34 44 psImage * outImage = NULL; 35 45 psImage *inImage = NULL; 46 psImage * outImage32 = NULL; 47 psImage *inImage32 = NULL; 48 49 double truthMatrix[4][4] = {{0.792608, 0.582076, -0.179186, -0.029193}, 50 {0.451923, -0.370502, 0.741918, 0.328712}, 51 {0.322416, -0.509579, -0.100228, -0.791411}, 52 {0.252161, -0.514048, -0.638283, 0.514553}}; 36 53 37 54 38 55 // Test A - Create input and output images 39 56 printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" ); 40 outImage = ( psImage* ) psImageAlloc( 4, 4, PS_TYPE_F64);41 inImage = ( psImage* ) psImageAlloc( 4, 4, PS_TYPE_F64);57 outImage = (psImage*) psImageAlloc(4, 4, PS_TYPE_F64); 58 inImage = (psImage*) psImageAlloc(4, 4, PS_TYPE_F64); 42 59 43 inImage->data.F64[ 0 ][ 0 ] = 1. / 1.; 44 inImage->data.F64[ 0 ][ 1 ] = 1. / 2.; 45 inImage->data.F64[ 0 ][ 2 ] = 1. / 3.; 46 inImage->data.F64[ 0 ][ 3 ] = 1. / 4.; 60 inImage->data.F64[0][0] = 1./1.; 61 inImage->data.F64[0][1] = 1./2.; 62 inImage->data.F64[0][2] = 1./3.; 63 inImage->data.F64[0][3] = 1./4.; 64 inImage->data.F64[1][0] = 1./2.; 65 inImage->data.F64[1][1] = 1./3.; 66 inImage->data.F64[1][2] = 1./4.; 67 inImage->data.F64[1][3] = 1./5.; 68 inImage->data.F64[2][0] = 1./3.; 69 inImage->data.F64[2][1] = 1./4.; 70 inImage->data.F64[2][2] = 1./5.; 71 inImage->data.F64[2][3] = 1./6.; 72 inImage->data.F64[3][0] = 1./4.; 73 inImage->data.F64[3][1] = 1./5.; 74 inImage->data.F64[3][2] = 1./6.; 75 inImage->data.F64[3][3] = 1./7.; 47 76 48 inImage->data.F64[ 1 ][ 0 ] = 1. / 2.; 49 inImage->data.F64[ 1 ][ 1 ] = 1. / 3.; 50 inImage->data.F64[ 1 ][ 2 ] = 1. / 4.; 51 inImage->data.F64[ 1 ][ 3 ] = 1. / 5.; 52 53 inImage->data.F64[ 2 ][ 0 ] = 1. / 3.; 54 inImage->data.F64[ 2 ][ 1 ] = 1. / 4.; 55 inImage->data.F64[ 2 ][ 2 ] = 1. / 5.; 56 inImage->data.F64[ 2 ][ 3 ] = 1. / 6.; 57 58 inImage->data.F64[ 3 ][ 0 ] = 1. / 4.; 59 inImage->data.F64[ 3 ][ 1 ] = 1. / 5.; 60 inImage->data.F64[ 3 ][ 2 ] = 1. / 6.; 61 inImage->data.F64[ 3 ][ 3 ] = 1. / 7.; 62 63 PRINT_MATRIX( inImage ); 64 printFooter( stdout, "psMatrix", "Create input and output images", true ); 77 outImage32 = (psImage*) psImageAlloc(4, 4, PS_TYPE_F32); 78 inImage32 = (psImage*) psImageAlloc(4, 4, PS_TYPE_F32); 79 inImage32->data.F32[0][0] = 1./1.; 80 inImage32->data.F32[0][1] = 1./2.; 81 inImage32->data.F32[0][2] = 1./3.; 82 inImage32->data.F32[0][3] = 1./4.; 83 inImage32->data.F32[1][0] = 1./2.; 84 inImage32->data.F32[1][1] = 1./3.; 85 inImage32->data.F32[1][2] = 1./4.; 86 inImage32->data.F32[1][3] = 1./5.; 87 inImage32->data.F32[2][0] = 1./3.; 88 inImage32->data.F32[2][1] = 1./4.; 89 inImage32->data.F32[2][2] = 1./5.; 90 inImage32->data.F32[2][3] = 1./6.; 91 inImage32->data.F32[3][0] = 1./4.; 92 inImage32->data.F32[3][1] = 1./5.; 93 inImage32->data.F32[3][2] = 1./6.; 94 inImage32->data.F32[3][3] = 1./7.; 95 printFooter(stdout, "psMatrix", "Create input and output images", true); 65 96 66 97 67 98 // Test B - Calculate Eigenvectors 68 printPositiveTestHeader( stdout, "psMatrix", "Calculate Eigenvectors" ); 69 psMatrixEigenvectors( outImage, inImage ); 70 PRINT_MATRIX( outImage ); 71 printFooter( stdout, "psMatrix", "Calculate Eigenvectors", true ); 99 printPositiveTestHeader(stdout, "psMatrix", "Calculate Eigenvectors"); 100 psMatrixEigenvectors(outImage, inImage); 101 CHECK_MATRIX(outImage); 102 psMatrixEigenvectors(outImage32, inImage32); 103 CHECK_MATRIX(outImage32); 104 printFooter(stdout, "psMatrix", "Calculate Eigenvectors", true); 72 105 73 106 74 107 // Test C - Free input and output images 75 printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" ); 76 psFree( outImage ); 77 psFree( inImage ); 78 psS32 nLeaks = psMemCheckLeaks( 0, NULL, stdout, false ); 79 if ( nLeaks != 0 ) { 80 printf( "ERROR: Found %d memory leaks\n", nLeaks ); 108 printPositiveTestHeader(stdout, "psMatrix", "Free input and output images"); 109 psFree(outImage); 110 psFree(inImage); 111 psFree(outImage32); 112 psFree(inImage32); 113 psS32 nLeaks = psMemCheckLeaks(0, NULL, stdout, false); 114 if (nLeaks != 0) { 115 printf("ERROR: Found %d memory leaks\n", nLeaks); 81 116 } 82 psS32 nBad = psMemCheckCorruption( 0);83 if ( nBad) {84 printf( "ERROR: Found %d bad memory blocks\n", nBad);117 psS32 nBad = psMemCheckCorruption(0); 118 if (nBad) { 119 printf("ERROR: Found %d bad memory blocks\n", nBad); 85 120 } 86 printFooter( stdout, "psMatrix" , "Free input and output images", true);121 printFooter(stdout, "psMatrix" , "Free input and output images", true); 87 122 88 123 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.
