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: 2009-01-29 21:55:14 $
00007   Version:   $Revision: 1.23 $
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:
00054   typedef LinearSystemWrapper Self;
00055   typedef Solution            Superclass;
00056   typedef Self*               Pointer;
00057   typedef const Self*         ConstPointer;
00058 
00059   typedef std::vector<unsigned int> ColumnArray;
00060 
00065   LinearSystemWrapper() 
00066     : m_Order(0), m_NumberOfMatrices(1), m_NumberOfVectors(1), m_NumberOfSolutions(1) {}
00067       /* , m_PrimaryMatrixSetupFunction(0), m_PrimaryVectorSetupFunction(0), m_PrimarySolutionSetupFunction(0) {} */
00069 
00074   virtual ~LinearSystemWrapper() {};
00075 
00080   virtual void Clean( void );
00081 
00087   void SetSystemOrder(unsigned int N) { m_Order = N; }
00088 
00092   unsigned int GetSystemOrder() const { return m_Order; }
00093 
00098   void SetNumberOfMatrices(unsigned int nMatrices) { m_NumberOfMatrices = nMatrices; }
00099 
00107   //virtual void SetMaximumNonZeroValuesInMatrix(unsigned int maxNonZeroValues) = 0;
00108 
00112   unsigned int GetNumberOfMatrices() { return m_NumberOfMatrices; }
00113 
00118   void SetNumberOfVectors(unsigned int nVectors) { m_NumberOfVectors = nVectors; }
00119 
00123   unsigned int GetNumberOfVectors() { return m_NumberOfVectors; }
00124 
00129   void SetNumberOfSolutions(unsigned int nSolutions) { m_NumberOfSolutions = nSolutions; }
00130 
00134   unsigned int GetNumberOfSolutions() { return m_NumberOfSolutions; }
00135 
00143   virtual void InitializeMatrix(unsigned int matrixIndex = 0) = 0;
00144 
00145 
00150   virtual bool IsMatrixInitialized(unsigned int matrixIndex = 0) = 0;
00151 
00156   virtual void DestroyMatrix(unsigned int matrixIndex = 0) = 0;
00157 
00164   virtual void InitializeVector(unsigned int vectorIndex = 0) = 0;
00165 
00166 
00171   virtual bool IsVectorInitialized(unsigned int vectorIndex = 0) = 0;
00172 
00177   virtual void DestroyVector(unsigned int vectorIndex = 0) = 0;
00178 
00185   virtual void InitializeSolution(unsigned int solutionIndex = 0) = 0;
00186 
00191   virtual bool IsSolutionInitialized(unsigned int solutionIndex = 0) = 0;
00192 
00196   virtual void DestroySolution(unsigned int solutionIndex = 0) = 0;
00197 
00204   virtual Float GetMatrixValue(unsigned int i, unsigned int j, unsigned int matrixIndex = 0) const = 0;
00205 
00213   virtual void SetMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0;
00214 
00222   virtual void AddMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0;
00223 
00236   virtual void GetColumnsOfNonZeroMatrixElementsInRow( unsigned int row, ColumnArray& cols, unsigned int matrixIndex = 0 );
00237 
00243   virtual Float GetVectorValue(unsigned int i, unsigned int vectorIndex = 0) const = 0;
00244 
00251   virtual void SetVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0;
00252 
00259   virtual void AddVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0;
00260 
00268   virtual void SetSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0;
00269 
00277   virtual void AddSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0;
00278 
00286   virtual void Solve(void) = 0;
00287 
00293   virtual void SwapMatrices(unsigned int matrixIndex1, unsigned int matrixIndex2) = 0;
00294 
00302   virtual void CopyMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2);
00303 
00309   virtual void SwapVectors(unsigned int vectorIndex1, unsigned int vectorIndex2) = 0;
00310 
00316   virtual void SwapSolutions(unsigned int solutionIndex1, unsigned int solutionIndex2) = 0;
00317 
00318 
00324   virtual void ScaleMatrix(Float scale, unsigned int matrixIndex = 0);
00325 
00326 
00332   void ScaleVector(Float scale, unsigned int vectorIndex = 0);
00333 
00334 
00340   void ScaleSolution(Float scale, unsigned int solutionIndex = 0);
00341 
00348   virtual void MultiplyMatrixMatrix(unsigned int resultMatrixIndex, unsigned int leftMatrixIndex, unsigned int rightMatrixIndex) = 0;
00349 
00356   virtual void AddMatrixMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2);
00357 
00364   virtual void AddVectorVector(unsigned int vectorIndex1, unsigned int vectorIndex2);
00365 
00372   virtual void MultiplyMatrixVector(unsigned int resultVectorIndex, unsigned int matrixIndex, unsigned int vectorIndex);
00373 
00379   virtual void CopySolution2Vector(unsigned int solutionIndex, unsigned int vectorIndex) = 0;
00380 
00386   virtual void CopyVector2Solution(unsigned int vectorIndex, unsigned int solutionIndex) = 0;
00387 
00393   virtual void CopyVector(unsigned int vectorSource, unsigned int vectorDestination);
00394 
00401   virtual void OptimizeMatrixStorage(unsigned int matrixIndex, unsigned int tempMatrixIndex);
00402 
00408   virtual void ReverseCuthillMckeeOrdering(ColumnArray& newNumbering, unsigned int matrixIndex = 0);
00409 
00410 protected:
00411 
00413   unsigned int m_Order;
00414 
00418   unsigned int m_NumberOfMatrices;
00419 
00423   unsigned int m_NumberOfVectors;
00424 
00428   unsigned int m_NumberOfSolutions;
00429 
00430   /*
00431    * Function used to prepare primary matrix for numerical solving 
00432    */
00433   //void (*m_PrimaryMatrixSetupFunction)(LinearSystemWrapper *lsw);
00434 
00435   /*
00436    * Function used to prepare primary vector for numerical solving 
00437    */
00438   /* void (*m_PrimaryVectorSetupFunction)(LinearSystemWrapper *lsw);*/
00439 
00440   /*
00441    * Function used to prepare primary matrix for numerical solving 
00442    */
00443   /* void (*m_PrimarySolutionSetupFunction)(LinearSystemWrapper *lsw); */
00444 
00445 private:
00446 
00450   void CuthillMckeeOrdering(ColumnArray& newNumbering, int startingRow, unsigned int matrixIndex = 0);
00451 
00452   void FollowConnectionsCuthillMckeeOrdering(unsigned int rowNumber, ColumnArray& rowDegree, ColumnArray& newNumbering, unsigned int nextRowNumber, unsigned int matrixIndex = 0);
00453 
00455   LinearSystemWrapper(const LinearSystemWrapper&);
00456 
00458   const LinearSystemWrapper& operator= (const LinearSystemWrapper&);
00459 
00460 };
00461 
00462 class FEMExceptionLinearSystem : public FEMException
00463 {
00464 public:
00470   FEMExceptionLinearSystem(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription);
00471 
00473   virtual ~FEMExceptionLinearSystem() throw() {}
00474 
00476   itkTypeMacro(FEMExceptionLinearSystem,FEMException);
00477 
00478 };
00479 
00480 class FEMExceptionLinearSystemBounds : public FEMException
00481 {
00482 public:
00488   FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1);
00489 
00494   FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1, unsigned int index2);
00495 
00497   virtual ~FEMExceptionLinearSystemBounds() throw() {}
00498 
00500   itkTypeMacro(FEMExceptionLinearSystem,FEMException);
00501 
00502 };
00503 
00504 }} // end namespace itk::fem
00505 
00506 #endif // #ifndef __itkFEMLinearSystemWrapper_h
00507 

Generated at Mon Jul 12 2010 18:19:18 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000