C++ main module for emicrom Package  1.0
EMM_BlockMassMatrix.h
Go to the documentation of this file.
1 #ifndef EMM_BlockMassMatrix_H
2 #define EMM_BlockMassMatrix_H
3 
4 //interface class
5 #include "EMM_MassMatrix.h"
6 
7 //matrix inheritance : mask vector not used
8 #include "MATH_Matrix.h"
9 #include "MATH_ArrayVector.h"
10 
11 //field
12 #include "EMM_RealField.h"
13 
26 class EMM_BlockMassMatrix : public virtual EMM_MassMatrix, public virtual MATH_Matrix {
27 
29  // ATTRIBUTES
30 public:
31 
32 
33 
34 private:
35 
36  //for solveib A.Y=B with work vector W
37  SP::MATH_Vector mW,mY,mB;
38 
39 protected:
40  // METHODS
41 
42  // CONSTRUCTORS
43 
46  EMM_BlockMassMatrix(void);
47 
48 
49 
50  // DESTRUCTORS
51 
52 
55  virtual ~EMM_BlockMassMatrix(void);
56 
57 public:
58 
62  virtual SP::MATH_Matrix NewInstance() const {
63  return New();
64  }
65 
69  inline static SP::EMM_BlockMassMatrix New() {
70  SP::EMM_BlockMassMatrix p(new EMM_BlockMassMatrix(),
72  p->setThis(p);
73  return p;
74  };
75 
76  // SET methods
77 
78 public:
79 
84  virtual void setSize(const tUIndex& nRows,const tUIndex& nCols) {
86  mW->setSize(nRows*getBlockSize());
87  }
88 
89 
90 
91  // GET methods
95  virtual tUIndex getRowsNumber() const {
97  }
101  virtual tUIndex getColumnsNumber() const {
103  }
104 
105 public:
106 
115  virtual tULLInt getMemorySize() const {
116  return EMM_MassMatrix::getMemorySize()+mW->getMemorySize()+mB->getMemorySize()+mY->getMemorySize();
117  }
118 
119 
120 public:
123  virtual tBoolean isSymmetric() const {
124  SP::MATH_ArrayVector W=MATH_ArrayVector::New();
125  return MATH_Matrix::isSymmetric(1.e-12,*W.get());
126  }
127 
128 protected:
138  virtual void product(const tUIndex& n,
139  const tReal& alpha,
140  const tUSInt& incX,
141  const tReal* x,
142  const tReal& beta,
143  const tUSInt& incY,tReal* y) const {
144  product(n,incX,alpha,x,beta,y);
145  }
146 
147 
148 private:
149 
158  void product(const tUIndex& n,
159  const tDimension& dim,
160  const tReal& alpha,
161  const tReal* x,
162  const tReal& beta,
163  tReal* y) const;
164 
165 
166 
167 
168 private:
177  tReal symmetricDot(const tUIndex& n,
178  const tDimension& dim,
179  const tReal* x,
180  const tReal* y) const;
181 
191  tReal symmetricDot(const tUIndex& n,
192  const tDimension& dim,
193  const tReal* D,
194  const tReal* x,
195  const tReal* y) const;
196 
197 
198 public:
199 
208  virtual tBoolean solve(MATH_Solver& solver,EMM_RealField& B);
209 
216  virtual void product(const tReal& alpha,const MATH_Vector& x,const tReal& beta, MATH_Vector& y) const {
217 
218  //verify the size of X
219  tUIndex nX=x.getSize();
220  if (nX!=getColumnsNumber())
221  throw CORE_Exception("emicrom/math/solver",
222  "EMM_BlockMassMatrix::product(beta,X,alpha,Y)",
223  "error in dimension of vector X "+CORE_Integer::toString(nX)+" != "+
225 
226  //verify the size of B = size of X
227  tUIndex nY=y.getSize();
228  if (nY!=getRowsNumber())
229  throw CORE_Exception("emicrom/math/solver",
230  "EMM_BlockMassMatrix::product(beta,X,alpha,Y)",
231  "error in dimension of vector Y "+CORE_Integer::toString(nY)+" != "+
233 
234 
235 
236 
237  //compute the product
238  product(nX/3,3,alpha,&x[0],beta,&y[0]);
239  }
240 
248  virtual void product(const tReal& alpha,const MATH_Vector& x,MATH_Vector& y) const {
249 
250 
251  //set the size of y
252  y.setSize(getRowsNumber());
253 
254  //verify the size of X
255  tUIndex nX=x.getSize();
256  if (nX!=getColumnsNumber())
257  throw CORE_Exception("emicrom/math/solver",
258  "EMM_BlockMatrix::product(beta,X,Y)",
259  "error in dimension of vector X "+CORE_Integer::toString(nX)+" != "+
261 
262 
263 
264 
265  //compute the product
266  product(nX/3,3,alpha,&x[0],0.,&y[0]);
267 
268  }
269 
274  virtual void product(const MATH_Vector& x,MATH_Vector& y) const {
275  //verify the size of X
276  tUIndex nX=x.getSize();
277  if (nX!=getColumnsNumber())
278  throw CORE_Exception("emicrom/math/solver",
279  "EMM_BlockMassMatrix::product(X,Y)",
280  "error in dimension of vector X "+CORE_Integer::toString(nX)+" != "+
282  //set the size of y
283  y.setSize(getRowsNumber());
284 
285 
286 
287  //compute the product
288  product(nX/3,3,1.,&x[0],0.,&y[0]);
289 
290  }
291 
298  virtual void product(const tReal& alpha,const EMM_RealField& X,
299  const tReal& beta,EMM_RealField& Y) const;
300 
301 
302 
303 
307  virtual tReal symmetricDot(const EMM_RealField& X) const;
308 
313  virtual tReal symmetricDot(const EMM_RealArray& W,const EMM_RealField& X) const;
314 
315 
319  virtual tString toString() const;
320 
321 
322 
323 
324 };
325 
326 #endif
SP::MATH_Vector mB
Definition: EMM_BlockMassMatrix.h:37
virtual ~EMM_BlockMassMatrix(void)
destroy
Definition: EMM_BlockMassMatrix.cpp:43
static SP::EMM_BlockMassMatrix New()
create a mass matrix
Definition: EMM_BlockMassMatrix.h:69
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: EMM_BlockMassMatrix.h:115
virtual tUIndex getColumnsNumber() const
get the columns number of the matrix
Definition: EMM_BlockMassMatrix.h:101
static const tDimension Y
Definition: EMM_Object.h:34
SP::MATH_Vector mY
Definition: EMM_BlockMassMatrix.h:37
virtual void product(const tReal &alpha, const MATH_Vector &x, MATH_Vector &y) const
Y=alpha.T.x where T is this.
Definition: EMM_BlockMassMatrix.h:248
This class describes a general matrix interface used in solver.
Definition: MATH_Matrix.h:20
static const tDimension X
Definition: EMM_Object.h:33
virtual void product(const tUIndex &n, const tReal &alpha, const tUSInt &incX, const tReal *x, const tReal &beta, const tUSInt &incY, tReal *y) const
y:=alpha T . x +beta y where T is this
Definition: EMM_BlockMassMatrix.h:138
tReal symmetricDot(const tUIndex &n, const tDimension &dim, const tReal *x, const tReal *y) const
Definition: EMM_BlockMassMatrix.cpp:90
#define tUSInt
Definition: types.h:28
#define tBoolean
Definition: types.h:139
virtual void setSize(const tUIndex &nRows, const tUIndex &nCols)
set the size of the matrix
Definition: EMM_MassMatrix.h:110
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
virtual tBoolean solve(MATH_Solver &solver, EMM_RealField &B)
sole AX=B thanks to the solver
Definition: EMM_BlockMassMatrix.cpp:950
#define tDimension
Definition: EMM_Types.h:10
virtual void product(const MATH_Vector &x, MATH_Vector &y) const
b=T.x where T is this
Definition: EMM_BlockMassMatrix.h:274
EMM_BlockMassMatrix(void)
create
Definition: EMM_BlockMassMatrix.cpp:11
virtual tString toString() const
return the string representatio of the class
Definition: EMM_BlockMassMatrix.cpp:992
virtual SP::MATH_Matrix NewInstance() const
return a share pointer to a new instance of this
Definition: EMM_BlockMassMatrix.h:62
virtual tUIndex getColumnsNumber() const
get the columns number of the matrix
Definition: EMM_MassMatrix.h:204
virtual void product(const tReal &alpha, const MATH_Vector &x, const tReal &beta, MATH_Vector &y) const
y:=alpha. T . x + beta y where T is this
Definition: EMM_BlockMassMatrix.h:216
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
SP_OBJECT(EMM_BlockMassMatrix)
This interface class describes the mass matrix where is the Q1 function with is 1 on the point i an...
Definition: EMM_MassMatrix.h:23
SP::MATH_Vector mW
Definition: EMM_BlockMassMatrix.h:37
virtual void setSize(const tUIndex &nRows, const tUIndex &nCols)
set the number of points in all directions
Definition: EMM_BlockMassMatrix.h:84
DEFINE_SVPTR(EMM_BlockMassMatrix)
This class describes a masked vector.
Definition: MATH_Vector.h:16
virtual tUIndex getRowsNumber() const
get the rows number of the matrix
Definition: EMM_BlockMassMatrix.h:95
tBoolean isSymmetric(const tReal &eps, const MATH_Vector &w) const
return true if the matrix is symmetric
Definition: MATH_Matrix.cpp:5
virtual tUIndex getSize() const =0
get the utile size of the vector
#define tUIndex
Definition: types.h:126
This class describes a real array.
Definition: EMM_RealArray.h:16
virtual void setSize(const tUIndex &n)=0
set the size of the vector
This class describes a solver of Ax=b.
Definition: MATH_Solver.h:18
static SP::MATH_ArrayVector New()
return a share pointer of a vector based on CORE_RealArray
Definition: MATH_ArrayVector.h:45
virtual tBoolean isSymmetric() const
return true if the matrix is symmetric
Definition: EMM_BlockMassMatrix.h:123
#define tString
Definition: types.h:135
const tUSInt & getBlockSize() const
get the block size
Definition: EMM_MassMatrix.h:158
#define tULLInt
Definition: types.h:45
This class describes a real field.
Definition: EMM_RealField.h:21
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: EMM_MassMatrix.h:169
This class describes the mass matrix where is the Q1 function which is 1 on the point i and 0 other...
Definition: EMM_BlockMassMatrix.h:26
#define tReal
Definition: types.h:118
DEFINE_SPTR(EMM_BlockMassMatrix)
virtual tUIndex getRowsNumber() const
get the rows number of the matrix
Definition: EMM_MassMatrix.h:198
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141