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

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

  1#ifndef BLOCKVECTOR_H
  2#define BLOCKVECTOR_H
  3
  4#include "SiconosAlgebraTypeDef.hpp"
  5#include "SiconosSerialization.hpp"
  6
  7class SiconosVector;
  8
  9
 10class BlockVector
 11{
 12private:
 13
 14  ACCEPT_SERIALIZATION(BlockVector);
 15
 16
 17  unsigned int _sizeV = 0;
 18
 19
 20  VectorOfVectors _vect;
 21
 22
 23  SP::Index _tabIndex;
 24
 25
 26  void _update();
 27
 28public:
 29
 30
 31  BlockVector();
 32
 33
 34  BlockVector(const BlockVector& v);
 35
 36
 37  BlockVector(SP::SiconosVector v1, SP::SiconosVector v2);
 38
 39
 40  BlockVector(unsigned int numberOfBlocks, unsigned int dim);
 41
 42
 43  BlockVector(unsigned int numberOfBlocks);
 44
 45
 46  ~BlockVector(){};
 47
 48
 49  void setBlock(const SiconosVector& input, unsigned int size_block, unsigned int start_in, unsigned int start_out);
 50
 51
 52  unsigned int size() const
 53  {
 54    return _sizeV;
 55  };
 56
 57
 58
 59  inline VectorOfVectors::iterator begin()
 60  {
 61    return _vect.begin();
 62  };
 63
 64
 65  inline VectorOfVectors::iterator end()
 66  {
 67    return _vect.end();
 68  };
 69
 70
 71  inline VectorOfVectors::const_iterator begin() const
 72  {
 73    return _vect.begin();
 74  };
 75
 76
 77  inline VectorOfVectors::const_iterator end() const
 78  {
 79    return _vect.end();
 80  } ;
 81
 82
 83  inline VectorOfVectors getAllVect() const
 84  {
 85    return _vect;
 86  }
 87
 88
 89  inline Index::size_type numberOfBlocks() const
 90  {
 91    return _tabIndex->size();
 92  };
 93
 94
 95  bool isDense() const;
 96
 97
 98  void zero();
 99
100
101  void fill(double a);
102
103
104  void display(void) const;
105
106
107  std::string toString() const;
108
109
110  double getValue(unsigned int i) const;
111
112
113  void setValue(unsigned int i, double value);
114
115
116  double& operator()(unsigned int i) ;
117
118
119  double operator()(unsigned int i) const;
120
121
122  inline SP::SiconosVector vector(unsigned int pos)
123  {
124    return _vect[pos];
125  };
126
127
128  inline SPC::SiconosVector vector(unsigned int pos) const
129  {
130    return _vect[pos];
131  };
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146  void setVector(unsigned int pos, const SiconosVector& v);
147
148
149  void setVectorPtr(unsigned int pos, SP::SiconosVector v);
150
151
152  void setAllVect(VectorOfVectors& v);
153
154
155  inline const SP::Index tabIndex() const
156  {
157    return _tabIndex;
158  }
159
160
161  unsigned int getNumVectorAtPos(unsigned int pos) const;
162
163
164  BlockVector& operator =(const BlockVector& vIn);
165
166
167  BlockVector& operator = (const double* data);
168
169
170  BlockVector& operator =(const SiconosVector& vIn);
171
172
173  BlockVector& operator -=(const BlockVector& vIn);
174
175
176  BlockVector& operator +=(const BlockVector&);
177
178
179  BlockVector& operator += (const SiconosVector& vIn);
180
181
182  BlockVector& operator -= (const SiconosVector& vIn);
183
184
185  BlockVector& operator *= (double s);
186
187
188  BlockVector& operator /= (double s);
189
190
191
192
193
194
195
196  void insertPtr(SP::SiconosVector v);
197
198
199  double norm2() const;
200
201
202  double normInf() const;
203
204
205  SP::SiconosVector prepareVectorForPlugin() const;
206
207
208
209
210  friend std::ostream& operator<<(std::ostream& os, const BlockVector& bv);
211
212
213
214  ACCEPT_NONVIRTUAL_VISITORS();
215
216};
217
218#endif