Changeset 908 for trunk/psLib/test/dataManip/tst_psMatrix07.c
- Timestamp:
- Jun 7, 2004, 3:58:03 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix07.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix07.c
r831 r908 5 5 * This test driver contains the following tests for psMatrix test point 7: 6 6 * A) Create input and output images and vectors 7 * B) Convert matrix to vector 8 * C) Convert vector to matrix 9 * D) Free input and output images and vectors 7 * B) Convert matrix to PS_DIMEN_VECTOR vector 8 * C) Attempt to use null image input argument 9 * D) Convert matrix to PS_DIMEN_TRANSV vector 10 * E) Improper image size 11 * F) Convert PS_DIMEN_VECTOR vector to matrix 12 * G) Attempt to use null input vector argument 13 * H) Convert PS_DIMEN_TRANSV vector to matrix 14 * I) Free input and output images and vectors 10 15 * 11 16 * @author Ross Harman, MHPCC 12 17 * 13 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06-0 2 23:29:39$18 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2004-06-08 01:56:35 $ 15 20 * 16 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 27 23 28 #define PRINT_MATRIX(IMAGE) \ 24 for(int i=0; i<IMAGE->numRows; i++) { \25 for(int j=0; j<IMAGE->numCols; j++) { \26 printf("%f ", IMAGE->data.F64[i][j]); \27 } \28 printf("\n"); \29 for(int i=0; i<IMAGE->numRows; i++) { \ 30 for(int j=0; j<IMAGE->numCols; j++) { \ 31 printf("%f ", IMAGE->data.F64[i][j]); \ 32 } \ 33 printf("\n"); \ 29 34 } 30 35 31 36 #define PRINT_VECTOR(VECTOR) \ 32 for(int i=0; i<VECTOR->n; i++) { \33 printf("%f\n", VECTOR->data.F64[i]); \37 for(int i=0; i<VECTOR->n; i++) { \ 38 printf("%f\n", VECTOR->data.F64[i]); \ 34 39 } 35 40 … … 39 44 { 40 45 psVector *v1 = NULL; 46 psVector *tempVector = NULL; 47 psImage *tempImage = NULL; 41 48 psImage *m1 = NULL; 42 49 psVector *v2 = NULL; 43 50 psImage *m2 = NULL; 51 psImage *m3 = NULL; 52 psImage *m4 = NULL; 53 psImage *badImage = NULL; 44 54 45 55 … … 50 60 v2 = (psVector*)psVectorAlloc(3, PS_TYPE_F64); 51 61 m2 = (psImage*)psImageAlloc(1, 3, PS_TYPE_F64); 62 m3 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64); 63 m4 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64); 64 badImage = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64); 52 65 m1->data.F64[0][0] = 0.0; 53 66 m1->data.F64[1][0] = 1.0; … … 57 70 v2->data.F64[2] = 2.0; 58 71 v2->n = 3; 72 m4->data.F64[0][0] = 0.0; 73 m4->data.F64[0][1] = 1.0; 74 m4->data.F64[0][2] = 2.0; 59 75 PRINT_MATRIX(m1); 76 printf("\n"); 77 PRINT_MATRIX(m4); 60 78 printf("\n"); 61 79 PRINT_VECTOR(v2); … … 63 81 64 82 65 // Test B - Convert matrix to vector 66 printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to vector"); 67 psMatrixToVector(v1, m1); 83 // Test B - Convert matrix to PS_DIMEN_VECTOR vector 84 printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to PS_DIMEN_VECTOR vector"); 85 tempVector = v1; 86 v1 = psMatrixToVector(v1, m1); 68 87 PRINT_VECTOR(v1); 69 printFooter(stdout, "psMatrix", "Calculate Eigenvectors", true); 88 if(v1->type.dimen != PS_DIMEN_VECTOR) { 89 printf("Error: Resulting image is not PS_DIMEN_VECTOR\n"); 90 } else if(v1 != tempVector) { 91 printf("Error: Return pointer not equal to output argument pointer\n"); 92 } 93 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_VECTOR vector", true); 70 94 71 95 72 // Test C - Convert vector to matrix73 print PositiveTestHeader(stdout, "psMatrix", "Convert vector to matrix");74 psVectorToMatrix(m2, v2);75 PRINT_MATRIX(m2);76 printFooter(stdout, "psMatrix", " Convert vector to matrix", true);96 // Test C - Attempt to use null image input argument 97 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null image input argument", 98 "Invalid operation: inImage or its data is NULL.", 0); 99 v1 = psMatrixToVector(v1, NULL); 100 printFooter(stdout, "psMatrix", "Attempt to use null image input argument", true); 77 101 78 102 79 // Test D - Free input and output images 103 // Test D - Convert matrix to PS_DIMEN_TRANSV vector 104 printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector"); 105 v1->type.dimen = PS_DIMEN_TRANSV; 106 psMatrixToVector(v1, m4); 107 PRINT_VECTOR(v1); 108 if(v1->type.dimen != PS_DIMEN_TRANSV) { 109 printf("Error: Resulting image is not PS_DIMEN_TRANSV\n"); 110 } else if(v1 != tempVector) { 111 printf("Error: Return pointer not equal to output argument pointer\n"); 112 } 113 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector", true); 114 115 116 // Test E - Improper image size 117 printNegativeTestHeader(stdout,"psMatrix", "Improper image size", 118 "Image does not have dim with 1 col or 1 row: (2 x 2).", 0); 119 psMatrixToVector(v1, badImage); 120 printFooter(stdout, "psMatrix", "Improper image size", true); 121 122 123 // Test F - Convert PS_DIMEN_VECTOR vector to matrix 124 printPositiveTestHeader(stdout, "psMatrix", "Convert PS_DIMEN_VECTOR vector to matrix"); 125 tempImage = m2; 126 m2 = psVectorToMatrix(m2, v2); 127 PRINT_MATRIX(m2); 128 if(m2->type.dimen != PS_DIMEN_IMAGE) { 129 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 130 } else if(m2 != tempImage) { 131 printf("Error: Return pointer not equal to output argument pointer\n"); 132 } 133 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_VECTOR vector to matrix", true); 134 135 136 // Test G - Attempt to use null input vector argument 137 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input vector argument", 138 "Invalid operation: inVector or its data is NULL.", 0); 139 psVectorToMatrix(m2, NULL); 140 printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true); 141 142 143 // Test H - Convert PS_DIMEN_TRANSV vector to matrix 144 printPositiveTestHeader(stdout, "psMatrix", "Convert PS_DIMEN_TRANSV vector to matrix"); 145 v2->type.dimen = PS_DIMEN_TRANSV; 146 tempImage = m3; 147 psVectorToMatrix(m3, v2); 148 PRINT_MATRIX(m3); 149 if(m3->type.dimen != PS_DIMEN_IMAGE) { 150 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 151 } else if(m3 != tempImage) { 152 printf("Error: Return pointer not equal to output argument pointer\n"); 153 } 154 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_TRANSV vector to matrix", true); 155 156 157 // Test I - Free input and output images 80 158 printPositiveTestHeader(stdout, "psMatrix", "Free input and output images and vectors"); 81 159 psImageFree(m1); … … 83 161 psImageFree(m2); 84 162 psVectorFree(v2); 163 psImageFree(m3); 164 psImageFree(m4); 165 psImageFree(badImage); 85 166 psMemCheckLeaks(0, NULL, stdout); 86 167 int nBad = psMemCheckCorruption(0);
Note:
See TracChangeset
for help on using the changeset viewer.
