00001 /** @file psMatrix.h 00002 * 00003 * @brief Provides functions for linear algebra operations on psImages and psVectors. 00004 * 00005 * Functions are provided to: 00006 * Transpose a psImage 00007 * Compute LUD 00008 * Solve LUD 00009 * Matrix inversion 00010 * Calculate determinant 00011 * Matrix multiplication 00012 * Calculate Eigenvectors 00013 * Convert matrix to vector 00014 * Convert vector to matrix 00015 * 00016 * These functions treat psImages as if they were matrices, therefore there is no psMatrix. These functions 00017 * operate only with the psF64 data type. 00018 * 00019 * @ingroup Matrix 00020 * 00021 * @author Ross Harman, MHPCC 00022 * 00023 * @version $Revision: 1.1.1.1 $ $Name: $ 00024 * @date $Date: 2005/09/14 20:42:48 $ 00025 * 00026 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00027 */ 00028 00029 #ifndef PSMATRIX_H 00030 #define PSMATRIX_H 00031 00032 /// @addtogroup Matrix 00033 /// @{ 00034 00035 /** LU Decomposition of psImage matrix. 00036 * 00037 * Performs a LU decomposition on a psImage matrix and returns the LU matrix. If the user specifies NULL for 00038 * the outImage or outPerm arguments, then they will be automatically created. The input image must 00039 * be square. This function operates only with the psF64 data type. Input and output arguments should not be 00040 * the same. GSL indexes the top row as the zero row, not the bottom. 00041 * 00042 * @return psImage* : Pointer to LU decomposed psImage. 00043 */ 00044 psImage* psMatrixLUD( 00045 psImage* out, ///< Image to return, or NULL. 00046 psVector** perm, ///< Output permutation vector used by psMatrixLUSolve. 00047 const psImage* in ///< Image to decompose. 00048 ); 00049 00050 /** LU Solution of psImage matrix. 00051 * 00052 * Solves for and returns the psVector, {x} in the equation [A]{x} = {b}. If the user specifies NULL as the 00053 * outVector argument, then it will automatically be created. The input image must be square. This function 00054 * operates only with the psF64 data type. Input and output arguments should not be the same. GSL indexes 00055 * the top row as the zero row, not the bottom. 00056 * 00057 * @return psVector* : Pointer to psVector solution of matrix equation. 00058 */ 00059 psVector* psMatrixLUSolve( 00060 psVector* out, ///< Vector to return, or NULL. 00061 const psImage* LU, ///< LU-decomposed matrix. 00062 const psVector* RHS, ///< Vector right-hand-side of equation. 00063 const psVector* perm ///< Permutation vector resulting from psMatrixLUD function. 00064 ); 00065 00066 /** Invert psImage matrix. 00067 * 00068 * Inverts a psImage matrix and returns the determinant as an option through the argument list. If the user 00069 * specifies NULL as the outImage argument, then it will automatically be created. The input image must be 00070 * square. This function operates only with the psF64 data type. Input and output arguments should not be 00071 * the same. GSL indexes the top row as the zero row, not the bottom. 00072 * 00073 * @return psImage* : Pointer to inverted psImage. 00074 */ 00075 psImage* psMatrixInvert( 00076 psImage* out, ///< Image to return, or NULL for in-place substitution. 00077 const psImage* in, ///< Image to be inverted 00078 float *determinant ///< Determinant to return, or NULL 00079 ); 00080 00081 /** Calculate psImage matrix determinant. 00082 * 00083 * Calculates the determinant of a psImage matrix and returns the single precision floating point result. The 00084 * input image must be square. This function operates only with the psF64 data type. GSL indexes the top row 00085 * as the zero row, not the bottom. 00086 * 00087 * @return float: Determinant from psImage. 00088 */ 00089 float psMatrixDeterminant( 00090 const psImage* in ///< Image used to calculate determinant. 00091 ); 00092 00093 /** Performs psImage matrix multiplication. 00094 * 00095 * Performs a classical matrix multiplication involving row and column operations. Input images must be square 00096 * and the same size. If the user specifies NULL as the outImage argument, then it will automatically be 00097 * created. This function operates only with the psF64 data type. GSL indexes the top row as the 00098 * zero row, not the bottom. 00099 * 00100 * @return psImage* : Pointer to resulting psImage. 00101 */ 00102 psImage* psMatrixMultiply( 00103 psImage* out, ///< Matrix to return, or NULL. 00104 const psImage* in1, ///< First input image. 00105 const psImage* in2 ///< Second input image. 00106 ); 00107 00108 /** Transpose matrix. 00109 * 00110 * Performs psImage matrix transpose by substituting existing rows for columns. The input image must be 00111 * square. If the user specifies NULL as the outImage argument, then it will automaticallty be created. 00112 * This function operates only with the psF64 data type. GSL indexes the top row as the zero 00113 * row, not the bottom. 00114 * 00115 * @return psImage* : Pointer to transposed psImage. 00116 */ 00117 psImage* psMatrixTranspose( 00118 psImage* out, ///< Image to return, or NULL 00119 const psImage* in ///< Image to transpose 00120 ); 00121 00122 /** Calculate matrix eigenvectors. 00123 * 00124 * Calculates the eigenvectors for a matrix. The input image must be symmetric and square. If the user 00125 * specifies NULL as the outImage argument, then it will automatically be created. This function operates 00126 * only with the psF64 data type. GSL indexes the top row as the zero row, not the bottom. 00127 * 00128 * @return psImage* : Pointer to matrix of Eigenvectors. 00129 */ 00130 psImage* psMatrixEigenvectors( 00131 psImage* out, ///< Eigenvectors to return, or NULL. 00132 const psImage* in ///< Input image. 00133 ); 00134 00135 /** Convert matrix to vector. 00136 * 00137 * Converts a 1-d psImage matrix into a vector. If the user specifies NULL as the outVector argument, then it 00138 * will automatically be created based on the input image (PS_DIMEN_VECTOR for an input image with 1 col or 00139 * PS_DIMENT_TRANSV for an input image with 1 row). Either the number of rows or the number of colums of the 00140 * input matrix must be 1. This function operates only with the psF64 data type. 00141 * 00142 * @return psVector* : Pointer to psVector. 00143 */ 00144 psVector* psMatrixToVector( 00145 psVector* outVector, ///< Vector to return, or NULL. 00146 const psImage* inImage ///< Image to convert. 00147 ); 00148 00149 /** Convert vector to matrix. 00150 * 00151 * Converts a vector into a psImage matrix. If the dimensionality of the vector is PS_DIMEN_VECTOR, then the 00152 * resulting psImage is a 1d column. If the dimensionality of the vector is PS_DIMEN_TRANSV, then the 00153 * resulting psImage is a 1d row. If the user specifies NULL as the outImage argument, then it will 00154 * automatically be created. This function operates only with the psF64 data type. 00155 * 00156 * @return psVector* : Pointer to psIamge. 00157 */ 00158 psImage* psVectorToMatrix( 00159 psImage* outImage, ///< Matrix to return, or NULL. 00160 const psVector* inVector ///< Vector to convert. 00161 ); 00162 00163 /// @} 00164 00165 #endif // #ifndef PSMATRIX_H
1.4.2