Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFEMLinearSystemWrapper.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkFEMLinearSystemWrapper.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:42 $ 00007 Version: $Revision: 1.22 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef __itkFEMLinearSystemWrapper_h 00019 #define __itkFEMLinearSystemWrapper_h 00020 00021 #include "itkMacro.h" 00022 #include "itkFEMSolution.h" 00023 #include "itkFEMException.h" 00024 00025 #include <vector> 00026 #include <typeinfo> 00027 #include <string> 00028 00029 namespace itk { 00030 namespace fem { 00031 00032 00051 class LinearSystemWrapper : public Solution 00052 { 00053 public: 00055 typedef LinearSystemWrapper Self; 00056 00058 typedef Solution Superclass; 00059 00061 typedef Self* Pointer; 00062 00064 typedef const Self* ConstPointer; 00065 00066 typedef std::vector<unsigned int> ColumnArray; 00067 00072 LinearSystemWrapper() 00073 : m_Order(0), m_NumberOfMatrices(1), m_NumberOfVectors(1), m_NumberOfSolutions(1) {} 00074 /* , m_PrimaryMatrixSetupFunction(0), m_PrimaryVectorSetupFunction(0), m_PrimarySolutionSetupFunction(0) {} */ 00075 00080 virtual ~LinearSystemWrapper() {}; 00081 00086 virtual void Clean( void ); 00087 00093 void SetSystemOrder(unsigned int N) { m_Order = N; } 00094 00098 unsigned int GetSystemOrder() const { return m_Order; } 00099 00104 void SetNumberOfMatrices(unsigned int nMatrices) { m_NumberOfMatrices = nMatrices; } 00105 00106 /* 00107 * Set the maximum number of entries permitted in a matrix 00108 * \param matrixIndex index of matrix to set value for 00109 * \param maxNonZeros maximum number of entries allowed in matrix 00110 * \note in general this function does nothing, however it may 00111 * redefined by the derived wrapper if necessary 00112 */ 00113 //virtual void SetMaximumNonZeroValuesInMatrix(unsigned int maxNonZeroValues) = 0; 00114 00118 unsigned int GetNumberOfMatrices() { return m_NumberOfMatrices; } 00119 00124 void SetNumberOfVectors(unsigned int nVectors) { m_NumberOfVectors = nVectors; } 00125 00129 unsigned int GetNumberOfVectors() { return m_NumberOfVectors; } 00130 00135 void SetNumberOfSolutions(unsigned int nSolutions) { m_NumberOfSolutions = nSolutions; } 00136 00140 unsigned int GetNumberOfSolutions() { return m_NumberOfSolutions; } 00141 00149 virtual void InitializeMatrix(unsigned int matrixIndex = 0) = 0; 00150 00151 00156 virtual bool IsMatrixInitialized(unsigned int matrixIndex = 0) = 0; 00157 00162 virtual void DestroyMatrix(unsigned int matrixIndex = 0) = 0; 00163 00170 virtual void InitializeVector(unsigned int vectorIndex = 0) = 0; 00171 00172 00177 virtual bool IsVectorInitialized(unsigned int vectorIndex = 0) = 0; 00178 00183 virtual void DestroyVector(unsigned int vectorIndex = 0) = 0; 00184 00191 virtual void InitializeSolution(unsigned int solutionIndex = 0) = 0; 00192 00197 virtual bool IsSolutionInitialized(unsigned int solutionIndex = 0) = 0; 00198 00202 virtual void DestroySolution(unsigned int solutionIndex = 0) = 0; 00203 00210 virtual Float GetMatrixValue(unsigned int i, unsigned int j, unsigned int matrixIndex = 0) const = 0; 00211 00219 virtual void SetMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0; 00220 00228 virtual void AddMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0; 00229 00242 virtual void GetColumnsOfNonZeroMatrixElementsInRow( unsigned int row, ColumnArray& cols, unsigned int matrixIndex = 0 ); 00243 00249 virtual Float GetVectorValue(unsigned int i, unsigned int vectorIndex = 0) const = 0; 00250 00257 virtual void SetVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0; 00258 00265 virtual void AddVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0; 00266 00274 virtual void SetSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0; 00275 00283 virtual void AddSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0; 00284 00292 virtual void Solve(void) = 0; 00293 00299 virtual void SwapMatrices(unsigned int matrixIndex1, unsigned int matrixIndex2) = 0; 00300 00308 virtual void CopyMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2); 00309 00315 virtual void SwapVectors(unsigned int vectorIndex1, unsigned int vectorIndex2) = 0; 00316 00322 virtual void SwapSolutions(unsigned int solutionIndex1, unsigned int solutionIndex2) = 0; 00323 00324 00330 virtual void ScaleMatrix(Float scale, unsigned int matrixIndex = 0); 00331 00332 00338 void ScaleVector(Float scale, unsigned int vectorIndex = 0); 00339 00340 00346 void ScaleSolution(Float scale, unsigned int solutionIndex = 0); 00347 00354 virtual void MultiplyMatrixMatrix(unsigned int resultMatrixIndex, unsigned int leftMatrixIndex, unsigned int rightMatrixIndex) = 0; 00355 00362 virtual void AddMatrixMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2); 00363 00370 virtual void AddVectorVector(unsigned int vectorIndex1, unsigned int vectorIndex2); 00371 00378 virtual void MultiplyMatrixVector(unsigned int resultVectorIndex, unsigned int matrixIndex, unsigned int vectorIndex); 00379 00385 virtual void CopySolution2Vector(unsigned int solutionIndex, unsigned int vectorIndex) = 0; 00386 00392 virtual void CopyVector2Solution(unsigned int vectorIndex, unsigned int solutionIndex) = 0; 00398 virtual void CopyVector(unsigned int vectorSource, unsigned int vectorDestination); 00399 00406 virtual void OptimizeMatrixStorage(unsigned int matrixIndex, unsigned int tempMatrixIndex); 00407 00413 virtual void ReverseCuthillMckeeOrdering(ColumnArray& newNumbering, unsigned int matrixIndex = 0); 00414 00415 /* 00416 * Sets the function used to prepare the primary system matrix for numerical solving 00417 * \param SetupFunction pointer to function that stores the matrix to 00418 * solve in the 0 matrix of the linear system 00419 */ 00420 /* 00421 void SetPrimaryMatrixSetupFunction(void (*SetupFunction)(LinearSystemWrapper *lsw)) 00422 { 00423 m_PrimaryMatrixSetupFunction = SetupFunction; 00424 } 00425 */ 00426 00427 00428 /* 00429 * Sets the function used to prepare the primary system vector for numerical solving 00430 * \param SetupFunction pointer to function that stores the vector to 00431 * solve in the 0 vector of the linear system 00432 */ 00433 /* 00434 void SetPrimaryVectorSetupFunction(void (*SetupFunction)(LinearSystemWrapper *lsw)) 00435 { 00436 m_PrimaryVectorSetupFunction = SetupFunction; 00437 } 00438 */ 00439 00440 /* 00441 * Sets the function used to prepare the primary system solution for numerical solving 00442 * \param SetupFunction pointer to function that stores the solution 00443 * in the 0 solution vector of the linear system 00444 */ 00445 /* 00446 void SetPrimarySolutionSetupFunction(void (*SetupFunction)(LinearSystemWrapper *lsw)) 00447 { 00448 m_PrimarySolutionSetupFunction = SetupFunction; 00449 } 00450 */ 00451 00452 protected: 00453 00455 unsigned int m_Order; 00456 00460 unsigned int m_NumberOfMatrices; 00461 00465 unsigned int m_NumberOfVectors; 00466 00470 unsigned int m_NumberOfSolutions; 00471 00472 /* 00473 * Function used to prepare primary matrix for numerical solving 00474 */ 00475 //void (*m_PrimaryMatrixSetupFunction)(LinearSystemWrapper *lsw); 00476 00477 /* 00478 * Function used to prepare primary vector for numerical solving 00479 */ 00480 /* void (*m_PrimaryVectorSetupFunction)(LinearSystemWrapper *lsw);*/ 00481 00482 /* 00483 * Function used to prepare primary matrix for numerical solving 00484 */ 00485 /* void (*m_PrimarySolutionSetupFunction)(LinearSystemWrapper *lsw); */ 00486 00487 private: 00488 00492 void CuthillMckeeOrdering(ColumnArray& newNumbering, int startingRow, unsigned int matrixIndex = 0); 00493 00494 void FollowConnectionsCuthillMckeeOrdering(unsigned int rowNumber, ColumnArray& rowDegree, ColumnArray& newNumbering, unsigned int nextRowNumber, unsigned int matrixIndex = 0); 00495 00497 LinearSystemWrapper(const LinearSystemWrapper&); 00498 00500 const LinearSystemWrapper& operator= (const LinearSystemWrapper&); 00501 00502 }; 00503 00504 00505 00506 class FEMExceptionLinearSystem : public FEMException 00507 { 00508 public: 00514 FEMExceptionLinearSystem(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription); 00515 00517 virtual ~FEMExceptionLinearSystem() throw() {} 00518 00520 itkTypeMacro(FEMExceptionLinearSystem,FEMException); 00521 00522 }; 00523 00524 class FEMExceptionLinearSystemBounds : public FEMException 00525 { 00526 public: 00532 FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1); 00533 00538 FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1, unsigned int index2); 00539 00541 virtual ~FEMExceptionLinearSystemBounds() throw() {} 00542 00544 itkTypeMacro(FEMExceptionLinearSystem,FEMException); 00545 00546 }; 00547 00548 }} // end namespace itk::fem 00549 00550 #endif // #ifndef __itkFEMLinearSystemWrapper_h

Generated at Sat Mar 31 02:18:28 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000