Changeset 4385 for trunk/psLib/src/dataManip/psMatrix.c
- Timestamp:
- Jun 24, 2005, 2:51:28 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psMatrix.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMatrix.c
r4321 r4385 21 21 * @author Robert DeSonia, MHPCC 22 22 * 23 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $24 * @date $Date: 2005-06-2 0 22:42:29$23 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2005-06-25 00:51:28 $ 25 25 * 26 26 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 298 298 } 299 299 300 psImage* psMatrixInvert(psImage* out Image, const psImage* inImage, float *det)300 psImage* psMatrixInvert(psImage* out, const psImage* in, float *determinant) 301 301 { 302 302 psS32 signum = 0; … … 307 307 gsl_permutation *perm = NULL; 308 308 309 #define INVERT_CLEANUP { psFree(out Image); return NULL; }310 // Error checks 311 PS_ASSERT_GENERAL_PTR_NON_NULL(det , INVERT_CLEANUP);312 PS_ASSERT_GENERAL_IMAGE_NON_NULL(in Image, INVERT_CLEANUP);313 PS_CHECK_POINTERS(in Image, outImage, INVERT_CLEANUP);314 PS_CHECK_DIMEN_AND_TYPE(in Image, PS_DIMEN_IMAGE, INVERT_CLEANUP);315 PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(in Image, INVERT_CLEANUP);316 317 out Image = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);318 319 PS_CHECK_SQUARE(in Image, INVERT_CLEANUP);320 PS_CHECK_SQUARE(out Image, INVERT_CLEANUP);309 #define INVERT_CLEANUP { psFree(out); return NULL; } 310 // Error checks 311 PS_ASSERT_GENERAL_PTR_NON_NULL(determinant, INVERT_CLEANUP); 312 PS_ASSERT_GENERAL_IMAGE_NON_NULL(in, INVERT_CLEANUP); 313 PS_CHECK_POINTERS(in, out, INVERT_CLEANUP); 314 PS_CHECK_DIMEN_AND_TYPE(in, PS_DIMEN_IMAGE, INVERT_CLEANUP); 315 PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(in, INVERT_CLEANUP); 316 317 out = psImageRecycle(out, in->numCols, in->numRows, in->type.type); 318 319 PS_CHECK_SQUARE(in, INVERT_CLEANUP); 320 PS_CHECK_SQUARE(out, INVERT_CLEANUP); 321 321 322 322 // Initialize data 323 numRows = in Image->numRows;324 numCols = in Image->numCols;323 numRows = in->numRows; 324 numCols = in->numCols; 325 325 326 326 // Initialize GSL data … … 328 328 lu = gsl_matrix_alloc(numRows, numCols); 329 329 inv = gsl_matrix_alloc(numRows, numCols); 330 psImageToGslMatrix(lu, in Image);330 psImageToGslMatrix(lu, in); 331 331 332 332 // Invert data and calculate determinant 333 333 gsl_linalg_LU_decomp(lu, perm, &signum); 334 334 gsl_linalg_LU_invert(lu, perm, inv); 335 *det = (float)gsl_linalg_LU_det(lu, signum);335 *determinant = (float)gsl_linalg_LU_det(lu, signum); 336 336 337 337 // Copy GSL matrix data to psImage data 338 gslMatrixToPsImage(out Image, inv);338 gslMatrixToPsImage(out, inv); 339 339 340 340 // Free GSL structs … … 343 343 gsl_matrix_free(inv); 344 344 345 return out Image;345 return out; 346 346 } 347 347
Note:
See TracChangeset
for help on using the changeset viewer.
