Changeset 2674 for trunk/psLib/test/dataManip/tst_psMatrix01.c
- Timestamp:
- Dec 9, 2004, 11:00:39 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix01.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix01.c
r2392 r2674 6 6 * A) Create input and output images 7 7 * B) Transpose input image into output image 8 * C) Transpose input image into auto allocated NULL output image 8 * C) Transpose input image into auto allocated NULL output image 9 9 * D) Free images and check for leaks 10 10 * 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 1-22 21:00:21$13 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-12-09 21:00:39 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 23 23 #define PRINT_MATRIX(IMAGE) \ 24 for(psS32 i=IMAGE->numRows-1; i>-1; i--) { \ 25 for(psS32 j=0; j<IMAGE->numCols; j++) { \ 26 printf("%f ", IMAGE->data.F64[i][j]); \ 27 } \ 28 printf("\n"); \ 29 } 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") 30 35 31 psS32 main( psS32 argc, 32 char* argv[] ) 36 psS32 main( psS32 argc, char* argv[] ) 33 37 { 34 38 psImage * tempImage = NULL; … … 36 40 37 41 // Test A - Create input and output images 38 printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" ); 39 psImage *inImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 ); 40 psImage *outImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 ); 41 inImage->data.F64[ 0 ][ 0 ] = 1; 42 inImage->data.F64[ 0 ][ 1 ] = 2; 43 inImage->data.F64[ 0 ][ 2 ] = 3; 44 inImage->data.F64[ 1 ][ 0 ] = 4; 45 inImage->data.F64[ 1 ][ 1 ] = 5; 46 inImage->data.F64[ 1 ][ 2 ] = 6; 47 inImage->data.F64[ 2 ][ 0 ] = 7; 48 inImage->data.F64[ 2 ][ 1 ] = 8; 49 inImage->data.F64[ 2 ][ 2 ] = 9; 50 PRINT_MATRIX( inImage ); 51 printFooter( stdout, "psMatrix", "Create input and output images", true ); 42 printPositiveTestHeader(stdout, "psMatrix", "Create input and output images"); 43 psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 44 psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 45 inImage->data.F64[0][0] = 1; 46 inImage->data.F64[0][1] = 2; 47 inImage->data.F64[0][2] = 3; 48 inImage->data.F64[1][0] = 4; 49 inImage->data.F64[1][1] = 5; 50 inImage->data.F64[1][2] = 6; 51 inImage->data.F64[2][0] = 7; 52 inImage->data.F64[2][1] = 8; 53 inImage->data.F64[2][2] = 9; 54 psImage *inImageF32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32); 55 psImage *outImageF32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32); 56 inImageF32->data.F32[0][0] = 1; 57 inImageF32->data.F32[0][1] = 2; 58 inImageF32->data.F32[0][2] = 3; 59 inImageF32->data.F32[1][0] = 4; 60 inImageF32->data.F32[1][1] = 5; 61 inImageF32->data.F32[1][2] = 6; 62 inImageF32->data.F32[2][0] = 7; 63 inImageF32->data.F32[2][1] = 8; 64 inImageF32->data.F32[2][2] = 9; 65 PRINT_MATRIX(inImage); 66 PRINT_MATRIX(inImageF32); 67 printFooter(stdout, "psMatrix", "Create input and output images", true); 52 68 53 69 54 70 // Test B - Transpose input image into output image 55 printPositiveTestHeader( stdout, "psMatrix", "Transpose input image into output image");71 printPositiveTestHeader(stdout, "psMatrix", "Transpose input image into output image"); 56 72 tempImage = outImage; 57 outImage = psMatrixTranspose( outImage, inImage ); 58 PRINT_MATRIX( outImage ); 59 if ( outImage->type.dimen != PS_DIMEN_IMAGE ) { 60 printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n" ); 61 } else 62 if ( outImage != tempImage ) { 63 printf( "Error: Return pointer not equal to output argument pointer\n" ); 64 } 65 printFooter( stdout, "psMatrix", "Transpose input image into output image", true ); 73 outImage = psMatrixTranspose(outImage, inImage); 74 PRINT_MATRIX(outImage); 75 if (outImage->type.dimen != PS_DIMEN_IMAGE) { 76 printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n"); 77 } else if (outImage != tempImage) { 78 printf("Error: Return pointer not equal to output argument pointer\n"); 79 } 80 81 tempImage = outImageF32; 82 outImageF32 = psMatrixTranspose(outImageF32, inImageF32); 83 PRINT_MATRIX(outImageF32); 84 if (outImageF32->type.dimen != PS_DIMEN_IMAGE) { 85 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 86 } else if (outImageF32 != tempImage) { 87 printf("Error: Return pointer not equal to output argument pointer\n"); 88 } 89 printFooter(stdout, "psMatrix", "Transpose input image into output image", true); 66 90 67 91 68 // Test C - Transpose input image into auto allocated NULL output image69 printPositiveTestHeader( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image");92 // Test C - Transpose input image into auto allocated NULL output image 93 printPositiveTestHeader(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image"); 70 94 psImage *outImageNull = NULL; 71 outImageNull = psMatrixTranspose( outImageNull, inImage ); 72 PRINT_MATRIX( outImageNull ); 73 printFooter( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image", true ); 95 outImageNull = psMatrixTranspose(outImageNull, inImage); 96 PRINT_MATRIX(outImageNull); 97 98 psImage *outImageNullF32 = NULL; 99 outImageNullF32 = psMatrixTranspose(outImageNullF32, inImageF32); 100 PRINT_MATRIX(outImageNullF32); 101 printFooter(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image", true); 74 102 75 103 76 104 // Test D - Free images and check for leaks 77 printPositiveTestHeader( stdout, "psMatrix", "Free images and check for leaks" ); 78 psFree( inImage ); 79 psFree( outImage ); 80 psFree( outImageNull ); 81 psS32 nLeaks = psMemCheckLeaks( 0, NULL, stdout, false ); 82 if ( nLeaks != 0 ) { 83 printf( "ERROR: Found %d memory leaks\n", nLeaks ); 105 printPositiveTestHeader(stdout, "psMatrix", "Free images and check for leaks"); 106 psFree(inImage); 107 psFree(outImage); 108 psFree(outImageNull); 109 psFree(inImageF32); 110 psFree(outImageF32); 111 psFree(outImageNullF32); 112 psS32 nLeaks = psMemCheckLeaks(0, NULL, stdout, false); 113 if (nLeaks != 0) { 114 printf("ERROR: Found %d memory leaks\n", nLeaks); 84 115 } 85 psS32 nBad = psMemCheckCorruption( 0);86 if ( nBad) {87 printf( "ERROR: Found %d bad memory blocks\n", nBad);116 psS32 nBad = psMemCheckCorruption(0); 117 if (nBad) { 118 printf("ERROR: Found %d bad memory blocks\n", nBad); 88 119 } 89 printFooter( stdout, "psMatrix" , "Free images and check for leaks", true);120 printFooter(stdout, "psMatrix" , "Free images and check for leaks", true); 90 121 91 122 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.
