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

itkFEMLinearSystemWrapperItpack.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFEMLinearSystemWrapperItpack.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/06/03 18:34:03 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkFEMLinearSystemWrapperItpack_h
00019 #define __itkFEMLinearSystemWrapperItpack_h
00020 
00021 #include "itpack_f2c.h"
00022 #include "itpack.h"
00023 #include "itkFEMSolution.h"
00024 #include "itkFEMLinearSystemWrapper.h"
00025 #include "itkFEMItpackSparseMatrix.h"
00026 #include <vector>
00027 
00028 
00029 namespace itk {
00030 namespace fem {
00031 
00038 class LinearSystemWrapperItpack : public LinearSystemWrapper
00039 {
00040 public:
00041  
00043   typedef LinearSystemWrapperItpack Self;
00044 
00046   typedef LinearSystemWrapper Superclass;
00047 
00049   typedef itpack::integer integer;
00050   
00052   typedef itpack::doublereal doublereal;
00053 
00055   typedef ItpackSparseMatrix MatrixRepresentation;
00056 
00058   typedef std::vector<MatrixRepresentation> MatrixHolder;
00059 
00060   /* auto pointer to vector of matrices typedef */
00061   /* typedef std::auto_ptr<MatrixHolder> MatrixArrayPtr; */
00062 
00064   /* typedef std::auto_ptr<doublereal> VectorRepresentation; */
00065   typedef doublereal* VectorRepresentation;
00066 
00068   typedef std::vector<VectorRepresentation> VectorHolder;
00069 
00070   /* auto pointer to vector of vectors typedef */
00071   /* typedef std::auto_ptr<VectorHolder> VectorArrayPtr; */
00072 
00073   /* pointer to array of unsigned int typedef */
00074   /* typedef std::auto_ptr<unsigned int> UnsignedIntegerArrayPtr; */
00075 
00076   /* -----------------------------------------------------------------
00077    * 
00078    * Routines for setting/reporting itpack parameters 
00079    *
00080    * ----------------------------------------------------------------- 
00081    */
00082 
00087   void SetMaximumNumberIterations(integer i) {   m_IPARM[0] = i; }
00088 
00092   integer  GetMaximumNumberIterations() { return m_IPARM[0]; }
00093 
00094   //void SetErrorReportingLevel(integer i) {   m_IPARM[1] = i; }
00095 
00099   integer  GetErrorReportingLevel() { return m_IPARM[1]; }
00100 
00105   void SetCommunicationSwitch(integer i) {   m_IPARM[2] = i; }
00106 
00110   integer  GetCommunicationSwitch() { return m_IPARM[2]; }
00111 
00112   //void SetOutputNumber(integer i) {   m_IPARM[3] = i; }
00113 
00117   integer  GetOutputNumber() { return m_IPARM[3]; }
00118 
00123   void SetSymmetricMatrixFlag(integer i) {   m_IPARM[4] = i; }
00124 
00128   integer  GetSymmetricMatrixFlag() { return m_IPARM[4]; }
00129 
00134   void SetAdaptiveSwitch(integer i) {   m_IPARM[5] = i; }
00135 
00139   integer  GetAdaptiveSwitch() { return m_IPARM[5]; }
00140 
00145   void SetAdaptiveCaseSwitch(integer i) {   m_IPARM[6] = i; }
00146 
00150   integer  GetAdaptiveCaseSwitch() { return m_IPARM[6]; }
00151 
00157   void SetWorkspaceUsed(integer i) {   m_IPARM[7] = i; }
00158 
00163   integer  GetWorkspaceUsed() { return m_IPARM[7]; }
00164 
00169   void SetRedBlackOrderingSwitch(integer i) {   m_IPARM[8] = i; }
00170 
00174   integer  GetRedBlackOrderingSwitch() { return m_IPARM[8]; }
00175 
00180   void SetRemoveSwitch(integer i) {   m_IPARM[9] = i; }
00181 
00185   integer  GetRemoveSwitch() { return m_IPARM[9]; }
00186 
00191   void SetTimingSwitch(integer i) {   m_IPARM[10] = i; }
00192 
00196   integer  GetTimingSwitch() { return m_IPARM[10]; }
00197 
00202   void SetErrorAnalysisSwitch(integer i) {   m_IPARM[11] = i; }
00203 
00207   integer  GetErrorAnalysisSwitch() { return m_IPARM[11]; }
00208 
00213   void   SetAccuracy(doublereal i) {   m_RPARM[0] = i; }
00214 
00218   doublereal GetAccuracy()    { return m_RPARM[0]; }
00219 
00224   void   SetLargestJacobiEigenvalueEstimate(doublereal i) {   m_RPARM[1] = i; }
00225 
00229   doublereal GetLargestJacobiEigenvalueEstimate()    { return m_RPARM[1]; }
00230 
00235   void   SetSmallestJacobiEigenvalueEstimate(doublereal i) {   m_RPARM[2] = i; }
00236 
00240   doublereal GetSmallestJacobiEigenvalueEstimate()    { return m_RPARM[2]; }
00241 
00246   void   SetDampingFactor(doublereal i) {   m_RPARM[3] = i; }
00247 
00251   doublereal GetDampingFactor()    { return m_RPARM[3]; }
00252 
00257   void   SetOverrelaxationParameter(doublereal i) {   m_RPARM[4] = i; }
00258 
00262   doublereal GetOverrelaxationParameter()    { return m_RPARM[4]; }
00263 
00268   void   SetEstimatedSpectralRadiusSSOR(doublereal i) {   m_RPARM[5] = i; }
00269 
00273   doublereal GetEstimatedSpectralRadiusSSOR()    { return m_RPARM[5]; }
00274 
00279   void   SetEstimatedSpectralRadiusLU(doublereal i) {   m_RPARM[6] = i; }
00280 
00284   doublereal GetEstimatedSpectralRadiusLU()    { return m_RPARM[6]; }
00285 
00290   void   SetTolerance(doublereal i) {   m_RPARM[7] = i; }
00291 
00295   doublereal GetTolerance()    { return m_RPARM[7]; }
00296 
00301   void   SetTimeToConvergence(doublereal i) {   m_RPARM[8] = i; }
00302 
00306   doublereal GetTimeToConvergence()    { return m_RPARM[8]; }
00307 
00312   void   SetTimeForCall(doublereal i) {   m_RPARM[9] = i; }
00313 
00317   doublereal GetTimeForCall()    { return m_RPARM[9]; }
00318 
00323   void   SetDigitsInError(doublereal i) {   m_RPARM[10] = i; }
00324 
00328   doublereal GetDigitsInError()    { return m_RPARM[10]; }
00329 
00334   void   SetDigitsInResidual(doublereal i) {   m_RPARM[11] = i; }
00335 
00339   doublereal GetDigitsInResidual()    { return m_RPARM[11]; }
00340 
00344   void JacobianConjugateGradient() { m_Method = 0; }
00345 
00349   void JacobianSemiIterative() { m_Method = 1; }
00350 
00354   void SuccessiveOverrelaxation() { m_Method = 2; }
00355 
00360   void SymmetricSuccessiveOverrelaxationConjugateGradient() { m_Method = 3; }
00361 
00366   void SymmetricSuccessiveOverrelaxationSuccessiveOverrelaxation() { m_Method = 4; }
00367 
00371   void ReducedSystemConjugateGradient() { m_Method = 5; }
00372 
00375   void ReducedSystemSemiIteration() { m_Method = 6; }
00376 
00377 
00378   /* -----------------------------------------------------------------
00379    * 
00380    * Redefine methods defined in LinearSystemWrapper 
00381    *
00382    * ----------------------------------------------------------------- 
00383    */
00384 
00390   virtual void SetMaximumNonZeroValuesInMatrix(unsigned int maxNonZeroValues) {m_MaximumNonZeroValues = maxNonZeroValues;}
00391 
00392 
00393   void ScaleMatrix(Float scale, unsigned int matrixIndex);
00394 
00395 
00396   /* -----------------------------------------------------------------
00397    * 
00398    * Functions required by LinearSystemWrapper 
00399    *
00400    * ----------------------------------------------------------------- 
00401    */
00402 
00406   LinearSystemWrapperItpack();
00407   
00411   ~LinearSystemWrapperItpack();
00412 
00413 
00414   /* memory management routines */
00415   virtual void  InitializeMatrix(unsigned int matrixIndex);  
00416 
00417   virtual bool  IsMatrixInitialized(unsigned int matrixIndex);
00418 
00419   virtual void  DestroyMatrix(unsigned int matrixIndex);
00420 
00421   virtual void  InitializeVector(unsigned int vectorIndex);
00422 
00423   virtual bool  IsVectorInitialized(unsigned int vectorIndex);
00424 
00425   virtual void  DestroyVector(unsigned int vectorIndex);
00426 
00427   virtual void  InitializeSolution(unsigned int solutionIndex);
00428 
00429   virtual bool  IsSolutionInitialized(unsigned int solutionIndex);
00430 
00431   virtual void  DestroySolution(unsigned int solutionIndex);
00432 
00433   /* assembly & solving routines */
00434   virtual Float GetMatrixValue(unsigned int i, unsigned int j, unsigned int matrixIndex) const;
00435 
00436   virtual void  SetMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex);
00437 
00438   virtual void  AddMatrixValue(unsigned int i, unsigned int j, Float value, unsigned int matrixIndex);
00439 
00440   virtual void GetColumnsOfNonZeroMatrixElementsInRow( unsigned int row, ColumnArray& cols, unsigned int matrixIndex );
00441 
00442   virtual Float GetVectorValue(unsigned int i, unsigned int vectorIndex) const;
00443 
00444   virtual void  SetVectorValue(unsigned int i, Float value, unsigned int vectorIndex);
00445 
00446   virtual void  AddVectorValue(unsigned int i, Float value, unsigned int vectorIndex);
00447 
00448   virtual Float GetSolutionValue(unsigned int i, unsigned int solutionIndex) const;
00449 
00450   virtual void  SetSolutionValue(unsigned int i, Float value, unsigned int solutionIndex);
00451 
00452   virtual void  AddSolutionValue(unsigned int i, Float value, unsigned int solutionIndex);
00453 
00454   virtual void  Solve(void);
00455 
00456 
00457   /* matrix & vector manipulation routines */
00458   virtual void  SwapMatrices(unsigned int matrixIndex1, unsigned int matrixIndex2);
00459 
00460   virtual void  SwapVectors(unsigned int vectorIndex1, unsigned int vectorIndex2);
00461 
00462   virtual void  SwapSolutions(unsigned int solutionIndex1, unsigned int solutionIndex2);
00463 
00464   virtual void  CopySolution2Vector(unsigned solutionIndex, unsigned int vectorIndex);
00465 
00466   virtual void  CopyVector2Solution(unsigned int vectorIndex, unsigned int solutionIndex);
00467 
00468   virtual void  MultiplyMatrixMatrix(unsigned int resultMatrixIndex, unsigned int leftMatrixIndex, unsigned int rightMatrixIndex);
00469 
00470   virtual void  MultiplyMatrixVector(unsigned int resultVectorIndex, unsigned int matrixIndex, unsigned int vectorIndex);
00471 
00472 private:
00473 
00475   MatrixHolder *m_Matrices;
00476 
00478   VectorHolder *m_Vectors;
00479 
00481   VectorHolder *m_Solutions;
00482 
00484   //UnsignedIntegerArrayPtr m_MaximumNonZeroValues;
00485   unsigned int m_MaximumNonZeroValues;
00486 
00488   int (*m_Methods[7])(integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *, doublereal *, 
00489        integer *, doublereal *, integer *);
00490 
00492   integer m_Method;
00493 
00495   integer m_IPARM[12];
00496 
00498   doublereal m_RPARM[12];
00499 
00500 };
00501 
00508 class FEMExceptionItpackSolver : public FEMException
00509 {
00510 public:
00516   FEMExceptionItpackSolver(const char *file, unsigned int lineNumber, std::string location, itpack::integer errorCode);
00517  
00519   virtual ~FEMExceptionItpackSolver() throw() {}
00520   
00522   itkTypeMacro(FEMExceptionItpackSolver,FEMException);
00523   
00524 };
00525 
00526 
00527 
00528 }} // end namespace itk::fem
00529 
00530 #endif // #ifndef __itkFEMLinearSystemWrapperItpack_h
00531 
00532 

Generated at Wed Mar 12 01:12:55 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000