Program listing for file kernel/src/utils/SiconosAlgebra/BlockMatrix.hpp

Program listing for file kernel/src/utils/SiconosAlgebra/BlockMatrix.hpp#

  1#ifndef __BlockMatrix__
  2#define __BlockMatrix__
  3
  4#include "SiconosMatrix.hpp"
  5
  6
  7class BlockMatrix : public SiconosMatrix
  8{
  9private:
 10
 11  ACCEPT_SERIALIZATION(BlockMatrix);
 12
 13
 14  SP::BlocksMat _mat;
 15
 16
 17  SP::Index _tabRow;
 18
 19
 20  SP::Index _tabCol;
 21
 22
 23  unsigned int _dimRow;
 24
 25
 26  unsigned int _dimCol;
 27
 28
 29
 30  BlockMatrix() {};
 31
 32public:
 33
 34
 35  BlockMatrix(const SiconosMatrix& m);
 36
 37
 38  BlockMatrix(const BlockMatrix& m);
 39
 40
 41  BlockMatrix(const std::vector<SP::SiconosMatrix>& m, unsigned int row, unsigned int col);
 42
 43
 44  BlockMatrix(SP::SiconosMatrix A, SP::SiconosMatrix B, SP::SiconosMatrix C, SP::SiconosMatrix D);
 45
 46
 47  ~BlockMatrix(void) noexcept;
 48
 49  inline bool checkSymmetry(double tol) const override
 50  {
 51    return false;
 52  };
 53
 54
 55  unsigned int numberOfBlocks(unsigned int i) const override;
 56
 57
 58  const DenseMat getDense(unsigned int row = 0, unsigned int col = 0) const override;
 59
 60
 61  const TriangMat getTriang(unsigned int row = 0, unsigned int col = 0) const override;
 62
 63
 64  const SymMat getSym(unsigned int row = 0, unsigned int col = 0)const override;
 65
 66
 67  const BandedMat getBanded(unsigned int row = 0, unsigned int col = 0)const override;
 68
 69
 70  const SparseMat getSparse(unsigned int row = 0, unsigned int col = 0)const override;
 71
 72
 73  const SparseCoordinateMat getSparseCoordinate(unsigned int row = 0, unsigned int col = 0)const override;
 74
 75
 76  const ZeroMat getZero(unsigned int row = 0, unsigned int col = 0) const override;
 77
 78
 79  const IdentityMat getIdentity(unsigned int row = 0, unsigned int col = 0) const override;
 80
 81
 82  DenseMat* dense(unsigned int row = 0, unsigned int col = 0)const override;
 83
 84
 85  TriangMat* triang(unsigned int row = 0, unsigned int col = 0)const override;
 86
 87
 88  SymMat* sym(unsigned int row = 0, unsigned int col = 0)const override;
 89
 90
 91  BandedMat* banded(unsigned int row = 0, unsigned int col = 0)const override;
 92
 93
 94  SparseMat* sparse(unsigned int row = 0, unsigned int col = 0)const override;
 95
 96
 97  SparseCoordinateMat* sparseCoordinate(unsigned int row = 0, unsigned int col = 0)const override;
 98
 99
100  ZeroMat* zero_mat(unsigned int row = 0, unsigned int col = 0) const override;
101
102
103  IdentityMat* identity(unsigned int row = 0, unsigned int col = 0) const override;
104
105
106  double* getArray(unsigned int row = 0, unsigned int col = 0) const override;
107
108
109  void zero() override;
110
111
112  void randomize() override;
113
114
115  void eye() override;
116
117
118  unsigned int size(unsigned int index) const override;
119
120
121  void resize(unsigned int nbrow, unsigned int nbcol, unsigned int lower = 0,
122              unsigned int upper = 0, bool b = true) override;
123
124
125  double normInf() const override;
126
127
128  void display() const override;
129
130
131  void displayExpert(bool brief = true) const override;
132
133
134  std::string toString() const override;
135
136
137  friend std::ostream& operator<<(std::ostream& os, const BlockMatrix& bm) ;
138
139
140  double& operator()(unsigned int i, unsigned int j) override;
141
142
143  double operator()(unsigned int i, unsigned int j) const override;
144
145
146  double getValue(unsigned int i, unsigned int j) const override;
147
148
149  void setValue(unsigned int i, unsigned int j, double value) override;
150
151
152  void trans() override;
153
154
155  void trans(const SiconosMatrix& m) override;
156
157
158  inline Index getTabRow() const
159  {
160    return *_tabRow;
161  };
162
163
164  inline Index getTabCol() const
165  {
166    return *_tabCol;
167  };
168
169
170  inline const SP::Index tabRow() const override
171  {
172    return _tabRow;
173  };
174
175
176  inline const SP::Index tabCol() const override
177  {
178    return _tabCol;
179  };
180
181
182  SP::SiconosMatrix block(unsigned int row = 0, unsigned int col = 0) override;
183
184
185  SPC::SiconosMatrix block(unsigned int row = 0, unsigned int col = 0) const override;
186
187
188  void  getRow(unsigned int r, SiconosVector& v) const override;
189
190
191  void  setRow(unsigned int r, const SiconosVector& v) override;
192
193
194  void  getCol(unsigned int c, SiconosVector& v) const override;
195
196
197  void  setCol(unsigned int c, const SiconosVector& v) override;
198
199
200  void addSimple(unsigned int& i, unsigned int& j, const SiconosMatrix& m);
201
202
203  void subSimple(unsigned int& i, unsigned int& j, const SiconosMatrix& m);
204
205
206  BlockMatrix& operator = (const SiconosMatrix& m) override;
207
208
209  BlockMatrix& operator = (const BlockMatrix& m);
210
211
212  BlockMatrix& operator = (const DenseMat& m) override;
213
214
215  BlockMatrix& operator +=(const SiconosMatrix& m) override;
216
217
218  BlockMatrix& operator -=(const SiconosMatrix& m) override;
219
220
221  void updateNumericsMatrix() override
222  {
223    THROW_EXCEPTION("BlockMatrix::updateNumericsMatrix(), not implemented fro BlockMatrix");
224  };
225
226
227
228  void PLUFactorizationInPlace() override;
229
230  void Factorize() override;
231
232
233
234  void PLUInverseInPlace() override;
235
236
237  void PLUForwardBackwardInPlace(SiconosMatrix &B) override;
238  void Solve(SiconosMatrix &B) override;
239
240
241
242  void PLUForwardBackwardInPlace(SiconosVector &B) override;
243  void Solve(SiconosVector &B) override;
244
245  ACCEPT_STD_VISITORS();
246
247  friend class SimpleMatrix;
248  friend void scal(double, const SiconosMatrix&, SiconosMatrix&, bool);
249  friend SiconosMatrix& operator *=(SiconosMatrix& m, const double& s);
250  friend SiconosMatrix& operator /=(SiconosMatrix& m, const double& s);
251
252
253  virtual size_t nnz(double tol = 1.e-14) override;
254};
255
256
257
258#endif