Changeset 872 for trunk/psLib/test/dataManip/tst_psMatrix03.c
- Timestamp:
- Jun 4, 2004, 1:42:57 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix03.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix03.c
r831 r872 8 8 * C) Determine solution to matrix equation 9 9 * D) Free input and output images and vectors 10 * 10 * E) Attempt to use null image input argument 11 * F) Attempt to use null input vector argument 12 * G) ttempt to use null LU image argument 13 * 11 14 * @author Ross Harman, MHPCC 12 15 * 13 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06-0 2 23:29:39$16 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-06-04 23:42:18 $ 15 18 * 16 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 24 #include "psTest.h" 22 25 23 #define PRINT_MATRIX(IMAGE) \26 #define PRINT_MATRIX(IMAGE) \ 24 27 for(int i=IMAGE->numRows-1; i>-1; i--) { \ 25 28 for(int j=0; j<IMAGE->numCols; j++) { \ 26 29 printf("%f ", IMAGE->data.F64[i][j]); \ 27 } \28 printf("\n"); \30 } \ 31 printf("\n"); \ 29 32 } 30 31 #define PRINT_VECTOR(VECTOR) \32 for(int i=0; i<VECTOR->n; i++) { \33 printf("%f\n", VECTOR->data.F64[i]); \33 \ 34 #define PRINT_VECTOR(VECTOR) \ 35 for(int i=0; i<VECTOR->n; i++) { \ 36 printf("%f\n", VECTOR->data.F64[i]); \ 34 37 } 35 38 … … 40 43 psImage *luImage = NULL; 41 44 psImage *inImage = NULL; 45 psImage *tempImage = NULL; 46 psVector *tempVector = NULL; 42 47 psVector *perm = NULL; 43 48 psVector *outVector = NULL; … … 73 78 // Test B - Calculate LU matrix 74 79 printPositiveTestHeader(stdout, "psMatrix", "Calculate LU matrix"); 75 psMatrixLUD(luImage, perm, inImage); 80 tempImage = luImage; 81 luImage = psMatrixLUD(luImage, perm, inImage); 76 82 PRINT_MATRIX(luImage); 83 if(luImage->type.type != PS_DIMEN_IMAGE) { 84 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 85 } else if(luImage != tempImage) { 86 printf("Error: Return pointer not equal to output argument pointer\n"); 87 } 77 88 printFooter(stdout, "psMatrix", "Calculate LU matrix", true); 78 89 … … 80 91 // Test C - Determine solution to matrix equation 81 92 printPositiveTestHeader(stdout, "psMatrix", "Determine solution to matrix equation"); 82 psMatrixLUSolve(outVector, luImage, inVector, perm); 93 tempVector = outVector; 94 outVector = psMatrixLUSolve(outVector, luImage, inVector, perm); 83 95 PRINT_VECTOR(outVector); 96 if(outVector->type.type != PS_DIMEN_VECTOR) { 97 printf("Error: Resulting image is not PS_DIMEN_VECTOR\n"); 98 } else if(outVector != tempVector) { 99 printf("Error: Return pointer not equal to output argument pointer\n"); 100 } 84 101 printFooter(stdout, "psMatrix", "Determine solution to matrix equation", true); 85 102 … … 99 116 printFooter(stdout, "psMatrix" ,"Free input and output images and vectors", true); 100 117 118 119 // Test E - Attempt to use null image input argument 120 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null image input argument", 121 "Invalid operation: inImage or its data is NULL.", 0); 122 psImage *imageTest = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 123 psMatrixLUD(imageTest, NULL, NULL); 124 printFooter(stdout, "psMatrix", "Attempt to use null image input argument", true); 125 126 127 // Test F - Attempt to use null input vector argument 128 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input vector argument", 129 "Invalid operation: inVector or its data is NULL.", 0); 130 psVector *vectorBad = NULL; 131 psVector *vectorBadOut = (psVector*)psVectorAlloc(3, PS_TYPE_F64); 132 psVector *permBad = (psVector*)psVectorAlloc(3, PS_TYPE_F64); 133 psMatrixLUSolve(vectorBadOut, imageTest, vectorBad, permBad); 134 printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true); 135 136 137 // Test G - Attempt to use null LU image argument 138 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null LU image argument", 139 "Invalid operation: inImage or its data is NULL.", 0); 140 psMatrixLUSolve(vectorBadOut, NULL, vectorBad, permBad); 141 printFooter(stdout, "psMatrix", "Attempt to use null LU image argument", true); 101 142 return 0; 102 143 }
Note:
See TracChangeset
for help on using the changeset viewer.
