Changeset 760
- Timestamp:
- May 24, 2004, 11:10:03 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
dataManip/psMatrix.h (modified) (1 diff)
-
math/psMatrix.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMatrix.h
r597 r760 1 #if !defined(PS_MATRIX_H) 2 #define PS_MATRIX_H 3 4 /** \file psMatrix.h 5 * \brief matrix math operators 6 * \ingroup MathGroup 1 /** @file psMatrix.h 2 * 3 * @brief Provides functions for linear algebra operations on psImages and psVectors. 4 * 5 * Functions are provided to: 6 * Transpose a psImage 7 * Compute LUD 8 * Solve LUD 9 * Matrix inversion 10 * Calculate determinant 11 * Matrix addition 12 * Matrix subtraction 13 * Matrix multiplication 14 * Calculate Eigenvectors 15 * Convert matrix to vector 16 * Convert vector to matrix 17 * 18 * These functions treat psImages as if they were matrices, therefore there is no psMatrix. These functions 19 * operate only with psF32 and psF64 data types. 20 * 21 * @author Ross Harman, MHPCC 22 * 23 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2004-05-24 21:10:03 $ 25 * 26 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 7 27 */ 8 28 9 /** Functions **************************************************************/ 10 /** \addtogroup MathGroup Math Utilities 11 * \{ 29 #ifndef PSMATRIX_H 30 #define PSMATRIX_H 31 32 /******************************************************************************/ 33 /* DEFINE STATEMENTS */ 34 /******************************************************************************/ 35 36 // None 37 38 /******************************************************************************/ 39 /* TYPE DEFINITIONS */ 40 /******************************************************************************/ 41 42 // None 43 44 /*****************************************************************************/ 45 /* FUNCTION PROTOTYPES */ 46 /*****************************************************************************/ 47 48 /** LU Decomposition of psImage matrix. 49 * 50 * Performs a LU decomposition on a psImage matrix and returns the LU matrix. If the user specifies NULL as the 51 * outImage argument, then the decomposition is done in-place and inImage will hold the inverted image. The input 52 * image must be square. This function operates only with psF32 and psF64 data types. 53 * 54 * @return psImage*: Pointer to LU decomposed psImage. 12 55 */ 56 psImage *psMatrixLUD( 57 psImage *outImage, ///< Image to return, or NULL. 58 psVector *outPerm, ///< Output permutation vector used by psMatrixLUSolve. 59 psImage *inImage ///< Image to decompose. 60 ); 13 61 62 /** LU Solution of psImage matrix. 63 * 64 * Solves for and returns the psVector, {x} in the equation [A]{x} = {b}. If the user specifies NULL as the 65 * outVector argument, then the solution for {x} is done in-place and inVector will hold the modified values. 66 * The input image must be square. This function operates only with psF32 and psF64 data types. 67 * 68 * @return psVector*: Pointer to psVector solution of matrix equation. 69 */ 70 psVector *psMatrixLUSolve( 71 psVector *outVector, ///< Vector to return, or NULL. 72 const psImage *luImage, ///< LU-decomposed matrix. 73 const psVector *inVector, ///< Vector right-hand-side of equation. 74 const psVector *inPerm ///< Permutation vector resulting from psMatrixLUD function. 75 ); 14 76 15 /* Linear Algebra */ 77 /** Invert psImage matrix. 78 * 79 * Inverts a psImage matrix and returns the determinant as an option through the argument list. If the user 80 * specifies NULL as the outImage argument, then the inversion is done in-place and inImage will hold the 81 * inverted image. The input image must be square. This function operates only with psF32 and psF64 data types. 82 * 83 * @return psImage*: Pointer to inverted psImage. 84 */ 85 psImage *psMatrixInvert( 86 psImage *outImage, ///< Image to return, or NULL for in-place substitution. 87 const psImage *inImage, ///< Image to be inverted 88 float *restrict det ///< Determinant to return, or NULL 89 ); 16 90 17 /** Invert matrix. Not using restrict, to allow inversion to be done in-place */ 18 psImage * 19 psMatrixInvert(psImage *out, ///< Matrix to return, or NULL 20 const psImage *myMatrix, ///< Matrix to be inverted 21 float *restrict determinant ///< Determinant to return, or NULL 22 ); 91 /** Calculate psImage matrix determinant. 92 * 93 * Calculates the determinant of a psImage matrix and returns the floating point determinant. The input 94 * image must be square. This function operates only with psF32 and psF64 data types. 95 * 96 * @return float: Determinant from psImage. 97 */ 98 float psMatrixDeterminant( 99 const psImage *restrict inMatrix ///< Image used to calculate determinant. 100 ); 23 101 24 /** Matrix determinant */ 25 float 26 psMatrixDeterminant(const psImage *restrict myMatrix ///< Matrix to get determinant for 27 ); 102 /** Performs basic psImage matrix operations. 103 * 104 * Performs psImage matrix operations for: addition, subtraction, multiplication. For addition, each element 105 * of the input image is added to the corresponding element of the output matrix. Subtraction works in a 106 * similar manner. For multiplication, the function performs a classical matrix multiplication involving row 107 * and column operations. For matrix multiplication, the number of columns must match the number of rows for 108 * inImage1 and inImage2, respectively. Matrix division is not defined for this function. If the user 109 * specifies NULL as the outImage argument, then a new psImage will be created and returned. This function 110 * operates only with psF32 and psF64 data types. 111 * 112 * @return psImage*: Pointer to resulting psImage. 113 */ 114 psImage *psMatrixOp( 115 psImage *outImage, ///< Matrix to return, or NULL. 116 psImage *inImage1, ///< First input image. 117 const char op, ///< Operation to perform: "+", "-", "*". 118 psImage *inImage2 ///< Second input image. 119 ); 28 120 29 /** Matrix operation: addition, subtraction, multiplication */ 30 psImage * 31 psMatrixOp(psImage *out, ///< Matrix to return, or NULL 32 const psImage *matrix1, ///< Matrix 1 33 const char *op, ///< Operation to perform: "+", "-", "*" 34 const psImage *matrix2 ///< Matrix 2 35 ); 121 /** Transpose matrix. 122 * 123 * Performs psImage matrix transpose by substituting existing rows for columns. The input image must be 124 * square. If the user specifies NULL as the outImage argument, then a new psImage will be created 125 * and returned. This function operates only with psF32 and psF64 data types. 126 * 127 * @return psImage*: Pointer to transposed psImage. 128 */ 129 psImage *psMatrixTranspose( 130 psImage *outImage, ///< Image to return, or NULL 131 const psImage *inImage ///< Image to transpose 132 ); 36 133 37 /** Transpose Matrix */ 38 psImage * 39 psMatrixTranspose(psImage *out, ///< Matrix to return, or NULL 40 const psImage *myMatrix ///< Matrix to transpose 41 ); 134 /** Calculate matrix eigenvectors. 135 * 136 * Calculates the eigenvectors for a matrix. The input image must be square. If the user specifies NULL as 137 * the outImage argument, then a new psImage will be created and returned. This function operates only with 138 * psF32 and psF64 data types. 139 * 140 * @return psImage*: Pointer to matrix of Eigenvectors. 141 */ 142 psImage *psMatrixEigenvectors( 143 psImage *outImage, ///< Eigenvectors to return, or NULL. 144 psImage *inImage ///< Input image. 145 ); 42 146 43 /** LU Decomposition of a matrix */ 44 psImage * 45 psMatrixLUD(psImage *out, ///< Matrix to return, or NULL 46 psImage *myMatrix ///< Matrix to decompose 47 ); 147 /** Convert matrix to vector. 148 * 149 * Converts a 1-d matrix into a vector. If the user specifies NULL as the outVector argument, then a new psImage will be created 150 * and returned. This function operates only with psF32 and psF64 data types. 151 * 152 * @return psVector*: Pointer to psVector. 153 */ 154 psVector *psMatrixToVector( 155 psVector *outVector, ///< Vector to return, or NULL. 156 psImage *inImage ///< Image to convert. 157 ); 48 158 49 /** LU Solution. Solves for and returns x in the equation Ax = b */ 50 psVector * 51 psMatrixLUSolve(psVector *out, ///< Vector to return, or NULL 52 const psImage *luMatrix, ///< LU-decomposed matrix 53 const psVector *rhsVector ///< right-hand-side of the equation 54 ); 55 56 /***********************************************************************************************************/ 57 58 /* Conversions */ 59 60 /** Convert matrix to vector. Intended for a 1-d matrix. */ 61 psVector * 62 psMatrixToVector(psVector *out, ///< Vector to return, or NULL 63 psImage *myMatrix ///< Matrix to convert 64 ); 65 66 /** Convert vector to matrix. */ 67 psImage * 68 psVectorToMatrix(psImage *out, ///< Matrix to return, or NULL 69 psVector *myVector ///< Vector to convert 70 ); 71 72 /* \} */ // End of MathGroup Functions 159 /** Convert vector to matrix. 160 * 161 * Converts a vector to a 1-d psImage matrix into a vector. If the user specifies NULL as the outImage 162 * argument, then a new psImage will be created and returned. This function operates only with psF32 and 163 * psF64 data types. 164 * 165 * @return psVector*: Pointer to psIamge. 166 */ 167 psImage *psVectorToMatrix( 168 psImage *outImage, ///< Matrix to return, or NULL. 169 psVector *inVector ///< Vector to convert. 170 ); 73 171 74 172 #endif -
trunk/psLib/src/math/psMatrix.h
r597 r760 1 #if !defined(PS_MATRIX_H) 2 #define PS_MATRIX_H 3 4 /** \file psMatrix.h 5 * \brief matrix math operators 6 * \ingroup MathGroup 1 /** @file psMatrix.h 2 * 3 * @brief Provides functions for linear algebra operations on psImages and psVectors. 4 * 5 * Functions are provided to: 6 * Transpose a psImage 7 * Compute LUD 8 * Solve LUD 9 * Matrix inversion 10 * Calculate determinant 11 * Matrix addition 12 * Matrix subtraction 13 * Matrix multiplication 14 * Calculate Eigenvectors 15 * Convert matrix to vector 16 * Convert vector to matrix 17 * 18 * These functions treat psImages as if they were matrices, therefore there is no psMatrix. These functions 19 * operate only with psF32 and psF64 data types. 20 * 21 * @author Ross Harman, MHPCC 22 * 23 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2004-05-24 21:10:03 $ 25 * 26 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 7 27 */ 8 28 9 /** Functions **************************************************************/ 10 /** \addtogroup MathGroup Math Utilities 11 * \{ 29 #ifndef PSMATRIX_H 30 #define PSMATRIX_H 31 32 /******************************************************************************/ 33 /* DEFINE STATEMENTS */ 34 /******************************************************************************/ 35 36 // None 37 38 /******************************************************************************/ 39 /* TYPE DEFINITIONS */ 40 /******************************************************************************/ 41 42 // None 43 44 /*****************************************************************************/ 45 /* FUNCTION PROTOTYPES */ 46 /*****************************************************************************/ 47 48 /** LU Decomposition of psImage matrix. 49 * 50 * Performs a LU decomposition on a psImage matrix and returns the LU matrix. If the user specifies NULL as the 51 * outImage argument, then the decomposition is done in-place and inImage will hold the inverted image. The input 52 * image must be square. This function operates only with psF32 and psF64 data types. 53 * 54 * @return psImage*: Pointer to LU decomposed psImage. 12 55 */ 56 psImage *psMatrixLUD( 57 psImage *outImage, ///< Image to return, or NULL. 58 psVector *outPerm, ///< Output permutation vector used by psMatrixLUSolve. 59 psImage *inImage ///< Image to decompose. 60 ); 13 61 62 /** LU Solution of psImage matrix. 63 * 64 * Solves for and returns the psVector, {x} in the equation [A]{x} = {b}. If the user specifies NULL as the 65 * outVector argument, then the solution for {x} is done in-place and inVector will hold the modified values. 66 * The input image must be square. This function operates only with psF32 and psF64 data types. 67 * 68 * @return psVector*: Pointer to psVector solution of matrix equation. 69 */ 70 psVector *psMatrixLUSolve( 71 psVector *outVector, ///< Vector to return, or NULL. 72 const psImage *luImage, ///< LU-decomposed matrix. 73 const psVector *inVector, ///< Vector right-hand-side of equation. 74 const psVector *inPerm ///< Permutation vector resulting from psMatrixLUD function. 75 ); 14 76 15 /* Linear Algebra */ 77 /** Invert psImage matrix. 78 * 79 * Inverts a psImage matrix and returns the determinant as an option through the argument list. If the user 80 * specifies NULL as the outImage argument, then the inversion is done in-place and inImage will hold the 81 * inverted image. The input image must be square. This function operates only with psF32 and psF64 data types. 82 * 83 * @return psImage*: Pointer to inverted psImage. 84 */ 85 psImage *psMatrixInvert( 86 psImage *outImage, ///< Image to return, or NULL for in-place substitution. 87 const psImage *inImage, ///< Image to be inverted 88 float *restrict det ///< Determinant to return, or NULL 89 ); 16 90 17 /** Invert matrix. Not using restrict, to allow inversion to be done in-place */ 18 psImage * 19 psMatrixInvert(psImage *out, ///< Matrix to return, or NULL 20 const psImage *myMatrix, ///< Matrix to be inverted 21 float *restrict determinant ///< Determinant to return, or NULL 22 ); 91 /** Calculate psImage matrix determinant. 92 * 93 * Calculates the determinant of a psImage matrix and returns the floating point determinant. The input 94 * image must be square. This function operates only with psF32 and psF64 data types. 95 * 96 * @return float: Determinant from psImage. 97 */ 98 float psMatrixDeterminant( 99 const psImage *restrict inMatrix ///< Image used to calculate determinant. 100 ); 23 101 24 /** Matrix determinant */ 25 float 26 psMatrixDeterminant(const psImage *restrict myMatrix ///< Matrix to get determinant for 27 ); 102 /** Performs basic psImage matrix operations. 103 * 104 * Performs psImage matrix operations for: addition, subtraction, multiplication. For addition, each element 105 * of the input image is added to the corresponding element of the output matrix. Subtraction works in a 106 * similar manner. For multiplication, the function performs a classical matrix multiplication involving row 107 * and column operations. For matrix multiplication, the number of columns must match the number of rows for 108 * inImage1 and inImage2, respectively. Matrix division is not defined for this function. If the user 109 * specifies NULL as the outImage argument, then a new psImage will be created and returned. This function 110 * operates only with psF32 and psF64 data types. 111 * 112 * @return psImage*: Pointer to resulting psImage. 113 */ 114 psImage *psMatrixOp( 115 psImage *outImage, ///< Matrix to return, or NULL. 116 psImage *inImage1, ///< First input image. 117 const char op, ///< Operation to perform: "+", "-", "*". 118 psImage *inImage2 ///< Second input image. 119 ); 28 120 29 /** Matrix operation: addition, subtraction, multiplication */ 30 psImage * 31 psMatrixOp(psImage *out, ///< Matrix to return, or NULL 32 const psImage *matrix1, ///< Matrix 1 33 const char *op, ///< Operation to perform: "+", "-", "*" 34 const psImage *matrix2 ///< Matrix 2 35 ); 121 /** Transpose matrix. 122 * 123 * Performs psImage matrix transpose by substituting existing rows for columns. The input image must be 124 * square. If the user specifies NULL as the outImage argument, then a new psImage will be created 125 * and returned. This function operates only with psF32 and psF64 data types. 126 * 127 * @return psImage*: Pointer to transposed psImage. 128 */ 129 psImage *psMatrixTranspose( 130 psImage *outImage, ///< Image to return, or NULL 131 const psImage *inImage ///< Image to transpose 132 ); 36 133 37 /** Transpose Matrix */ 38 psImage * 39 psMatrixTranspose(psImage *out, ///< Matrix to return, or NULL 40 const psImage *myMatrix ///< Matrix to transpose 41 ); 134 /** Calculate matrix eigenvectors. 135 * 136 * Calculates the eigenvectors for a matrix. The input image must be square. If the user specifies NULL as 137 * the outImage argument, then a new psImage will be created and returned. This function operates only with 138 * psF32 and psF64 data types. 139 * 140 * @return psImage*: Pointer to matrix of Eigenvectors. 141 */ 142 psImage *psMatrixEigenvectors( 143 psImage *outImage, ///< Eigenvectors to return, or NULL. 144 psImage *inImage ///< Input image. 145 ); 42 146 43 /** LU Decomposition of a matrix */ 44 psImage * 45 psMatrixLUD(psImage *out, ///< Matrix to return, or NULL 46 psImage *myMatrix ///< Matrix to decompose 47 ); 147 /** Convert matrix to vector. 148 * 149 * Converts a 1-d matrix into a vector. If the user specifies NULL as the outVector argument, then a new psImage will be created 150 * and returned. This function operates only with psF32 and psF64 data types. 151 * 152 * @return psVector*: Pointer to psVector. 153 */ 154 psVector *psMatrixToVector( 155 psVector *outVector, ///< Vector to return, or NULL. 156 psImage *inImage ///< Image to convert. 157 ); 48 158 49 /** LU Solution. Solves for and returns x in the equation Ax = b */ 50 psVector * 51 psMatrixLUSolve(psVector *out, ///< Vector to return, or NULL 52 const psImage *luMatrix, ///< LU-decomposed matrix 53 const psVector *rhsVector ///< right-hand-side of the equation 54 ); 55 56 /***********************************************************************************************************/ 57 58 /* Conversions */ 59 60 /** Convert matrix to vector. Intended for a 1-d matrix. */ 61 psVector * 62 psMatrixToVector(psVector *out, ///< Vector to return, or NULL 63 psImage *myMatrix ///< Matrix to convert 64 ); 65 66 /** Convert vector to matrix. */ 67 psImage * 68 psVectorToMatrix(psImage *out, ///< Matrix to return, or NULL 69 psVector *myVector ///< Vector to convert 70 ); 71 72 /* \} */ // End of MathGroup Functions 159 /** Convert vector to matrix. 160 * 161 * Converts a vector to a 1-d psImage matrix into a vector. If the user specifies NULL as the outImage 162 * argument, then a new psImage will be created and returned. This function operates only with psF32 and 163 * psF64 data types. 164 * 165 * @return psVector*: Pointer to psIamge. 166 */ 167 psImage *psVectorToMatrix( 168 psImage *outImage, ///< Matrix to return, or NULL. 169 psVector *inVector ///< Vector to convert. 170 ); 73 171 74 172 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
