C++ mpi module for stochmagnet_main Package
SM_PackedBlockSymmetricMatrix.hpp
1 #ifndef SM_PackedBlockSymmetricMatrix_HPP
2 #define SM_PackedBlockSymmetricMatrix_HPP
3 
4 template<typename T,tUCInt P>
5 void SM_PackedBlockSymmetricMatrix<T,P>::vectorProduct(const T* vX,T* vY) const {
6 
7  const tIndex &N=this->getRowBlocksNumber();
8 
9  //vY=0
10  memset(vY,0,sizeof(T)*P*N);
11 
12 
13  //diagonla values
14  const T* vD=&this->getDiagonalValues()[0];
15 
16  //iterator on block
17  const T* vB=&this->getSupBlocksValues()[0];
18 
19 
20 
21 
22  //work indices of element in block of size PxP
23  //tUCInt i=0,j=0;
24  //tUCInt incB=0;//increment on block
25  //const T* iXj=null;//iterator of Xj inside block
26 
27  //iterator on X
28  const T* Xj=0;
29 
30 
31  //indices of block
32  tIndex ib=0,jb=0;
33 
34  //iterator on diagonal values
35  const T* Di=vD;
36 
37  //iterator on block
38  const T* Bij=vB;
39 
40  //block at row 0 and column ib
41  const T* B0i=Bij;
42 
43  //increment of block for next column
44  tIndex incBij=0;
45 
46 
47  //Y values at block start
48  T* Yi_d,*Yi=vY;
49  T* eYi=Yi;eYi+=P;
50 
51  //work pointers
52  T* w1=null,*w2=null,*w3=null,*w4=null;
53 
54  for (ib=0;ib<N;ib++) {//row index of the block
55 
56 
57  //Yi+=Bij.Xj
58  Xj=vX;
59 
60  //Yi_x=&Yi[0];
61  //Yi_y=&Yi[1];
62  //Yi_z=&Yi[2];
63 
64  Bij=B0i;
65  for (jb=0;jb<ib;jb++) {//column index of the block
66 
67  //Block product Yi + =B_ij . X_j
68  //BlockVectorProduct(Bij,Xj,Yi,
69  // i,j,incB,iXj);
70  //Xj_x=Xj[0];
71  //Xj_y=Xj[1];
72  //Xj_z=Xj[2];
73  //BlockVectorProduct(Bij,Xj_x,Xj_y,Xj_z,*Yi_x,*Yi_y,*Yi_z);
74 
76 
77  //iterators at block at next row
79 
80  Xj+=P;
81 
82  }//end loop on column index < i index
83 
84 
85  //diagonal term
86  //jb=ib Yi+=Di.Xi
87  Yi_d=Yi;
88  while (Yi_d!=eYi) {
89  (*Yi_d)+=(*Di)*(*Xj);
90  Yi_d++;
91  Xj++;
92  }
93  Di++;
94 
95  //jb>ib : jb=ib+1;
96  jb=ib;jb++;
97  //block for next column
98  B0i=Bij;
99  //jb-th block of next colum
100  incBij=ib;
102  Bij+=incBij;
103  while (jb<N) {//column index of the block
104 
105  //Block product
106 
108 
109 
110  //next block for X
111  Xj+=P;
112 
113  //iterators to block at next column +=jb*BLOCK_SIZE
115  Bij+=incBij;
116 
117  //next column
118  jb++;
119  }//end loop on column index >= i index
120 
121  //Yi at next row block
122  Yi=eYi;
123  eYi+=P;
124 
125  }//end loop on row index
126 
127 }
128 
129 
130 
131 #endif
static void BlockVectorProduct(const T *B, const T *X, T *Y, const T *eY, const T *Xi, const T *Xj, T *Yi, T *Yj)
compute sthe vector product of the packed symmetric block B of dimension P by X to obtain Y=B....
Definition: SM_PackedBlockMatrix.h:188
This class described a symmetric matrix by block of size PxP in a packed storage.
Definition: SM_PackedBlockSymmetricMatrix.h:18
virtual void vectorProduct(const T *vX, T *vY) const
vector product
Definition: SM_PackedBlockSymmetricMatrix.hpp:5