Changeset 2695 for trunk/psLib/test/dataManip/tst_psMatrix07.c
- Timestamp:
- Dec 10, 2004, 12:55:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix07.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix07.c
r2392 r2695 16 16 * @author Ross Harman, MHPCC 17 17 * 18 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $19 * @date $Date: 2004-1 1-22 21:00:21$18 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2004-12-10 22:55:17 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psTest.h" 27 27 28 #define PRINT_MATRIX(IMAGE) \ 29 for(psS32 i=0; i<IMAGE->numRows; i++) { \ 30 for(psS32 j=0; j<IMAGE->numCols; j++) { \ 31 printf("%f ", IMAGE->data.F64[i][j]); \ 32 } \ 33 printf("\n"); \ 28 29 #define TOLERANCE 0.000001 30 31 #define CHECK_MATRIX(IMAGE,TRUTH) \ 32 for(psU32 i=0; i<IMAGE->numRows; i++) { \ 33 for(psU32 j=0; j<IMAGE->numCols; j++) { \ 34 if(IMAGE->type.type == PS_TYPE_F64) { \ 35 if(fabs(IMAGE->data.F64[i][j]-TRUTH[i][j]) > TOLERANCE) { \ 36 printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j, \ 37 IMAGE->data.F64[i][j], TRUTH[i][j]); \ 38 } \ 39 } else if(IMAGE->type.type == PS_TYPE_F32){ \ 40 if(fabs(IMAGE->data.F32[i][j]-TRUTH[i][j]) > TOLERANCE) { \ 41 printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j, \ 42 IMAGE->data.F32[i][j], TRUTH[i][j]); \ 43 } \ 44 } \ 45 } \ 34 46 } 35 47 36 #define PRINT_VECTOR(VECTOR) \ 37 for(psS32 i=0; i<VECTOR->n; i++) { \ 38 printf("%f\n", VECTOR->data.F64[i]); \ 48 #define CHECK_VECTOR(VECTOR) \ 49 for(psU32 i=0; i<VECTOR->n; i++) { \ 50 if(VECTOR->type.type == PS_TYPE_F64) { \ 51 if(fabs(VECTOR->data.F64[i]-truthVector[i]) > TOLERANCE) { \ 52 printf("Vector values at element %d don't agree %lf vs %lf\n", i, \ 53 VECTOR->data.F64[i], truthVector[i]); \ 54 } \ 55 } else if(VECTOR->type.type == PS_TYPE_F32){ \ 56 if(fabs(VECTOR->data.F32[i]-truthVector[i]) > TOLERANCE) { \ 57 printf("Vector values at element %d don't agree %f vs %lf\n", i, \ 58 VECTOR->data.F32[i], truthVector[i]); \ 59 } \ 60 } \ 39 61 } 40 62 41 63 42 psS32 main(psS32 argc, 43 char* argv[]) 64 psS32 main(psS32 argc, char* argv[]) 44 65 { 45 66 psVector *v1 = NULL; … … 48 69 psImage *m1 = NULL; 49 70 psVector *v2 = NULL; 71 psVector *v3 = NULL; 50 72 psImage *m2 = NULL; 51 73 psImage *m3 = NULL; … … 53 75 psImage *badImage = NULL; 54 76 77 double truthVector[3] = {0.0, 1.0, 2.0}; 78 double truthMatrix[3][1] = {{0.0}, {1.0}, {2.0}}; 55 79 56 80 // Test A - Create input and output images … … 73 97 m4->data.F64[0][1] = 1.0; 74 98 m4->data.F64[0][2] = 2.0; 75 PRINT_MATRIX(m1);76 printf("\n");77 PRINT_MATRIX(m4);78 printf("\n");79 PRINT_VECTOR(v2);80 99 printFooter(stdout, "psMatrix", "Create input and output images and vectors", true); 81 100 … … 85 104 tempVector = v1; 86 105 v1 = psMatrixToVector(v1, m1); 87 PRINT_VECTOR(v1);106 CHECK_VECTOR(v1); 88 107 if(v1->type.dimen != PS_DIMEN_VECTOR) { 89 108 printf("Error: Resulting image is not PS_DIMEN_VECTOR\n"); 90 } else 91 if(v1 != tempVector) { 92 printf("Error: Return pointer not equal to output argument pointer\n"); 93 } 109 } else if(v1 != tempVector) { 110 printf("Error: Return pointer not equal to output argument pointer\n"); 111 } 94 112 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_VECTOR vector", true); 95 113 … … 104 122 // Test D - Convert matrix to PS_DIMEN_TRANSV vector 105 123 printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector"); 106 v1->type.dimen = PS_DIMEN_TRANSV; 107 psMatrixToVector(v1, m4); 108 PRINT_VECTOR(v1); 109 if(v1->type.dimen != PS_DIMEN_TRANSV) { 124 v3 = psVectorAlloc(3, PS_TYPE_F64); 125 v3->type.dimen = PS_DIMEN_TRANSV; 126 psMatrixToVector(v3, m4); 127 CHECK_VECTOR(v3); 128 if(v3->type.dimen != PS_DIMEN_TRANSV) { 110 129 printf("Error: Resulting image is not PS_DIMEN_TRANSV\n"); 111 } else 112 if(v1 != tempVector) { 113 printf("Error: Return pointer not equal to output argument pointer\n"); 114 } 130 } else if(v3 != tempVector) { 131 printf("Error: Return pointer not equal to output argument pointer\n"); 132 } 115 133 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector", true); 116 134 … … 127 145 tempImage = m2; 128 146 m2 = psVectorToMatrix(m2, v2); 129 PRINT_MATRIX(m2);147 CHECK_MATRIX(m2,truthMatrix); 130 148 if(m2->type.dimen != PS_DIMEN_IMAGE) { 131 149 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 132 } else 133 if(m2 != tempImage) { 134 printf("Error: Return pointer not equal to output argument pointer\n"); 135 } 150 } else if(m2 != tempImage) { 151 printf("Error: Return pointer not equal to output argument pointer\n"); 152 } 136 153 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_VECTOR vector to matrix", true); 137 154 … … 149 166 tempImage = m3; 150 167 psVectorToMatrix(m3, v2); 151 PRINT_MATRIX(m3);168 CHECK_MATRIX(m3, truthMatrix); 152 169 if(m3->type.dimen != PS_DIMEN_IMAGE) { 153 170 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 154 } else 155 if(m3 != tempImage) { 156 printf("Error: Return pointer not equal to output argument pointer\n"); 157 } 171 } else if(m3 != tempImage) { 172 printf("Error: Return pointer not equal to output argument pointer\n"); 173 } 158 174 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_TRANSV vector to matrix", true); 159 175 … … 165 181 psFree(m2); 166 182 psFree(v2); 183 psFree(v3); 167 184 psFree(m3); 168 185 psFree(m4);
Note:
See TracChangeset
for help on using the changeset viewer.
