itkFEMLinearSystemWrapperDenseVNL.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkFEMLinearSystemWrapperDenseVNL_h
00019 #define __itkFEMLinearSystemWrapperDenseVNL_h
00020 #include "itkFEMLinearSystemWrapper.h"
00021 #include "vnl/vnl_matrix.h"
00022 #include "vnl/vnl_vector.h"
00023 #include "vnl/algo/vnl_svd.h"
00024 #include <vector>
00025
00026
00027 namespace itk {
00028 namespace fem {
00029
00030
00037 class LinearSystemWrapperDenseVNL : public LinearSystemWrapper
00038 {
00039 public:
00040
00041
00042 typedef LinearSystemWrapper::Float Float;
00043
00044
00045 typedef LinearSystemWrapper SuperClass;
00046
00047
00048 typedef vnl_matrix<Float> MatrixRepresentation;
00049
00050
00051 typedef std::vector< MatrixRepresentation* > MatrixHolder;
00052
00053
00054 LinearSystemWrapperDenseVNL() : LinearSystemWrapper(), m_Matrices(0), m_Vectors(0), m_Solutions(0) {}
00055 virtual ~LinearSystemWrapperDenseVNL();
00056
00057
00058 virtual void InitializeMatrix(unsigned int matrixIndex);
00059 virtual bool IsMatrixInitialized(unsigned int matrixIndex);
00060 virtual void DestroyMatrix(unsigned int matrixIndex);
00061 virtual void InitializeVector(unsigned int vectorIndex);
00062 virtual bool IsVectorInitialized(unsigned int vectorIndex);
00063 virtual void DestroyVector(unsigned int vectorIndex);
00064 virtual void InitializeSolution(unsigned int solutionIndex);
00065 virtual bool IsSolutionInitialized(unsigned int solutionIndex);
00066 virtual void DestroySolution(unsigned int solutionIndex);
00067 virtual void SetMaximumNonZeroValuesInMatrix(unsigned int, unsigned int) {}
00068
00069
00070
00071 virtual Float GetMatrixValue(unsigned int i, unsigned int j, unsigned int matrixIndex) const { return (*((*m_Matrices)[matrixIndex]))(i,j); }
00072 virtual void SetMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex) { (*((*m_Matrices)[matrixIndex]))(i,j) = value; }
00073 virtual void AddMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex) { (*((*m_Matrices)[matrixIndex]))(i,j) += value; }
00074 virtual Float GetVectorValue(unsigned int i, unsigned int vectorIndex) const { return (* ( (*m_Vectors)[vectorIndex] ) )[i]; }
00075 virtual void SetVectorValue(unsigned int i, Float value, unsigned int vectorIndex) { (*((*m_Vectors)[vectorIndex]))(i) = value; }
00076 virtual void AddVectorValue(unsigned int i, Float value, unsigned int vectorIndex) { (*((*m_Vectors)[vectorIndex]))(i) += value; }
00077 virtual Float GetSolutionValue(unsigned int i, unsigned int solutionIndex) const;
00078 virtual void SetSolutionValue(unsigned int i, Float value, unsigned int solutionIndex) { (*((*m_Solutions)[solutionIndex]))(i) = value; }
00079 virtual void AddSolutionValue(unsigned int i, Float value, unsigned int solutionIndex) { (*((*m_Solutions)[solutionIndex]))(i) += value; }
00080 virtual void Solve(void);
00081
00082
00083 virtual void ScaleMatrix(Float scale, unsigned int matrixIndex);
00084 virtual void ScaleVector(Float scale, unsigned int vectorIndex);
00085 virtual void ScaleSolution(Float scale, unsigned int solutionIndex);
00086 virtual void SwapMatrices(unsigned int matrixIndex1, unsigned int matrixIndex2);
00087 virtual void SwapVectors(unsigned int vectorIndex1, unsigned int vectorIndex2);
00088 virtual void SwapSolutions(unsigned int solutionIndex1, unsigned int solutionIndex2);
00089 virtual void CopySolution2Vector(unsigned solutionIndex, unsigned int vectorIndex);
00090 virtual void CopyVector2Solution(unsigned int vectorIndex, unsigned int solutionIndex);
00091 virtual void MultiplyMatrixMatrix(unsigned int resultMatrixIndex, unsigned int leftMatrixIndex, unsigned int rightMatrixIndex);
00092 virtual void MultiplyMatrixVector(unsigned int resultVectorIndex, unsigned int matrixIndex, unsigned int vectorIndex);
00093
00094 private:
00095
00097
00098 MatrixHolder *m_Matrices;
00099
00101 std::vector< vnl_vector<Float>* > *m_Vectors;
00102
00104 std::vector< vnl_vector<Float>* > *m_Solutions;
00105
00106 };
00107
00108 }}
00109
00110 #endif
00111