![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsSparseMatrix_Matrix3x3.hpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (12/22/2009) 00009 UPDATE (04/10/2010) 00010 ******************************************************************************/ 00011 #ifndef TAPs_SPARSE_MATRIX_MATRIX3X3_HPP 00012 #define TAPs_SPARSE_MATRIX_MATRIX3X3_HPP 00013 00014 #include "TAPsSparseVector_Matrix3x3.hpp" 00015 #include "TAPsSparseSymmetricMatrix_Matrix3x3.hpp" 00016 00017 BEGIN_NAMESPACE_TAPs 00018 //============================================================================= 00019 template <typename T> 00020 class SparseMatrix_Matrix3x3 { 00021 //============================================================================= 00022 public: 00023 // Member Functions ------------------------------------------------------- 00025 friend std::ostream & operator<< ( std::ostream &output, SparseMatrix_Matrix3x3<T> const &obj ) 00026 { 00027 output << obj.StrInfo(); 00028 return output; 00029 } 00030 //------------------------------------------------------------------------- 00032 SparseMatrix_Matrix3x3 ( unsigned int numOfRows = 0 ); 00034 SparseMatrix_Matrix3x3 ( SparseMatrix_Matrix3x3<T> const &orig ); 00036 virtual ~SparseMatrix_Matrix3x3 (); 00037 //------------------------------------------------------------------------- 00039 virtual std::string StrInfo () const; 00040 //------------------------------------------------------------------------- 00042 inline SparseMatrix_Matrix3x3<T> & operator= ( SparseMatrix_Matrix3x3<T> const &orig ); 00043 00045 //inline SparseMatrix_Matrix3x3<T> & operator= ( SparseSymmetricMatrix_Matrix3x3<T> &orig ); 00046 00050 inline void SetTo ( SparseMatrix_Matrix3x3<T> const &orig ); 00051 00052 //------------------------------------------------------------------------- 00053 00054 //------------------------------------------------------------------------- 00055 // Operations 00056 00058 inline void MulWith ( 00059 std::vector< Vector3<T> > const &I, 00060 std::vector< Vector3<T> > &O 00061 ) const; 00062 00066 inline void MulWith_wSkippedRows ( 00067 std::vector< Vector3<T> > const &I, 00068 std::vector< Vector3<T> > &O, 00069 std::vector< bool > const &rowsFixStatus, 00070 T diagval 00071 ) const; 00072 00076 inline void MulWith_wSkippedCols ( 00077 std::vector< Vector3<T> > const &I, 00078 std::vector< Vector3<T> > &O, 00079 std::vector< bool > const &colsFixStatus, 00080 T diagval 00081 ) const; 00082 00086 inline void MulWith_wSkippedRowsCols ( 00087 std::vector< Vector3<T> > const &I, 00088 std::vector< Vector3<T> > &O, 00089 std::vector< bool > const &rowscolsFixStatus, 00090 T diagval 00091 ) const; 00092 00095 inline void ChangeNumOfRows ( unsigned int numOfRows ); 00096 00097 //=============================================================== 00098 // Diagonalizes WITH A SPECIFIED VALUE 00099 //--------------------------------------------------------------- 00101 inline void DiagonalizeRow ( unsigned int row, T diagonalValue ); 00102 00106 inline void DiagonalizeRows ( 00107 std::vector< bool > const & rows, 00108 T diagonalValue 00109 ); 00110 00112 inline void DiagonalizeRows ( 00113 std::vector< unsigned int > const & rows, 00114 T diagonalValue 00115 ); 00116 00118 inline void DiagonalizeCol ( unsigned int col, T diagonalValue ); 00119 00123 inline void DiagonalizeCols ( 00124 std::vector< bool > const & cols, 00125 T diagonalValue 00126 ); 00127 00129 inline void DiagonalizeRowCol ( unsigned int rowcol, T diagonalValue ); 00130 00135 inline void DiagonalizeRowsCols ( 00136 std::vector< bool > const & rowscols, 00137 T diagonalValue 00138 ); 00139 //--------------------------------------------------------------- 00140 00141 //=============================================================== 00142 // Diagonalizes 00143 //--------------------------------------------------------------- 00145 inline void DiagonalizeRow ( unsigned int row ); 00146 00150 inline void DiagonalizeRows ( 00151 std::vector< bool > const & rows 00152 ); 00153 00155 inline void DiagonalizeRows ( 00156 std::vector< unsigned int > const & rows 00157 ); 00158 00160 inline void DiagonalizeCol ( unsigned int col ); 00161 00165 inline void DiagonalizeCols ( 00166 std::vector< bool > const & cols 00167 ); 00168 00170 inline void DiagonalizeRowCol ( unsigned int rowcol ); 00171 00176 inline void DiagonalizeRowsCols ( 00177 std::vector< bool > const & rowscols 00178 ); 00179 //--------------------------------------------------------------- 00180 00182 inline unsigned int GetNumOfRows () const { return m_Rows.size(); } 00183 00185 void SetDirectAccessors (); 00186 00189 inline SparseVector_Matrix3x3<T> * const DirectAccess ( unsigned int row ); 00190 00194 static void MPCGSolver ( 00195 SparseMatrix_Matrix3x3<T> const &A, 00196 std::vector< Vector3<T> > const &x, 00197 std::vector< Vector3<T> > const &b, 00198 std::vector< Vector3<T> > &x_out, 00199 std::vector< Vector3<T> > const &ft, 00200 std::vector< Vector3<T> > const &P, 00201 int iterationLimit = 100, 00202 T errorThreshold = 1E-3 00203 ); 00204 00205 //------------------------------------------------------------------------- 00206 00207 // Data Members ----------------------------------------------------------- 00208 //============================================================================= 00209 protected: 00210 // Member Functions ------------------------------------------------------- 00211 00212 // Data Members ----------------------------------------------------------- 00213 std::list< SparseVector_Matrix3x3<T> > m_Rows; 00214 std::vector< SparseVector_Matrix3x3<T>* > m_DirectAccessors; 00215 //============================================================================= 00216 private: 00217 // Member Functions ------------------------------------------------------- 00218 00219 static inline std::string DEBUG_ToStr ( std::vector< Vector3<T> > const &V ) 00220 { 00221 std::stringstream ss; 00222 ss << "Dense Vector of size "<<V.size()<<":\n"; 00223 for ( unsigned int i = 0; i < V.size(); ++i ) { 00224 ss << V[i] << "\n"; 00225 } 00226 return ss.str(); 00227 } 00228 00229 static inline std::string DEBUG_ToStr ( std::vector< Matrix3x3<T> > const &V ) 00230 { 00231 std::stringstream ss; 00232 ss << "Dense Vector of size "<<V.size()<<":\n"; 00233 for ( unsigned int i = 0; i < V.size(); ++i ) { 00234 ss << V[i] << "\n"; 00235 } 00236 return ss.str(); 00237 } 00238 // Data Members ----------------------------------------------------------- 00239 //============================================================================= 00240 00241 #if defined(__gl_h_) || defined(__GL_H__) 00242 public: 00243 //virtual void Draw (); 00244 #endif 00245 00246 //============================================================================= 00247 }; // END CLASS SparseMatrix_Matrix3x3 00248 //============================================================================= 00249 END_NAMESPACE_TAPs 00250 //----------------------------------------------------------------------------- 00252 #include "TAPsSparseMatrix_Matrix3x3.cpp" 00253 00255 // Include definition if TAPs_USE_EXPORT is not defined 00256 //#if !defined( TAPs_USE_EXPORT ) 00257 // #include "TAPsSparseMatrix_Matrix3x3.cpp" 00258 //#endif 00259 //----------------------------------------------------------------------------- 00260 #endif 00261 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00262 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----