Changeset 2686 for trunk/psLib/test/dataManip/tst_psMatrix04.c
- Timestamp:
- Dec 10, 2004, 10:00:22 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix04.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix04.c
r2392 r2686 10 10 * E) Attempt to use null input image argument 11 11 * F) Attempt to use null input float argument 12 * 12 * 13 13 * @author Ross Harman, MHPCC 14 14 * 15 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-1 1-22 21:00:21$15 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-12-10 19:59:49 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "psTest.h" 24 24 25 #define PRINT_MATRIX(IMAGE) \ 26 for(psS32 i=IMAGE->numRows-1; i>-1; i--) { \ 27 for(psS32 j=0; j<IMAGE->numCols; j++) { \ 28 printf("%f ", IMAGE->data.F64[i][j]); \ 29 } \ 30 printf("\n"); \ 25 26 #define TOLERANCE 0.000001 27 28 #define CHECK_MATRIX(IMAGE) \ 29 for(psU32 i=0; i<IMAGE->numRows; i++) { \ 30 for(psU32 j=0; j<IMAGE->numCols; j++) { \ 31 if(IMAGE->type.type == PS_TYPE_F64) { \ 32 if(fabs(IMAGE->data.F64[i][j]-truthMatrix[i][j]) > TOLERANCE) { \ 33 printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j, \ 34 IMAGE->data.F64[i][j], truthMatrix[i][j]); \ 35 } \ 36 } else if(IMAGE->type.type == PS_TYPE_F32){ \ 37 if(fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j]) > TOLERANCE) { \ 38 printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j, \ 39 IMAGE->data.F32[i][j], truthMatrix[i][j]); \ 40 } \ 41 } \ 42 } \ 31 43 } 32 44 45 #define CHECK_VALUE(VALUE) \ 46 if(fabs(VALUE-truthValue) > TOLERANCE) { \ 47 printf("Values don't agree %lf vs %lf\n", VALUE, truthValue); \ 48 } 33 49 34 psS32 main(psS32 argc, 35 char* argv[]) 50 psS32 main(psS32 argc, char* argv[]) 36 51 { 37 52 float det = 0.0f; … … 40 55 psImage *inImage = NULL; 41 56 psImage *tempImage = NULL; 57 psImage *outImage32 = NULL; 58 psImage *inImage32 = NULL; 59 psImage *tempImage32 = NULL; 60 61 double truthMatrix[3][3] = {{4.0000000, -4.333333, -2.333333}, 62 {-1.000000, 1.666667, 0.666667}, 63 {-1.000000, 0.666667, 0.666667}}; 64 double truthValue = 3.0; 42 65 43 66 … … 55 78 inImage->data.F64[2][1] = 5; 56 79 inImage->data.F64[2][2] = 7; 57 PRINT_MATRIX(inImage); 80 81 outImage32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32); 82 inImage32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32); 83 inImage32->data.F32[0][0] = 2; 84 inImage32->data.F32[0][1] = 4; 85 inImage32->data.F32[0][2] = 3; 86 inImage32->data.F32[1][0] = 0; 87 inImage32->data.F32[1][1] = 1; 88 inImage32->data.F32[1][2] = -1; 89 inImage32->data.F32[2][0] = 3; 90 inImage32->data.F32[2][1] = 5; 91 inImage32->data.F32[2][2] = 7; 58 92 printFooter(stdout, "psMatrix", "Create input and output images", true); 59 93 … … 63 97 tempImage = outImage; 64 98 outImage = psMatrixInvert(outImage, inImage, &det); 65 PRINT_MATRIX(outImage);66 printf("\ndet = %f\n",det);99 CHECK_MATRIX(outImage); 100 CHECK_VALUE(det); 67 101 if(outImage->type.dimen != PS_DIMEN_IMAGE) { 68 102 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 69 } else 70 if(outImage != tempImage) { 71 printf("Error: Return pointer not equal to output argument pointer\n"); 72 } 103 } else if(outImage != tempImage) { 104 printf("Error: Return pointer not equal to output argument pointer\n"); 105 } 106 det = 0.0f; 107 tempImage32 = outImage32; 108 outImage32 = psMatrixInvert(outImage32, inImage32, &det); 109 CHECK_MATRIX(outImage32); 110 CHECK_VALUE(det); 111 if(outImage32->type.dimen != PS_DIMEN_IMAGE) { 112 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 113 } else if(outImage32 != tempImage32) { 114 printf("Error: Return pointer not equal to output argument pointer\n"); 115 } 73 116 printFooter(stdout, "psMatrix", "Invert matrix and calculate determinant", true); 74 117 … … 77 120 printPositiveTestHeader(stdout, "psMatrix", "Calculate determinant only"); 78 121 det2 = psMatrixDeterminant(inImage); 79 printf("det = %f\n", *det2); 122 CHECK_VALUE(*det2); 123 psFree(det2); 124 det2 = psMatrixDeterminant(inImage32); 125 CHECK_VALUE(*det2); 126 psFree(det2); 80 127 printFooter(stdout, "psMatrix", "Calculate determinant only", true); 81 128 … … 85 132 psFree(outImage); 86 133 psFree(inImage); 87 psFree(det2); 134 psFree(outImage32); 135 psFree(inImage32); 88 136 if(psMemCheckLeaks(0, NULL, stdout, false) != 0 ) { 89 137 psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
Note:
See TracChangeset
for help on using the changeset viewer.
