- Timestamp:
- Aug 6, 2004, 12:34:06 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c
r1365 r1406 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-0 2 19:43:23$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-06 22:34:06 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 #define PRINT_SCALAR(SCALAR,TYPE) \ 26 26 if(PS_IS_PSELEMTYPE_COMPLEX(SCALAR->type.type)) { \ 27 printf("%.2f%f+.2i ", creal(SCALAR->data.TYPE), cimag(SCALAR->data.TYPE)); \28 } else if(PS_IS_PSELEMTYPE_INT(SCALAR->type.type)) { \29 printf("%d", (int)SCALAR->data.TYPE); \30 } else { \31 printf("%.2f", (double)SCALAR->data.TYPE); \32 } \27 printf("%.2f%f+.2i ", creal(SCALAR->data.TYPE), cimag(SCALAR->data.TYPE)); \ 28 } else if(PS_IS_PSELEMTYPE_INT(SCALAR->type.type)) { \ 29 printf("%d", (int)SCALAR->data.TYPE); \ 30 } else { \ 31 printf("%.2f", (double)SCALAR->data.TYPE); \ 32 } \ 33 33 printf("\n\n"); 34 34 … … 36 36 #define PRINT_VECTOR(VECTOR,TYPE) \ 37 37 for(int i=0; i<VECTOR->n; i++) { \ 38 if(PS_IS_PSELEMTYPE_COMPLEX(VECTOR->type.type)) { \39 printf("%.2f%+.2fi\n", creal(VECTOR->data.TYPE[i]), cimag(VECTOR->data.TYPE[i])); \40 } else if(PS_IS_PSELEMTYPE_INT(VECTOR->type.type)) { \41 printf("%d\n", (int)VECTOR->data.TYPE[i]); \42 } else { \43 printf("%.2f\n", (double)VECTOR->data.TYPE[i]); \44 } \45 } \38 if(PS_IS_PSELEMTYPE_COMPLEX(VECTOR->type.type)) { \ 39 printf("%.2f%+.2fi\n", creal(VECTOR->data.TYPE[i]), cimag(VECTOR->data.TYPE[i])); \ 40 } else if(PS_IS_PSELEMTYPE_INT(VECTOR->type.type)) { \ 41 printf("%d\n", (int)VECTOR->data.TYPE[i]); \ 42 } else { \ 43 printf("%.2f\n", (double)VECTOR->data.TYPE[i]); \ 44 } \ 45 } \ 46 46 printf("\n"); 47 47 … … 49 49 #define PRINT_MATRIX(IMAGE,TYPE) \ 50 50 for(int i=IMAGE->numRows-1; i>-1; i--) { \ 51 for(int j=0; j<IMAGE->numCols; j++) { \52 if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) { \53 printf("%.2f%+.2fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j])); \54 } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) { \55 printf("%d ", (int)IMAGE->data.TYPE[i][j]); \56 } else { \57 printf("%.2f ", (double)IMAGE->data.TYPE[i][j]); \58 } \59 } \60 printf("\n"); \61 } \51 for(int j=0; j<IMAGE->numCols; j++) { \ 52 if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) { \ 53 printf("%.2f%+.2fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j])); \ 54 } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) { \ 55 printf("%d ", (int)IMAGE->data.TYPE[i][j]); \ 56 } else { \ 57 printf("%.2f ", (double)IMAGE->data.TYPE[i][j]); \ 58 } \ 59 } \ 60 printf("\n"); \ 61 } \ 62 62 printf("\n"); 63 63 … … 66 66 psVector *NAME = (psVector*)psVectorAlloc(SIZE, PS_TYPE_##TYPE); \ 67 67 for(int i=0; i<SIZE; i++) { \ 68 NAME->data.TYPE[i] = VALUE; \69 } \68 NAME->data.TYPE[i] = VALUE; \ 69 } \ 70 70 NAME->n = SIZE; 71 71 … … 74 74 psImage *NAME = (psImage*)psImageAlloc(NCOLS,NROWS,PS_TYPE_##TYPE); \ 75 75 for(int i=0; i<NAME->numRows; i++) { \ 76 for(int j=0; j<NAME->numCols; j++) { \77 NAME->data.TYPE[i][j] = VALUE; \78 } \79 }80 81 76 for(int j=0; j<NAME->numCols; j++) { \ 77 NAME->data.TYPE[i][j] = VALUE; \ 78 } \ 79 } 80 81 82 82 #define CHECK_MEMORY \ 83 83 psMemCheckLeaks(0, NULL, stdout); \ 84 84 int nBad = psMemCheckCorruption(0); \ 85 85 if(nBad) { \ 86 printf("ERROR: Found %d bad memory blocks\n", nBad); \87 }88 89 86 printf("ERROR: Found %d bad memory blocks\n", nBad); \ 87 } 88 89 90 90 int main( int argc, char* argv[] ) 91 91 { … … 109 109 printFooter(stdout, "psMatrixVectorArithmetic", "Test matrix psUnaryOp", true); \ 110 110 } 111 111 112 112 testBinaryOpM( abs, S32, -10, 0, 3, 2 ); 113 113 testBinaryOpM( abs, F32, -10.0, 0.0, 3, 2 ); … … 178 178 testBinaryOpM( datan, F64, 1.0, 0.0, 3, 2 ); 179 179 testBinaryOpM( datan, C32, 1.0 + 1.0i, 0.0 + 0.0i, 3, 2 ); 180 181 180 181 182 182 // Test vector unary operations 183 183 #define testBinaryOpV(OP,TYPE,VALUE1,VALUE2,SIZE) \ … … 198 198 printFooter(stdout, "psMatrixVectorArithmetic", "Test vector psUnaryOp", true); \ 199 199 } 200 200 201 201 testBinaryOpV( abs, S32, -10, 0, 3 ); 202 202 testBinaryOpV( abs, F32, -10.0, 0.0, 3 ); … … 267 267 testBinaryOpV( datan, F64, 1.0, 0.0, 3 ); 268 268 testBinaryOpV( datan, C32, 1.0 + 1.0i, 0.0 + 0.0i, 3 ); 269 269 270 270 return 0; 271 271 }
Note:
See TracChangeset
for help on using the changeset viewer.
