ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkFEMItpackSparseMatrix.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 
00019 #ifndef __itkFEMItpackSparseMatrix_h
00020 #define __itkFEMItpackSparseMatrix_h
00021 
00022 #include "itkFEMException.h"
00023 
00024 namespace itk
00025 {
00026 namespace fem
00027 {
00036 // Forward declaration of friend class
00037 class ItpackLinearSystemWrapper;
00038 
00039 class ItpackSparseMatrix
00040 {
00041 public:
00042 
00044   typedef long   integer;
00045   typedef double doublereal;
00046 
00048   ItpackSparseMatrix();
00049 
00054   ItpackSparseMatrix(integer order);
00055 
00062   ItpackSparseMatrix(integer order, integer maxNonZeroValues);
00063 
00067   ~ItpackSparseMatrix();
00068 
00074   void SetOrder(integer order)
00075   {
00076     m_N = order;
00077   }
00078 
00084   void SetMaxNonZeroValues(integer maxNonZeroValues)
00085   {
00086     m_NZ = maxNonZeroValues;
00087   }
00088 
00095   void Set(integer i, integer j, doublereal value);
00096 
00103   void Add(integer i, integer j, doublereal value);
00104 
00109   doublereal Get(integer i, integer j);
00110 
00114   integer *    GetN()
00115   {
00116     return &m_N;
00117   }
00118 
00122   integer *     GetIA();
00123 
00130   void  SetCompressedRow(integer *ia, integer *ja, doublereal *a);
00131 
00135   integer *     GetJA();
00136 
00140   doublereal *  GetA();
00141 
00145   doublereal * GetValueArray()
00146   {
00147     return GetA();
00148   }
00149 
00153   integer *    GetColumnArray()
00154   {
00155     return GetJA();
00156   }
00157 
00161   integer *    GetRowArray()
00162   {
00163     return GetIA();
00164   }
00165 
00169   integer     GetOrder()       const
00170   {
00171     return m_N;
00172   }
00173 
00177   integer     GetMaxNonZeroValues() const
00178   {
00179     return m_NZ;
00180   }
00181 
00185   void Clear();
00186 
00190   void mult(doublereal *vector, doublereal *result);
00191 
00195   void mult(ItpackSparseMatrix *rightMatrix, ItpackSparseMatrix *resultMatrix);
00196 
00198   void PrintCompressedRow();
00199 
00200 private:
00201 
00203   friend class LinearSystemWrapperItpack;
00204 
00206   void Initialize();
00207 
00209   void UnFinalize();
00210 
00212   void Finalize();
00213 
00215   integer m_MatrixFinalized;
00216 
00218   integer m_MatrixInitialized;
00219 
00221   integer m_N;
00222 
00224   integer m_NZ;
00225 
00227   integer *m_IA;
00228 
00230   integer *m_JA;
00231 
00233   doublereal *m_A;
00234 
00236   integer *m_IWORK;
00237 
00244   integer m_MODE;
00245 
00247   integer m_NOUT;
00248 
00256   integer m_LEVEL;
00257 
00265   // integer m_IER;
00266 };
00267 
00275 class ITK_ABI_EXPORT FEMExceptionItpackSparseMatrixSbagn : public FEMException
00276 {
00277 public:
00278 
00280   typedef long   integer;
00281   typedef double doublereal;
00282 
00288   FEMExceptionItpackSparseMatrixSbagn(const char *file, unsigned int lineNumber, std::string location,
00289                                       integer errorCode);
00290 
00292   virtual ~FEMExceptionItpackSparseMatrixSbagn()
00293   throw ( )
00294   {
00295   }
00296 
00298   itkTypeMacro(FEMExceptionItpackSparseMatrixSbagn, FEMException);
00299 };
00300 
00308 class ITK_ABI_EXPORT FEMExceptionItpackSparseMatrixSbsij : public FEMException
00309 {
00310 public:
00311 
00313   typedef long   integer;
00314   typedef double doublereal;
00315 
00321   FEMExceptionItpackSparseMatrixSbsij(const char *file, unsigned int lineNumber, std::string location,
00322                                       integer errorCode);
00323 
00325   virtual ~FEMExceptionItpackSparseMatrixSbsij()
00326   throw ( )
00327   {
00328   }
00329 
00331   itkTypeMacro(FEMExceptionItpackSparseMatrixSbsij, FEMException);
00332 };
00333 }
00334 }  // end namespace itk::fem
00335 
00336 #endif
00337