Changeset 824
- Timestamp:
- Jun 1, 2004, 12:42:57 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 10 edited
-
dataManip/psFFT.c (modified) (2 diffs)
-
dataManip/psMatrix.c (modified) (15 diffs)
-
dataManip/psVectorFFT.c (modified) (2 diffs)
-
fft/psVectorFFT.c (modified) (2 diffs)
-
image/psImage.c (modified) (8 diffs)
-
image/psImage.h (modified) (2 diffs)
-
image/psImageIO.c (modified) (3 diffs)
-
math/psMatrix.c (modified) (15 diffs)
-
mathtypes/psImage.c (modified) (8 diffs)
-
mathtypes/psImage.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFFT.c
r823 r824 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06-01 22: 27:16$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-01 22:42:57 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 "A zero image was returned."); 229 229 out = psImageRecycle(out,numCols,numRows,type); 230 memset(out->data. v[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows);230 memset(out->data.V[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows); 231 231 return out; 232 232 } -
trunk/psLib/src/dataManip/psMatrix.c
r807 r824 20 20 * @author Ross Harman, MHPCC 21 21 * 22 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $23 * @date $Date: 2004-0 5-28 20:52:41$22 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2004-06-01 22:42:57 $ 24 24 * 25 25 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 70 70 /** Preprocessor macro to generate error a NULL image */ 71 #define PS_CHECK_NULL_VECTOR(NAME, RETURN) \72 if (NAME == NULL || NAME->vec.v == NULL) { \73 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \74 return RETURN; \71 #define PS_CHECK_NULL_VECTOR(NAME, RETURN) \ 72 if (NAME == NULL || NAME->vec.v == NULL) { \ 73 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 74 return RETURN; \ 75 75 } 76 76 77 77 /** Preprocessor macro to create vector based on another */ 78 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \79 if(NAME == NULL) { \80 NAME = psVectorAlloc(PS_TYPE, SIZE); \78 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \ 79 if(NAME == NULL) { \ 80 NAME = psVectorAlloc(PS_TYPE, SIZE); \ 81 81 } 82 82 83 83 /** Preprocessor macro to generate error for zero length vector */ 84 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \85 if (NAME->n < 1) { \86 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \87 return RETURN; \84 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \ 85 if (NAME->n < 1) { \ 86 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \ 87 return RETURN; \ 88 88 } 89 89 90 90 /** Preprocessor macro to generate error a NULL image */ 91 #define PS_CHECK_NULL_IMAGE(NAME, RETURN) \92 if (NAME == NULL || NAME->data. v == NULL) {\93 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \94 return RETURN; \91 #define PS_CHECK_NULL_IMAGE(NAME, RETURN) \ 92 if (NAME == NULL || NAME->data.V == NULL) { \ 93 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 94 return RETURN; \ 95 95 } 96 96 97 97 /** Preprocessor macro to create image based on another */ 98 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \99 if(NAME == NULL) { \100 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \98 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \ 99 if(NAME == NULL) { \ 100 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \ 101 101 } 102 102 103 103 /** Preprocessor macro to generate error for zero length rows or columns */ 104 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \105 if (NAME->numCols < 1 || NAME->numRows < 1) { \106 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \107 NAME->numCols, NAME->numRows); \108 return RETURN; \104 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \ 105 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 106 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 107 NAME->numCols, NAME->numRows); \ 108 return RETURN; \ 109 109 } 110 110 111 111 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */ 112 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \113 if (NAME->type.dimen != PS_DIMEN) { \114 psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN);\115 return RETURN; \116 } else if(NAME->type.type != PS_TYPE_F64) { \117 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \118 return RETURN; \112 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \ 113 if (NAME->type.dimen != PS_DIMEN) { \ 114 psError(__func__,"Invalid operation: %s incorrectdimensionality %d.", #NAME, PS_DIMEN); \ 115 return RETURN; \ 116 } else if(NAME->type.type != PS_TYPE_F64) { \ 117 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \ 118 return RETURN; \ 119 119 } 120 120 121 121 /** Preprocessor macro to check that input is not equal to output */ 122 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \123 if (NAME1 == NAME2) { \124 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \125 return RETURN; \122 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \ 123 if (NAME1 == NAME2) { \ 124 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 125 return RETURN; \ 126 126 } 127 127 128 128 /** Preprocessor macro to check that an image is square */ 129 #define PS_CHECK_SQUARE(NAME, RETURN) \130 if (NAME->numCols != NAME->numRows) { \131 psError(__func__,"Invalid operation: %s not square array.", #NAME); \132 return RETURN; \129 #define PS_CHECK_SQUARE(NAME, RETURN) \ 130 if (NAME->numCols != NAME->numRows) { \ 131 psError(__func__,"Invalid operation: %s not square array.", #NAME); \ 132 return RETURN; \ 133 133 } 134 134 135 135 /** Preprocessor macro to initalize a GSL matrix. */ 136 #define PS_GSL_MATRIX_INITIALIZE(LHS_NAME, RHS_NAME) \137 LHS_NAME.size1 = numRows; \138 LHS_NAME.size2 = numCols; \139 LHS_NAME.tda = numCols; \136 #define PS_GSL_MATRIX_INITIALIZE(LHS_NAME, RHS_NAME) \ 137 LHS_NAME.size1 = numRows; \ 138 LHS_NAME.size2 = numCols; \ 139 LHS_NAME.tda = numCols; \ 140 140 LHS_NAME.data = RHS_NAME; 141 141 … … 174 174 outPerm->n = numCols; 175 175 perm.data = outPerm->vec.v; 176 PS_GSL_MATRIX_INITIALIZE(lu, outImage->data. v[0]);176 PS_GSL_MATRIX_INITIALIZE(lu, outImage->data.V[0]); 177 177 178 178 // Non-square matrices not allowed … … 181 181 182 182 // Copy psImage input data into GSL matrix data to keep input data pristine 183 memcpy(lu.data, inImage->data. v[0], arraySize);183 memcpy(lu.data, inImage->data.V[0], arraySize); 184 184 185 185 // Calculate LU decomposition … … 189 189 } 190 190 191 psVector *psMatrixLUSolve(psVector *outVector, const psImage *inImage, const psVector *inVector, const psVector *inPerm) 191 psVector *psMatrixLUSolve(psVector *outVector, const psImage *inImage, const psVector *inVector, const 192 psVector *inPerm) 192 193 { 193 194 int arraySize = 0; … … 220 221 221 222 // Initialize GSL data 222 PS_GSL_MATRIX_INITIALIZE(lu, inImage->data. v[0]);223 PS_GSL_MATRIX_INITIALIZE(lu, inImage->data.V[0]); 223 224 224 225 outVector->n = numCols; … … 270 271 271 272 // Initialize GSL data 272 PS_GSL_MATRIX_INITIALIZE(inv, outImage->data. v[0]);273 PS_GSL_MATRIX_INITIALIZE(inv, outImage->data.V[0]); 273 274 274 275 // Non-square matrices not allowed … … 277 278 278 279 // Copy psImage input data into GSL matrix data to keep input data pristine 279 memcpy(lu->data, inImage->data. v[0], arraySize);280 memcpy(lu->data, inImage->data.V[0], arraySize); 280 281 281 282 // Invert data and calculate determinant … … 319 320 320 321 // Copy psImage input data into GSL matrix data to keep input data pristine 321 memcpy(lu->data, inImage->data. v[0], arraySize);322 memcpy(lu->data, inImage->data.V[0], arraySize); 322 323 323 324 // Calculate determinant … … 360 361 361 362 // Initialize GSL data 362 PS_GSL_MATRIX_INITIALIZE(m1, inImage1->data. v[0]);363 PS_GSL_MATRIX_INITIALIZE(m2, inImage2->data. v[0]);364 PS_GSL_MATRIX_INITIALIZE(m3, outImage->data. v[0]);363 PS_GSL_MATRIX_INITIALIZE(m1, inImage1->data.V[0]); 364 PS_GSL_MATRIX_INITIALIZE(m2, inImage2->data.V[0]); 365 PS_GSL_MATRIX_INITIALIZE(m3, outImage->data.V[0]); 365 366 366 367 // Non-square matrices not allowed … … 396 397 397 398 // Initialize GSL data 398 PS_GSL_MATRIX_INITIALIZE(trans, outImage->data. v[0]);399 PS_GSL_MATRIX_INITIALIZE(trans, outImage->data.V[0]); 399 400 400 401 // Non-square matrices not allowed … … 403 404 404 405 // Copy psImage input data into psImage output data to keep input data pristine 405 memcpy(outImage->data. v[0], inImage->data.v[0], arraySize);406 memcpy(outImage->data.V[0], inImage->data.V[0], arraySize); 406 407 407 408 // Transpose data … … 434 435 435 436 // Initialize GSL data 436 PS_GSL_MATRIX_INITIALIZE(in, inImage->data. v[0]);437 PS_GSL_MATRIX_INITIALIZE(out, outImage->data. v[0]);437 PS_GSL_MATRIX_INITIALIZE(in, inImage->data.V[0]); 438 PS_GSL_MATRIX_INITIALIZE(out, outImage->data.V[0]); 438 439 439 440 // Allocate GSL structs … … 482 483 483 484 colSize = PSELEMTYPE_SIZEOF(inImage->type.type)*inImage->numRows; 484 memcpy(outVector->vec.v, inImage->data. v[0], colSize);485 memcpy(outVector->vec.v, inImage->data.V[0], colSize); 485 486 486 487 return outVector; … … 509 510 510 511 colSize = PSELEMTYPE_SIZEOF(outImage->type.type)*outImage->numRows; 511 memcpy(outImage->data. v[0], inVector->vec.v, colSize);512 memcpy(outImage->data.V[0], inVector->vec.v, colSize); 512 513 513 514 return outImage; -
trunk/psLib/src/dataManip/psVectorFFT.c
r823 r824 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06-01 22: 27:16$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-01 22:42:57 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 "A zero image was returned."); 229 229 out = psImageRecycle(out,numCols,numRows,type); 230 memset(out->data. v[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows);230 memset(out->data.V[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows); 231 231 return out; 232 232 } -
trunk/psLib/src/fft/psVectorFFT.c
r823 r824 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-06-01 22: 27:16$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-06-01 22:42:57 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 "A zero image was returned."); 229 229 out = psImageRecycle(out,numCols,numRows,type); 230 memset(out->data. v[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows);230 memset(out->data.V[0],0,PSELEMTYPE_SIZEOF(type)*numCols*numRows); 231 231 return out; 232 232 } -
trunk/psLib/src/image/psImage.c
r821 r824 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 1:30:47 $11 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 22:42:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 psImage *image = (psImage *)psAlloc(sizeof(psImage)); 49 49 50 image->data. v= psAlloc(sizeof(void*)*numRows);51 52 image->data. v[0] = psAlloc(area*elementSize);50 image->data.V = psAlloc(sizeof(void*)*numRows); 51 52 image->data.V[0] = psAlloc(area*elementSize); 53 53 54 54 for(int i = 1; i < numRows; i++) { 55 image->data. v[i] = (void*)((int8_t*)image->data.v[i-1]+rowSize);55 image->data.V[i] = (void*)((int8_t*)image->data.V[i-1]+rowSize); 56 56 } 57 57 … … 91 91 psImageFreeChildren(image); 92 92 93 psFree(image->data. v[0]);94 psFree(image->data. v);95 image->data. v= NULL;93 psFree(image->data.V[0]); 94 psFree(image->data.V); 95 image->data.V = NULL; 96 96 97 97 psFree(image); … … 138 138 139 139 // Resize the image buffer 140 old->data. v[0] = psRealloc(old->data.v[0],numCols * numRows * elementSize);141 old->data. v = (void**) psRealloc(old->data.v,numRows * sizeof(void*));140 old->data.V[0] = psRealloc(old->data.V[0],numCols * numRows * elementSize); 141 old->data.V = (void**) psRealloc(old->data.V,numRows * sizeof(void*)); 142 142 143 143 // recreate the row pointers 144 144 for(int i = 1; i < numRows; i++) { 145 old->data. v[i] = (void*)((int8_t*)old->data.v[i-1]+rowSize);145 old->data.V[i] = (void*)((int8_t*)old->data.V[i-1]+rowSize); 146 146 } 147 147 … … 161 161 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row 162 162 163 if (image == NULL || image->data. v== NULL) {163 if (image == NULL || image->data.V == NULL) { 164 164 psError(__func__,"Can not subset image because input image or its pixel buffer is NULL."); 165 165 return NULL; … … 211 211 212 212 for (int row = 0; row < numRows; row++) { 213 memcpy(out->data. v[row],image->data.U8[row0+row] + inputColOffset,213 memcpy(out->data.V[row],image->data.U8[row0+row] + inputColOffset, 214 214 outputRowSize); 215 215 } … … 250 250 int numCols; 251 251 252 if (input == NULL || input->data. v== NULL) {252 if (input == NULL || input->data.V == NULL) { 253 253 psError(__func__,"Can not copy image because input image or its pixel buffer is NULL."); 254 254 return NULL; … … 280 280 // cover the trival case of copy of the same datatype. 281 281 if (type == inDatatype) { 282 memcpy(output->data. v[0],input->data.v[0],elementSize*numRows*numCols);282 memcpy(output->data.V[0],input->data.V[0],elementSize*numRows*numCols); 283 283 return output; 284 284 } -
trunk/psLib/src/image/psImage.h
r820 r824 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 0:00:08$11 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 22:42:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 psC64 **C64; ///< double-precision complex data. 60 60 psPTR **PTR; ///< void pointers 61 void ** v; ///< pointer to data61 void **V; ///< pointer to data 62 62 } data; ///< Union for data types. 63 63 const struct psImage *parent; ///< Parent, if a subimage. -
trunk/psLib/src/image/psImageIO.c
r817 r824 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-0 5-29 01:42:44$9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-06-01 22:42:57 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 135 135 psImageRecycle(output,numCols,numRows,PS_TYPE_U8); 136 136 (void)fits_read_subset(fptr, TBYTE, firstPixel, lastPixel, increment, 137 NULL, output->data. v, &anynull, &status);137 NULL, output->data.V, &anynull, &status); 138 138 break; 139 139 case SHORT_IMG: 140 140 psImageRecycle(output,numCols,numRows,PS_TYPE_S16); 141 141 (void)fits_read_subset(fptr, TSHORT, firstPixel, lastPixel, increment, 142 NULL, output->data. v, &anynull, &status);142 NULL, output->data.V, &anynull, &status); 143 143 break; 144 144 case LONG_IMG: 145 145 psImageRecycle(output,numCols,numRows,PS_TYPE_S32); 146 146 (void)fits_read_subset(fptr, TINT, firstPixel, lastPixel, increment, 147 NULL, output->data. v, &anynull, &status);147 NULL, output->data.V, &anynull, &status); 148 148 break; 149 149 case FLOAT_IMG: 150 150 psImageRecycle(output,numCols,numRows,PS_TYPE_F32); 151 151 (void)fits_read_subset(fptr, TFLOAT, firstPixel, lastPixel, increment, 152 NULL, output->data. v, &anynull, &status);152 NULL, output->data.V, &anynull, &status); 153 153 break; 154 154 case DOUBLE_IMG: 155 155 psImageRecycle(output,numCols,numRows,PS_TYPE_F64); 156 156 (void)fits_read_subset(fptr, TDOUBLE, firstPixel, lastPixel, increment, 157 NULL, output->data. v, &anynull, &status);157 NULL, output->data.V, &anynull, &status); 158 158 break; 159 159 default: … … 323 323 324 324 325 if ( fits_write_subset(fptr, datatype, firstPixel, lastPixel, input->data. v, &status) != 0) {325 if ( fits_write_subset(fptr, datatype, firstPixel, lastPixel, input->data.V, &status) != 0) { 326 326 (void)fits_get_errstatus(status, fitsErr); 327 327 status = 0; -
trunk/psLib/src/math/psMatrix.c
r807 r824 20 20 * @author Ross Harman, MHPCC 21 21 * 22 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $23 * @date $Date: 2004-0 5-28 20:52:41$22 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2004-06-01 22:42:57 $ 24 24 * 25 25 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 70 70 /** Preprocessor macro to generate error a NULL image */ 71 #define PS_CHECK_NULL_VECTOR(NAME, RETURN) \72 if (NAME == NULL || NAME->vec.v == NULL) { \73 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \74 return RETURN; \71 #define PS_CHECK_NULL_VECTOR(NAME, RETURN) \ 72 if (NAME == NULL || NAME->vec.v == NULL) { \ 73 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 74 return RETURN; \ 75 75 } 76 76 77 77 /** Preprocessor macro to create vector based on another */ 78 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \79 if(NAME == NULL) { \80 NAME = psVectorAlloc(PS_TYPE, SIZE); \78 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \ 79 if(NAME == NULL) { \ 80 NAME = psVectorAlloc(PS_TYPE, SIZE); \ 81 81 } 82 82 83 83 /** Preprocessor macro to generate error for zero length vector */ 84 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \85 if (NAME->n < 1) { \86 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \87 return RETURN; \84 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \ 85 if (NAME->n < 1) { \ 86 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \ 87 return RETURN; \ 88 88 } 89 89 90 90 /** Preprocessor macro to generate error a NULL image */ 91 #define PS_CHECK_NULL_IMAGE(NAME, RETURN) \92 if (NAME == NULL || NAME->data. v == NULL) {\93 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \94 return RETURN; \91 #define PS_CHECK_NULL_IMAGE(NAME, RETURN) \ 92 if (NAME == NULL || NAME->data.V == NULL) { \ 93 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 94 return RETURN; \ 95 95 } 96 96 97 97 /** Preprocessor macro to create image based on another */ 98 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \99 if(NAME == NULL) { \100 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \98 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \ 99 if(NAME == NULL) { \ 100 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \ 101 101 } 102 102 103 103 /** Preprocessor macro to generate error for zero length rows or columns */ 104 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \105 if (NAME->numCols < 1 || NAME->numRows < 1) { \106 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \107 NAME->numCols, NAME->numRows); \108 return RETURN; \104 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \ 105 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 106 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 107 NAME->numCols, NAME->numRows); \ 108 return RETURN; \ 109 109 } 110 110 111 111 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */ 112 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \113 if (NAME->type.dimen != PS_DIMEN) { \114 psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN);\115 return RETURN; \116 } else if(NAME->type.type != PS_TYPE_F64) { \117 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \118 return RETURN; \112 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \ 113 if (NAME->type.dimen != PS_DIMEN) { \ 114 psError(__func__,"Invalid operation: %s incorrectdimensionality %d.", #NAME, PS_DIMEN); \ 115 return RETURN; \ 116 } else if(NAME->type.type != PS_TYPE_F64) { \ 117 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \ 118 return RETURN; \ 119 119 } 120 120 121 121 /** Preprocessor macro to check that input is not equal to output */ 122 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \123 if (NAME1 == NAME2) { \124 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \125 return RETURN; \122 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \ 123 if (NAME1 == NAME2) { \ 124 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 125 return RETURN; \ 126 126 } 127 127 128 128 /** Preprocessor macro to check that an image is square */ 129 #define PS_CHECK_SQUARE(NAME, RETURN) \130 if (NAME->numCols != NAME->numRows) { \131 psError(__func__,"Invalid operation: %s not square array.", #NAME); \132 return RETURN; \129 #define PS_CHECK_SQUARE(NAME, RETURN) \ 130 if (NAME->numCols != NAME->numRows) { \ 131 psError(__func__,"Invalid operation: %s not square array.", #NAME); \ 132 return RETURN; \ 133 133 } 134 134 135 135 /** Preprocessor macro to initalize a GSL matrix. */ 136 #define PS_GSL_MATRIX_INITIALIZE(LHS_NAME, RHS_NAME) \137 LHS_NAME.size1 = numRows; \138 LHS_NAME.size2 = numCols; \139 LHS_NAME.tda = numCols; \136 #define PS_GSL_MATRIX_INITIALIZE(LHS_NAME, RHS_NAME) \ 137 LHS_NAME.size1 = numRows; \ 138 LHS_NAME.size2 = numCols; \ 139 LHS_NAME.tda = numCols; \ 140 140 LHS_NAME.data = RHS_NAME; 141 141 … … 174 174 outPerm->n = numCols; 175 175 perm.data = outPerm->vec.v; 176 PS_GSL_MATRIX_INITIALIZE(lu, outImage->data. v[0]);176 PS_GSL_MATRIX_INITIALIZE(lu, outImage->data.V[0]); 177 177 178 178 // Non-square matrices not allowed … … 181 181 182 182 // Copy psImage input data into GSL matrix data to keep input data pristine 183 memcpy(lu.data, inImage->data. v[0], arraySize);183 memcpy(lu.data, inImage->data.V[0], arraySize); 184 184 185 185 // Calculate LU decomposition … … 189 189 } 190 190 191 psVector *psMatrixLUSolve(psVector *outVector, const psImage *inImage, const psVector *inVector, const psVector *inPerm) 191 psVector *psMatrixLUSolve(psVector *outVector, const psImage *inImage, const psVector *inVector, const 192 psVector *inPerm) 192 193 { 193 194 int arraySize = 0; … … 220 221 221 222 // Initialize GSL data 222 PS_GSL_MATRIX_INITIALIZE(lu, inImage->data. v[0]);223 PS_GSL_MATRIX_INITIALIZE(lu, inImage->data.V[0]); 223 224 224 225 outVector->n = numCols; … … 270 271 271 272 // Initialize GSL data 272 PS_GSL_MATRIX_INITIALIZE(inv, outImage->data. v[0]);273 PS_GSL_MATRIX_INITIALIZE(inv, outImage->data.V[0]); 273 274 274 275 // Non-square matrices not allowed … … 277 278 278 279 // Copy psImage input data into GSL matrix data to keep input data pristine 279 memcpy(lu->data, inImage->data. v[0], arraySize);280 memcpy(lu->data, inImage->data.V[0], arraySize); 280 281 281 282 // Invert data and calculate determinant … … 319 320 320 321 // Copy psImage input data into GSL matrix data to keep input data pristine 321 memcpy(lu->data, inImage->data. v[0], arraySize);322 memcpy(lu->data, inImage->data.V[0], arraySize); 322 323 323 324 // Calculate determinant … … 360 361 361 362 // Initialize GSL data 362 PS_GSL_MATRIX_INITIALIZE(m1, inImage1->data. v[0]);363 PS_GSL_MATRIX_INITIALIZE(m2, inImage2->data. v[0]);364 PS_GSL_MATRIX_INITIALIZE(m3, outImage->data. v[0]);363 PS_GSL_MATRIX_INITIALIZE(m1, inImage1->data.V[0]); 364 PS_GSL_MATRIX_INITIALIZE(m2, inImage2->data.V[0]); 365 PS_GSL_MATRIX_INITIALIZE(m3, outImage->data.V[0]); 365 366 366 367 // Non-square matrices not allowed … … 396 397 397 398 // Initialize GSL data 398 PS_GSL_MATRIX_INITIALIZE(trans, outImage->data. v[0]);399 PS_GSL_MATRIX_INITIALIZE(trans, outImage->data.V[0]); 399 400 400 401 // Non-square matrices not allowed … … 403 404 404 405 // Copy psImage input data into psImage output data to keep input data pristine 405 memcpy(outImage->data. v[0], inImage->data.v[0], arraySize);406 memcpy(outImage->data.V[0], inImage->data.V[0], arraySize); 406 407 407 408 // Transpose data … … 434 435 435 436 // Initialize GSL data 436 PS_GSL_MATRIX_INITIALIZE(in, inImage->data. v[0]);437 PS_GSL_MATRIX_INITIALIZE(out, outImage->data. v[0]);437 PS_GSL_MATRIX_INITIALIZE(in, inImage->data.V[0]); 438 PS_GSL_MATRIX_INITIALIZE(out, outImage->data.V[0]); 438 439 439 440 // Allocate GSL structs … … 482 483 483 484 colSize = PSELEMTYPE_SIZEOF(inImage->type.type)*inImage->numRows; 484 memcpy(outVector->vec.v, inImage->data. v[0], colSize);485 memcpy(outVector->vec.v, inImage->data.V[0], colSize); 485 486 486 487 return outVector; … … 509 510 510 511 colSize = PSELEMTYPE_SIZEOF(outImage->type.type)*outImage->numRows; 511 memcpy(outImage->data. v[0], inVector->vec.v, colSize);512 memcpy(outImage->data.V[0], inVector->vec.v, colSize); 512 513 513 514 return outImage; -
trunk/psLib/src/mathtypes/psImage.c
r821 r824 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 1:30:47 $11 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 22:42:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 psImage *image = (psImage *)psAlloc(sizeof(psImage)); 49 49 50 image->data. v= psAlloc(sizeof(void*)*numRows);51 52 image->data. v[0] = psAlloc(area*elementSize);50 image->data.V = psAlloc(sizeof(void*)*numRows); 51 52 image->data.V[0] = psAlloc(area*elementSize); 53 53 54 54 for(int i = 1; i < numRows; i++) { 55 image->data. v[i] = (void*)((int8_t*)image->data.v[i-1]+rowSize);55 image->data.V[i] = (void*)((int8_t*)image->data.V[i-1]+rowSize); 56 56 } 57 57 … … 91 91 psImageFreeChildren(image); 92 92 93 psFree(image->data. v[0]);94 psFree(image->data. v);95 image->data. v= NULL;93 psFree(image->data.V[0]); 94 psFree(image->data.V); 95 image->data.V = NULL; 96 96 97 97 psFree(image); … … 138 138 139 139 // Resize the image buffer 140 old->data. v[0] = psRealloc(old->data.v[0],numCols * numRows * elementSize);141 old->data. v = (void**) psRealloc(old->data.v,numRows * sizeof(void*));140 old->data.V[0] = psRealloc(old->data.V[0],numCols * numRows * elementSize); 141 old->data.V = (void**) psRealloc(old->data.V,numRows * sizeof(void*)); 142 142 143 143 // recreate the row pointers 144 144 for(int i = 1; i < numRows; i++) { 145 old->data. v[i] = (void*)((int8_t*)old->data.v[i-1]+rowSize);145 old->data.V[i] = (void*)((int8_t*)old->data.V[i-1]+rowSize); 146 146 } 147 147 … … 161 161 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row 162 162 163 if (image == NULL || image->data. v== NULL) {163 if (image == NULL || image->data.V == NULL) { 164 164 psError(__func__,"Can not subset image because input image or its pixel buffer is NULL."); 165 165 return NULL; … … 211 211 212 212 for (int row = 0; row < numRows; row++) { 213 memcpy(out->data. v[row],image->data.U8[row0+row] + inputColOffset,213 memcpy(out->data.V[row],image->data.U8[row0+row] + inputColOffset, 214 214 outputRowSize); 215 215 } … … 250 250 int numCols; 251 251 252 if (input == NULL || input->data. v== NULL) {252 if (input == NULL || input->data.V == NULL) { 253 253 psError(__func__,"Can not copy image because input image or its pixel buffer is NULL."); 254 254 return NULL; … … 280 280 // cover the trival case of copy of the same datatype. 281 281 if (type == inDatatype) { 282 memcpy(output->data. v[0],input->data.v[0],elementSize*numRows*numCols);282 memcpy(output->data.V[0],input->data.V[0],elementSize*numRows*numCols); 283 283 return output; 284 284 } -
trunk/psLib/src/mathtypes/psImage.h
r820 r824 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-01 2 0:00:08$11 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-01 22:42:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 psC64 **C64; ///< double-precision complex data. 60 60 psPTR **PTR; ///< void pointers 61 void ** v; ///< pointer to data61 void **V; ///< pointer to data 62 62 } data; ///< Union for data types. 63 63 const struct psImage *parent; ///< Parent, if a subimage.
Note:
See TracChangeset
for help on using the changeset viewer.
