-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathBlockTridiagonalMatrix.h
68 lines (53 loc) · 1.92 KB
/
BlockTridiagonalMatrix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef MATH_BLOCK_TRIDIAGONAL_MATRIX
#define MATH_BLOCK_TRIDIAGONAL_MATRIX
#include "matrix.h"
#include "BlockVector.h"
namespace Math {
class BlockTridiagonalMatrix
{
public:
typedef BlockTridiagonalMatrix MyT;
BlockTridiagonalMatrix();
BlockTridiagonalMatrix(int nBlock);
BlockTridiagonalMatrix(int nBlock,int nMat);
BlockTridiagonalMatrix(int nBlock,int nMat,Real initVal);
inline int numBlockRows() const { return (int)diagonal.size(); }
inline int numBlockCols() const { return (int)diagonal.size(); }
int numTotalRows() const;
int numTotalCols() const;
void resize(int nBlock);
void resize(int nBlock,int nMat);
void resize(int nBlock,int nMat,Real initVal);
void resizeSimilar(const MyT&);
void clear();
Matrix& operator()(int i,int j);
const Matrix& operator()(int i,int j) const;
inline void operator += (const MyT& a) { inc(a); }
inline void operator -= (const MyT& a) { dec(a); }
void add(const MyT&,const MyT&);
void sub(const MyT&,const MyT&);
void mul(const MyT&,Real c);
void div(const MyT&,Real c);
void inc(const MyT&);
void dec(const MyT&);
void madd(const MyT&,Real c);
void mul(const BlockVector& a,BlockVector& x) const;
void mulTranspose(const BlockVector& a,BlockVector& x) const;
void madd(const BlockVector& a,BlockVector& x) const;
void maddTranspose(const BlockVector& a,BlockVector& x) const;
void setZero();
void set(Real);
void setIdentity();
void setTranspose(const MyT&);
bool solveInverse_LU(const BlockVector& b,BlockVector& x) const;
bool solveInverse_Cholesky(const BlockVector& b,BlockVector& x) const; //valid only if positive definite
void inplaceTranspose();
void getMatrix(Matrix&) const;
inline bool isEmpty() const { return diagonal.empty(); }
bool isValid() const;
bool hasDims(const MyT& m) const;
bool hasDims(int nBlock,int nMat) const;
std::vector<Matrix> diagonal,upperDiagonal,lowerDiagonal;
};
} //namespace Math
#endif