Changeset 4589 for trunk/psLib/src/math
- Timestamp:
- Jul 20, 2005, 3:40:10 PM (21 years ago)
- Location:
- trunk/psLib/src/math
- Files:
-
- 2 edited
-
psMatrix.c (modified) (15 diffs)
-
psMatrix.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMatrix.c
r4540 r4589 21 21 * @author Robert DeSonia, MHPCC 22 22 * 23 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $24 * @date $Date: 2005-07- 12 19:12:01$23 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2005-07-21 01:40:10 $ 25 25 * 26 26 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 95 95 96 96 /** Static function to copy psF32 or psF64 vector data to a GSL vector */ 97 static void psVectorToGslVector(gsl_vector *outGslVector, const psVector *inVector) 97 static void psVectorToGslVector(gsl_vector *outGslVector, 98 const psVector *inVector) 98 99 { 99 100 psU32 i = 0; … … 112 113 113 114 /** Static function to copy GSL vector data to a psF32 or psF64 vector */ 114 static void gslVectorToPsVector(psVector *outVector, gsl_vector *inGslVector) 115 static void gslVectorToPsVector(psVector *outVector, 116 gsl_vector *inGslVector) 115 117 { 116 118 psU32 i = 0; … … 129 131 130 132 /** Static function to copy psF32 or psF64 image data to a GSL matrix */ 131 static void psImageToGslMatrix(gsl_matrix *outGslMatrix, const psImage *inImage) 133 static void psImageToGslMatrix(gsl_matrix *outGslMatrix, 134 const psImage *inImage) 132 135 { 133 136 psU32 i = 0; … … 155 158 156 159 /** Static function to copy GSL matrix data to a psF32 or psF64 image */ 157 static void gslMatrixToPsImage(psImage *outImage, gsl_matrix *inGslMatrix) 160 static void gslMatrixToPsImage(psImage *outImage, 161 gsl_matrix *inGslMatrix) 158 162 { 159 163 psU32 i = 0; … … 185 189 /*****************************************************************************/ 186 190 187 psImage* psMatrixLUD(psImage* out, psVector** perm, psImage* in) 191 psImage* psMatrixLUD(psImage* out, 192 psVector** perm, 193 const psImage* in) 188 194 { 189 195 psS32 signum = 0; … … 243 249 } 244 250 245 psVector* psMatrixLUSolve(psVector* out, const psImage* LU, const psVector* RHS, 251 psVector* psMatrixLUSolve(psVector* out, 252 const psImage* LU, 253 const psVector* RHS, 246 254 const psVector* perm) 247 255 { … … 298 306 } 299 307 300 psImage* psMatrixInvert(psImage* out, const psImage* in, float *determinant) 308 psImage* psMatrixInvert(psImage* out, 309 const psImage* in, 310 float *determinant) 301 311 { 302 312 psS32 signum = 0; … … 346 356 } 347 357 348 float *psMatrixDeterminant(const psImage* in)358 float psMatrixDeterminant(const psImage* in) 349 359 { 350 360 psS32 signum = 0; 351 361 psS32 numRows = 0; 352 362 psS32 numCols = 0; 353 psF32 *det = NULL;363 psF32 det = 0; 354 364 gsl_matrix *lu = NULL; 355 365 gsl_permutation *perm = NULL; 356 366 357 #define DETERMINANT_EXIT { return NULL; }367 #define DETERMINANT_EXIT { return 0; } 358 368 // Error checks 359 369 PS_ASSERT_GENERAL_IMAGE_NON_NULL(in, DETERMINANT_EXIT); … … 372 382 373 383 // Calculate determinant 374 det = (psF32*)psAlloc(sizeof(psF32));384 // det = psAlloc(sizeof(psF32)); 375 385 gsl_linalg_LU_decomp(lu, perm, &signum); 376 *det = (psF32)gsl_linalg_LU_det(lu, signum);386 det = (psF32)gsl_linalg_LU_det(lu, signum); 377 387 378 388 // Free GSL structs … … 383 393 } 384 394 385 psImage* psMatrixMultiply(psImage* out, psImage* in1, psImage* in2) 395 psImage* psMatrixMultiply(psImage* out, 396 const psImage* in1, 397 const psImage* in2) 386 398 { 387 399 gsl_matrix *m1 = NULL; … … 434 446 } 435 447 436 psImage* psMatrixTranspose(psImage* out, const psImage* in) 448 psImage* psMatrixTranspose(psImage* out, 449 const psImage* in) 437 450 { 438 451 psU32 i = 0; … … 480 493 } 481 494 482 psImage* psMatrixEigenvectors(psImage* out, psImage* in) 495 psImage* psMatrixEigenvectors(psImage* out, 496 const psImage* in) 483 497 { 484 498 psS32 numRows = 0; … … 529 543 } 530 544 531 psVector* psMatrixToVector(psVector* outVector, const psImage* inImage) 545 psVector* psMatrixToVector(psVector* outVector, 546 const psImage* inImage) 532 547 { 533 548 psS32 size = 0; … … 593 608 } 594 609 595 psImage* psVectorToMatrix(psImage* outImage, const psVector* inVector) 610 psImage* psVectorToMatrix(psImage* outImage, 611 const psVector* inVector) 596 612 { 597 613 psS32 size = 0; -
trunk/psLib/src/math/psMatrix.h
r4388 r4589 21 21 * @author Ross Harman, MHPCC 22 22 * 23 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $24 * @date $Date: 2005-0 6-25 01:15:01$23 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2005-07-21 01:40:10 $ 25 25 * 26 26 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 45 45 psImage* out, ///< Image to return, or NULL. 46 46 psVector** perm, ///< Output permutation vector used by psMatrixLUSolve. 47 psImage* in///< Image to decompose.47 const psImage* in ///< Image to decompose. 48 48 ); 49 49 … … 87 87 * @return float: Determinant from psImage. 88 88 */ 89 float *psMatrixDeterminant(89 float psMatrixDeterminant( 90 90 const psImage* in ///< Image used to calculate determinant. 91 91 ); … … 102 102 psImage* psMatrixMultiply( 103 103 psImage* out, ///< Matrix to return, or NULL. 104 psImage* in1,///< First input image.105 psImage* in2///< Second input image.104 const psImage* in1, ///< First input image. 105 const psImage* in2 ///< Second input image. 106 106 ); 107 107 … … 116 116 */ 117 117 psImage* psMatrixTranspose( 118 psImage* out, ///< Image to return, or NULL119 const psImage* in Image///< Image to transpose118 psImage* out, ///< Image to return, or NULL 119 const psImage* in ///< Image to transpose 120 120 ); 121 121 … … 130 130 psImage* psMatrixEigenvectors( 131 131 psImage* out, ///< Eigenvectors to return, or NULL. 132 psImage* in///< Input image.132 const psImage* in ///< Input image. 133 133 ); 134 134
Note:
See TracChangeset
for help on using the changeset viewer.
