Orfeo Toolbox  3.16
itkFEMLinearSystemWrapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFEMLinearSystemWrapper.h,v $
5  Language: C++
6  Date: $Date: 2009-01-29 21:55:14 $
7  Version: $Revision: 1.23 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkFEMLinearSystemWrapper_h
19 #define __itkFEMLinearSystemWrapper_h
20 
21 #include "itkMacro.h"
22 #include "itkFEMSolution.h"
23 #include "itkFEMException.h"
24 
25 #include <vector>
26 #include <typeinfo>
27 #include <string>
28 
29 namespace itk {
30 namespace fem {
31 
32 
52 {
53 public:
56  typedef Self* Pointer;
57  typedef const Self* ConstPointer;
58 
59  typedef std::vector<unsigned int> ColumnArray;
60 
67  /* , m_PrimaryMatrixSetupFunction(0), m_PrimaryVectorSetupFunction(0), m_PrimarySolutionSetupFunction(0) {} */
68 
73  virtual ~LinearSystemWrapper() {};
74 
79  virtual void Clean( void );
80 
86  void SetSystemOrder(unsigned int N) { m_Order = N; }
87 
91  unsigned int GetSystemOrder() const { return m_Order; }
92 
97  void SetNumberOfMatrices(unsigned int nMatrices) { m_NumberOfMatrices = nMatrices; }
98 
106  //virtual void SetMaximumNonZeroValuesInMatrix(unsigned int maxNonZeroValues) = 0;
107 
111  unsigned int GetNumberOfMatrices() { return m_NumberOfMatrices; }
112 
117  void SetNumberOfVectors(unsigned int nVectors) { m_NumberOfVectors = nVectors; }
118 
122  unsigned int GetNumberOfVectors() { return m_NumberOfVectors; }
123 
128  void SetNumberOfSolutions(unsigned int nSolutions) { m_NumberOfSolutions = nSolutions; }
129 
133  unsigned int GetNumberOfSolutions() { return m_NumberOfSolutions; }
134 
142  virtual void InitializeMatrix(unsigned int matrixIndex = 0) = 0;
143 
144 
149  virtual bool IsMatrixInitialized(unsigned int matrixIndex = 0) = 0;
150 
155  virtual void DestroyMatrix(unsigned int matrixIndex = 0) = 0;
156 
163  virtual void InitializeVector(unsigned int vectorIndex = 0) = 0;
164 
165 
170  virtual bool IsVectorInitialized(unsigned int vectorIndex = 0) = 0;
171 
176  virtual void DestroyVector(unsigned int vectorIndex = 0) = 0;
177 
184  virtual void InitializeSolution(unsigned int solutionIndex = 0) = 0;
185 
190  virtual bool IsSolutionInitialized(unsigned int solutionIndex = 0) = 0;
191 
195  virtual void DestroySolution(unsigned int solutionIndex = 0) = 0;
196 
203  virtual Float GetMatrixValue(unsigned int i, unsigned int j, unsigned int matrixIndex = 0) const = 0;
204 
212  virtual void SetMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0;
213 
221  virtual void AddMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex = 0) = 0;
222 
235  virtual void GetColumnsOfNonZeroMatrixElementsInRow( unsigned int row, ColumnArray& cols, unsigned int matrixIndex = 0 );
236 
242  virtual Float GetVectorValue(unsigned int i, unsigned int vectorIndex = 0) const = 0;
243 
250  virtual void SetVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0;
251 
258  virtual void AddVectorValue(unsigned int i, Float value, unsigned int vectorIndex = 0) = 0;
259 
267  virtual void SetSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0;
268 
276  virtual void AddSolutionValue(unsigned int i, Float value, unsigned int solutionIndex = 0) = 0;
277 
285  virtual void Solve(void) = 0;
286 
292  virtual void SwapMatrices(unsigned int matrixIndex1, unsigned int matrixIndex2) = 0;
293 
301  virtual void CopyMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2);
302 
308  virtual void SwapVectors(unsigned int vectorIndex1, unsigned int vectorIndex2) = 0;
309 
315  virtual void SwapSolutions(unsigned int solutionIndex1, unsigned int solutionIndex2) = 0;
316 
317 
323  virtual void ScaleMatrix(Float scale, unsigned int matrixIndex = 0);
324 
325 
331  void ScaleVector(Float scale, unsigned int vectorIndex = 0);
332 
333 
339  void ScaleSolution(Float scale, unsigned int solutionIndex = 0);
340 
347  virtual void MultiplyMatrixMatrix(unsigned int resultMatrixIndex, unsigned int leftMatrixIndex, unsigned int rightMatrixIndex) = 0;
348 
355  virtual void AddMatrixMatrix(unsigned int matrixIndex1, unsigned int matrixIndex2);
356 
363  virtual void AddVectorVector(unsigned int vectorIndex1, unsigned int vectorIndex2);
364 
371  virtual void MultiplyMatrixVector(unsigned int resultVectorIndex, unsigned int matrixIndex, unsigned int vectorIndex);
372 
378  virtual void CopySolution2Vector(unsigned int solutionIndex, unsigned int vectorIndex) = 0;
379 
385  virtual void CopyVector2Solution(unsigned int vectorIndex, unsigned int solutionIndex) = 0;
391  virtual void CopyVector(unsigned int vectorSource, unsigned int vectorDestination);
392 
399  virtual void OptimizeMatrixStorage(unsigned int matrixIndex, unsigned int tempMatrixIndex);
400 
406  virtual void ReverseCuthillMckeeOrdering(ColumnArray& newNumbering, unsigned int matrixIndex = 0);
407 
408 protected:
409 
411  unsigned int m_Order;
412 
416  unsigned int m_NumberOfMatrices;
417 
421  unsigned int m_NumberOfVectors;
422 
426  unsigned int m_NumberOfSolutions;
427 
428  /*
429  * Function used to prepare primary matrix for numerical solving
430  */
431  //void (*m_PrimaryMatrixSetupFunction)(LinearSystemWrapper *lsw);
432 
433  /*
434  * Function used to prepare primary vector for numerical solving
435  */
436  /* void (*m_PrimaryVectorSetupFunction)(LinearSystemWrapper *lsw);*/
437 
438  /*
439  * Function used to prepare primary matrix for numerical solving
440  */
441  /* void (*m_PrimarySolutionSetupFunction)(LinearSystemWrapper *lsw); */
442 
443 private:
444 
448  void CuthillMckeeOrdering(ColumnArray& newNumbering, int startingRow, unsigned int matrixIndex = 0);
449 
450  void FollowConnectionsCuthillMckeeOrdering(unsigned int rowNumber, ColumnArray& rowDegree, ColumnArray& newNumbering, unsigned int nextRowNumber, unsigned int matrixIndex = 0);
451 
454 
457 
458 };
459 
461 {
462 public:
468  FEMExceptionLinearSystem(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription);
469 
471  virtual ~FEMExceptionLinearSystem() throw() {}
472 
475 
476 };
477 
479 {
480 public:
486  FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1);
487 
492  FEMExceptionLinearSystemBounds(const char *file, unsigned int lineNumber, std::string location, std::string moreDescription, unsigned int index1, unsigned int index2);
493 
495  virtual ~FEMExceptionLinearSystemBounds() throw() {}
496 
499 
500 };
501 
502 }} // end namespace itk::fem
503 
504 #endif // #ifndef __itkFEMLinearSystemWrapper_h

Generated at Sat Feb 2 2013 23:36:46 for Orfeo Toolbox with doxygen 1.8.1.1