C++ main module for mmsd Package  1.0
LAP_DoubleBandedStorage.h
Go to the documentation of this file.
1 #ifndef LAP_DoubleBandedStorage_H
2 #define LAP_DoubleBandedStorage_H
3 
5 
6 DEFINE_SPTR(LAP_DoubleBandMatrix);
7 
25 
26  SP_OBJECT(LAP_DoubleBandedStorage);
27 
28 private:
29  // ATTRIBUTES
30 
31 
32 
33  //number of bands on the upper matrix, diagonal is included
34  tLVectorIndex mUBandsNumber;
35  //number of bands on the lower matrix, diagonal is included
36  tLVectorIndex mLBandsNumber;
37  //number of bands = mUBandsNumber+mLBandsNumber-1
38  tLVectorIndex mBandsNumber;
39 
40  // ASSOCIATIONS
41  // METHOD
42 
43 
44 public:
45  // CONSTRUCTORS
48 
49  mUBandsNumber=0;
50  mLBandsNumber=1;
51  mBandsNumber=mUBandsNumber+mLBandsNumber-1;
52  }
53 
54  // DESTRUCTORS
58  }
59 
60 
61 
62  // -------------
63  // NEW METHODS
64  // -------------
65 public:
68  inline static SP::LAP_DoubleBandedStorage New() {
69  SP::LAP_DoubleBandedStorage p(new LAP_DoubleBandedStorage(),
71  p->setThis(p);
72  return p;
73  };
74 
75  //-----------
76  // OPERATORS
77  // ----------
78 
82  virtual double& operator()(const tLVectorIndex& i,const tLVectorIndex& j) {
83  //AB(Ku+i-j,j) K=mUBandsNumber-1
84  return ( (j>=i+mUBandsNumber) || (j+mLBandsNumber<=i) )? getNullValue():(*this)[mUBandsNumber-1+(i-j)+mBandsNumber*j];
85  };
86 
90  virtual const double& operator()(const tLVectorIndex& i,const tLVectorIndex& j) const {
91  return ( (j>=i+mUBandsNumber) || (j+mLBandsNumber<=i) )? getNullValue():(*this)[mUBandsNumber-1+(i-j)+mBandsNumber*j];
92  };
93 
94 
95 
96  //scalar operators
97  //================
101 
108 
112 
113 
117 
118 
119  //full matrix operator
120  //===============================
121 
128 
135 
138  inline void add(const double& alpha, const LAP_DoubleBandedStorage& B) {
139  add(alpha,
140  B.getValuesNumber(),
143  &B[0]);
144  }
145 private:
148  void add(const double& alpha,
149  const tLVectorIndex& nX,
150  const tLVectorIndex& ux,
151  const tLVectorIndex& lx,
152  const double *x);
153 
154 
155  // ----------------
156  // MATRIX SETTINGS
157  // ----------------
158 
159 public:
163  virtual tBoolean copy(const tBoolean& isSymmetric,
164  const tBoolean& isUpper,
165  const tBoolean& isTransposed,
166  const LAP_DoubleMatrixStorage& x);
167 
168 
171  tBoolean copyFullStorage(const tBoolean& isSymmetric,
172  const tBoolean& isUpper,
173  const tBoolean& isTransposed,
174  const tLVectorIndex& nViewedRows,
175  const tLVectorIndex& nViewedCols,
176  const tLVectorIncrement& incx,
177  const tLVectorIndex& ldx,
178  const double* x);
182  const double* x);
183 
187  const tLVectorIndex& nUBands,
188  const tLVectorIndex& nLBands,
189  const double* x);
190 
191 
192  //dimension setting
193  //=================
194 
197  inline void setUpperBandsNumber(const tLVectorIndex& n) {
198  mUBandsNumber=n;
199  mBandsNumber= mUBandsNumber+mLBandsNumber-1;
200  }
203  inline void setLowerBandsNumber(const tLVectorIndex& n) {
204  mLBandsNumber=n;
205  mBandsNumber= mUBandsNumber+mLBandsNumber-1;
206  }
209  inline const tLVectorIndex& setBandsNumber(const tLVectorIndex& u,const tLVectorIndex& l) {
210  mUBandsNumber=u;
211  mLBandsNumber=l;
212  mBandsNumber= mUBandsNumber+mLBandsNumber-1;
213  return mBandsNumber;
214  }
215 
218  tBoolean updateBandsNumber(const std::pair<tLVectorIndex,tLVectorIndex>& nBands);
219 
222  inline tBoolean compile() {
224  }
225 
226 
227 
229  //======
230 
233  pair<tLVectorIndex,tLVectorIndex> computeBandsNumber() const;
234 
237  inline const tLVectorIndex& getBandsNumber() const {
238  return mBandsNumber;
239  }
242  inline const tLVectorIndex& getUpperBandsNumber() const {
243  return mUBandsNumber;
244  }
247  inline const tLVectorIndex& getLowerBandsNumber() const {
248  return mLBandsNumber;
249  }
250 
251 
252 
253 
254  // ------------------------
255  // operation on matrix
256  // ------------------------
257 public:
258 
259 
260 
266  double max(const tFlag& d,const tLVectorIndex& index) const;
267 
272  void indexMin(tLVectorIndex& i,tLVectorIndex& j) const;
273 
276  virtual double trace() const;
277 
278 
279 
280 public:
283  virtual void addDiagonal(const double& alpha);
284 
285 
286 
287 
288 
289 };
290 #endif
virtual double & operator()(const tLVectorIndex &i, const tLVectorIndex &j)
accessor of element at row i and column j taking into account the view only use the upper diagonal ...
Definition: LAP_DoubleBandedStorage.h:82
tBoolean copyFullStorage(const tBoolean &isSymmetric, const tBoolean &isUpper, const tBoolean &isTransposed, const tLVectorIndex &nViewedRows, const tLVectorIndex &nViewedCols, const tLVectorIncrement &incx, const tLVectorIndex &ldx, const double *x)
copy the upper part of full array of size nRows*nCols
Definition: LAP_DoubleBandedStorage.cpp:45
LAP_DoubleBandedStorage()
build a matrix
Definition: LAP_DoubleBandedStorage.h:47
const tLVectorIndex & getLowerBandsNumber() const
get the lower bands number
Definition: LAP_DoubleBandedStorage.h:247
double & getNullValue()
get a null value
Definition: LAP_Object.h:54
virtual double trace() const
return trace
Definition: LAP_DoubleBandedStorage.cpp:1440
tBoolean compile()
compile the matrix to optimal bands number
Definition: LAP_DoubleBandedStorage.h:222
pair< tLVectorIndex, tLVectorIndex > computeBandsNumber() const
GET.
Definition: LAP_DoubleBandedStorage.cpp:380
double max(const tFlag &d, const tLVectorIndex &index) const
make get max among the direction if (d==ROW) max of all the columns of row index if (d==COL) max of a...
Definition: LAP_DoubleBandedStorage.cpp:1349
DEFINE_SPTR(LAP_DoubleBandMatrix)
void setLowerBandsNumber(const tLVectorIndex &n)
set lower bands number
Definition: LAP_DoubleBandedStorage.h:203
this class describes a banded storage for lapack used where values are stored in vector of size (nSBa...
Definition: LAP_DoubleBandedStorage.h:24
const tLVectorIndex & setBandsNumber(const tLVectorIndex &u, const tLVectorIndex &l)
set bands number
Definition: LAP_DoubleBandedStorage.h:209
LAP_DoubleBandedStorage & operator-=(const lapack_real &s)
sub s to the upper matrix viewed term by term taking into account the view
#define tBoolean
Definition: types.h:48
#define lapack_real
Definition: lapack_functions.h:9
const tLVectorIndex & getBandsNumber() const
get the bands number
Definition: LAP_DoubleBandedStorage.h:237
const tLVectorIndex & getUpperBandsNumber() const
get the upper bands number
Definition: LAP_DoubleBandedStorage.h:242
virtual ~LAP_DoubleBandedStorage()
destroy a matrix
Definition: LAP_DoubleBandedStorage.h:57
tBoolean copyPackStorage(const tLVectorIndex &nX, const double *x)
copy the packed array of memory nx such that nx=n*(n+1)/2 where n is the dimension of the vector stor...
Definition: LAP_DoubleBandedStorage.cpp:273
void add(const double &alpha, const LAP_DoubleBandedStorage &B)
This += alpha . B.
Definition: LAP_DoubleBandedStorage.h:138
static SP::LAP_DoubleBandedStorage New()
create a new banded storage class
Definition: LAP_DoubleBandedStorage.h:68
void indexMin(tLVectorIndex &i, tLVectorIndex &j) const
get the index of the min view element in absolute value
Definition: LAP_DoubleBandedStorage.cpp:1261
virtual void addDiagonal(const double &alpha)
This += alpha . I.
Definition: LAP_DoubleBandedStorage.cpp:1465
tLVectorIndex getValuesNumber() const
get the number of values
Definition: LAP_DoubleMatrixStorage.h:178
LAP_DoubleBandedStorage & operator*=(const lapack_real &s)
multiply by s the matrix viewed term by term taking into account the view
LAP_DoubleBandedStorage & operator/=(const lapack_real &s)
divide by s the matrix viewed term by term taking into account the view
#define tLVectorIndex
Definition: lapack_types.h:13
tBoolean updateBandsNumber(const std::pair< tLVectorIndex, tLVectorIndex > &nBands)
update the bands number
Definition: LAP_DoubleBandedStorage.cpp:448
LAP_DoubleBandedStorage & operator^=(const lapack_real &s)
power by s the matrix viewed term by term taking into account the view
Definition: LAP_DoubleBandedStorage.cpp:519
void setUpperBandsNumber(const tLVectorIndex &n)
set upper bands number
Definition: LAP_DoubleBandedStorage.h:197
#define tLVectorIncrement
Definition: lapack_types.h:16
LAP_DoubleBandedStorage & operator+=(const lapack_real &s)
add s to the upper matrix viewed term by term taking into account the view
tBoolean copyBandStorage(const tLVectorIndex &nX, const tLVectorIndex &nUBands, const tLVectorIndex &nLBands, const double *x)
copy the band array x of size nBands x nRow from the first row of the first column ...
Definition: LAP_DoubleBandedStorage.cpp:339
Definition: LAP_DoubleMatrixStorage.h:16
virtual const double & operator()(const tLVectorIndex &i, const tLVectorIndex &j) const
accessor of element at row i and column j taking into account the view only use the upper diagonal ...
Definition: LAP_DoubleBandedStorage.h:90
virtual tBoolean copy(const tBoolean &isSymmetric, const tBoolean &isUpper, const tBoolean &isTransposed, const LAP_DoubleMatrixStorage &x)
copy the storage
Definition: LAP_DoubleBandedStorage.cpp:11
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14