Program listing for file kernel/src/simulationTools/BlockCSRMatrix.hpp#
Return to documentation for this file
1#ifndef BLOCKCSRMATRIX_H
2#define BLOCKCSRMATRIX_H
3
4#include "NumericsFwd.h"
5#include "SiconosSerialization.hpp"
6#include "SimulationTypeDef.hpp"
7
8#include <boost/numeric/ublas/fwd.hpp>
9
10
11
12typedef boost::numeric::ublas::compressed_matrix<
13 double *, boost::numeric::ublas::basic_row_major<unsigned int>, 0,
14 boost::numeric::ublas::unbounded_array<std::size_t>>
15 CompressedRowMat;
16TYPEDEF_SPTR(CompressedRowMat)
17TYPEDEF_SPTR(SparseBlockStructuredMatrix)
18
19
20class BlockCSRMatrix {
21private:
22
23 ACCEPT_SERIALIZATION(BlockCSRMatrix);
24
25
26 unsigned int _nr;
27
28
29 unsigned int _nc;
30
31
32 SP::CompressedRowMat _blockCSR;
33
34
35 SP::SparseBlockStructuredMatrix _sparseBlockStructuredMatrix;
36
37
38 SP::IndexInt _diagsize0;
39
40
41 SP::IndexInt _diagsize1;
42
43
44 SP::IndexInt rowPos;
45
46
47 SP::IndexInt colPos;
48
49
50 BlockCSRMatrix(const BlockCSRMatrix &);
51
52
53 BlockCSRMatrix &operator=(const BlockCSRMatrix &);
54
55public:
56
57 BlockCSRMatrix();
58
59
60 BlockCSRMatrix(unsigned int n);
61
62
63 BlockCSRMatrix(InteractionsGraph &indexSet);
64
65
66 ~BlockCSRMatrix();
67
68
69 inline unsigned int numberOfBlocksInARow() const { return _nr; };
70
71
72 unsigned int getNbNonNullBlocks() const;
73
74
75 inline SP::SparseBlockStructuredMatrix getNumericsMatSparse()
76 {
77 return _sparseBlockStructuredMatrix;
78 };
79
80
81 inline SP::CompressedRowMat getMSparse() { return _blockCSR; };
82
83
84 IndexInt::value_type getSizeOfDiagonalBlock(int i) const
85 {
86 if (i == 0)
87 return _diagsize0->at(0);
88 else
89 return (_diagsize0->at(i) - _diagsize0->at(i - 1));
90 };
91
92
93 inline SP::IndexInt getPositionsIndex(bool i)
94 {
95 if (i)
96 return rowPos;
97 else
98 return colPos;
99 };
100
101
102 void fill(InteractionsGraph &indexSet);
103
104
105 void fillW(InteractionsGraph &indexSet);
106
107
108 void fillH(InteractionsGraph &indexSet);
109
110
111 void convert();
112
113
114 void display() const;
115};
116
117#endif