Changeset 897 for trunk/psLib/test/dataManip/tst_psMatrix04.c
- Timestamp:
- Jun 7, 2004, 10:25:03 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
r798 r897 8 8 * C) Calculate determinant only 9 9 * D) Free input and output images 10 * 10 * E) Attempt to use null input image argument 11 * F) Attempt to use null input float argument 12 * 11 13 * @author Ross Harman, MHPCC 12 14 * 13 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-0 5-28 02:52:23 $15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-06-07 20:25:03 $ 15 17 * 16 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 24 23 25 #define PRINT_MATRIX(IMAGE) \ 24 for(int i=IMAGE->numRows-1; i>-1; i--) { \25 for(int j=0; j<IMAGE->numCols; j++) { \26 printf("%f ", IMAGE->data.F64[i][j]); \27 } \28 printf("\n"); \26 for(int i=IMAGE->numRows-1; i>-1; i--) { \ 27 for(int j=0; j<IMAGE->numCols; j++) { \ 28 printf("%f ", IMAGE->data.F64[i][j]); \ 29 } \ 30 printf("\n"); \ 29 31 } 30 32 … … 34 36 { 35 37 float det = 0.0f; 38 float *det2 = NULL; 36 39 psImage *outImage = NULL; 37 40 psImage *inImage = NULL; 41 psImage *tempImage = NULL; 38 42 39 43 … … 57 61 // Test B - Invert matrix and calculate determinant 58 62 printPositiveTestHeader(stdout, "psMatrix", "Invert matrix and calculate determinant"); 59 psMatrixInvert(outImage, inImage, &det); 63 tempImage = outImage; 64 outImage = psMatrixInvert(outImage, inImage, &det); 60 65 PRINT_MATRIX(outImage); 61 66 printf("\ndet = %f\n", det); 67 if(outImage->type.dimen != PS_DIMEN_IMAGE) { 68 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 69 } else if(outImage != tempImage) { 70 printf("Error: Return pointer not equal to output argument pointer\n"); 71 } 62 72 printFooter(stdout, "psMatrix", "Invert matrix and calculate determinant", true); 63 73 … … 65 75 // Test C - Calculate determinant only 66 76 printPositiveTestHeader(stdout, "psMatrix", "Calculate determinant only"); 67 det = 0.0f; 68 det = psMatrixDeterminant(inImage); 69 printf("det = %f\n", det); 77 det2 = psMatrixDeterminant(inImage); 78 printf("det = %f\n", *det2); 70 79 printFooter(stdout, "psMatrix", "Calculate determinant only", true); 71 80 … … 75 84 psImageFree(outImage); 76 85 psImageFree(inImage); 86 psFree(det2); 77 87 psMemCheckLeaks(0, NULL, stdout); 78 88 int nBad = psMemCheckCorruption(0); … … 82 92 printFooter(stdout, "psMatrix" ,"Free input and output images", true); 83 93 94 95 // Test E - Attempt to use null input image argument 96 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input image argument", 97 "Invalid operation: inImage or its data is NULL.", 0); 98 psImage *badOutImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 99 psMatrixInvert(badOutImage, NULL, &det); 100 printFooter(stdout, "psMatrix", "Attempt to use null input image argument", true); 101 102 103 // Test F - Attempt to use null input float argument 104 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input float argument", 105 "Invalid operation: determinant argument is NULL.", 0); 106 psImage *badInImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 107 psMatrixInvert(badOutImage, badInImage, NULL); 108 printFooter(stdout, "psMatrix", "Attempt to use null input float argument", true); 109 84 110 return 0; 85 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
