ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkFEMItpackSparseMatrix.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkFEMItpackSparseMatrix_h
20 #define itkFEMItpackSparseMatrix_h
21 
22 #include "itkFEMException.h"
23 #include "ITKFEMExport.h"
24 
25 namespace itk
26 {
27 namespace fem
28 {
37 // Forward declaration of friend class
38 class ItpackLinearSystemWrapper;
39 
40 class ITKFEM_EXPORT ItpackSparseMatrix
41 {
42 public:
43 
45  typedef long integer;
46  typedef double doublereal;
47 
50 
56 
63  ItpackSparseMatrix(integer order, integer maxNonZeroValues);
64 
69 
75  void SetOrder(integer order)
76  {
77  m_N = order;
78  }
79 
85  void SetMaxNonZeroValues(integer maxNonZeroValues)
86  {
87  m_NZ = maxNonZeroValues;
88  }
89 
96  void Set(integer i, integer j, doublereal value);
97 
104  void Add(integer i, integer j, doublereal value);
105 
110  doublereal Get(integer i, integer j);
111 
116  {
117  return &m_N;
118  }
119 
123  integer * GetIA();
124 
131  void SetCompressedRow(integer *ia, integer *ja, doublereal *a);
132 
136  integer * GetJA();
137 
141  doublereal * GetA();
142 
147  {
148  return GetA();
149  }
150 
155  {
156  return GetJA();
157  }
158 
163  {
164  return GetIA();
165  }
166 
171  {
172  return m_N;
173  }
174 
179  {
180  return m_NZ;
181  }
182 
186  void Clear();
187 
191  void mult(doublereal *vector, doublereal *result);
192 
196  void mult(ItpackSparseMatrix *rightMatrix, ItpackSparseMatrix *resultMatrix);
197 
199  void PrintCompressedRow();
200 
201 private:
202 
205 
207  void Initialize();
208 
210  void UnFinalize();
211 
213  void Finalize();
214 
217 
220 
223 
226 
229 
232 
235 
238 
246 
249 
258 
266  // integer m_IER;
267 };
268 
277 {
278 public:
279 
281  typedef long integer;
282  typedef double doublereal;
283 
289  FEMExceptionItpackSparseMatrixSbagn(const char *file, unsigned int lineNumber, std::string location,
290  integer errorCode);
291 
294  throw ( );
295 
298 };
299 
307 class ITK_ABI_EXPORT FEMExceptionItpackSparseMatrixSbsij : public FEMException
308 {
309 public:
310 
312  typedef long integer;
313  typedef double doublereal;
314 
320  FEMExceptionItpackSparseMatrixSbsij(const char *file, unsigned int lineNumber, std::string location,
321  integer errorCode);
322 
325  throw ( );
326 
328  itkTypeMacro(FEMExceptionItpackSparseMatrixSbsij, FEMException);
329 };
330 }
331 } // end namespace itk::fem
332 
333 #endif
handles errors that occur when building the matrix
a compressed row sparse matrix representation that makes use of itpack to dynamically assemble the ma...
Declaration of several exception classes that are used within the FEM code.
void SetMaxNonZeroValues(integer maxNonZeroValues)
handles errors that occur when unfinalizing the matrix
LinearSystemWrapper class that uses Itpack numeric library functions to define and solve a sparse lin...
Base class for all exception's that can occur within FEM classes.