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

itkFEMLinearSystemWrapperDenseVNL.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFEMLinearSystemWrapperDenseVNL.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-01-31 19:28:28 $
00007   Version:   $Revision: 1.9 $
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 __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   /* values stored in matrices & vectors */
00042   typedef LinearSystemWrapper::Float Float;
00043 
00044   /* superclass */
00045   typedef LinearSystemWrapper SuperClass;
00046 
00047   /* matrix typedef */
00048   typedef vnl_matrix<Float>                 MatrixRepresentation;
00049 
00050   /* matrix holder typedef */
00051   typedef std::vector< MatrixRepresentation* >     MatrixHolder;
00052 
00053   /* constructor & destructor */
00054   LinearSystemWrapperDenseVNL() : LinearSystemWrapper(), m_Matrices(0), m_Vectors(0), m_Solutions(0) {}
00055   virtual ~LinearSystemWrapperDenseVNL();
00056 
00057   /* memory management routines */
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   /* assembly & solving routines */
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   /* matrix & vector manipulation routines */
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   //std::vector< vnl_sparse_matrix<Float>* > *m_Matrices;
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 }} // end namespace itk::fem
00109 
00110 #endif
00111 

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