8 #ifndef _ISSM_SEQ_VEC_H_
9 #define _ISSM_SEQ_VEC_H_
16 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
19 #include "../../shared/shared.h"
30 template <
class doubletype>
49 if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
56 if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
63 if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
71 this->vector=xNew<doubletype>(pM);
72 xMemCpy<doubletype>(this->vector,buffer,pM);
77 if(this->M)xDelete<doubletype>(this->vector);
86 _printf_(
"IssmSeqVec size " << this->M <<
"\n");
103 for(i=0;i<ssize;i++) this->vector[list[i]]+=values[i];
106 for(i=0;i<ssize;i++) this->vector[list[i]]=values[i];
109 _error_(
"unknown insert mode!");
119 this->vector[dof]+=value;
122 this->vector[dof]=value;
125 _error_(
"unknown insert mode!");
132 *pvalue=this->vector[dof];
157 int* indices=xNew<int>(vector_size);
158 for(
int i=0;i<vector_size;i++) indices[i]=i;
161 doubletype* values =xNew<doubletype>(vector_size);
162 xMemCpy<doubletype>(values,this->vector,vector_size);
173 void Set(doubletype value){
175 for(
int i=0;i<this->
M;i++)this->vector[i]=value;
189 for(i=0;i<this->
M;i++)this->vector[i]=a*X->
vector[i]+this->vector[i];
203 for(i=0;i<this->
M;i++)this->vector[i]=X->
vector[i]+a*this->vector[i];
209 doubletype* buffer=NULL;
212 buffer=xNew<doubletype>(this->M);
213 xMemCpy<doubletype>(buffer,this->vector,this->M);
227 for(
int i=0;i<this->
M;i++)this->vector[i]+=shift;
241 for(i=0;i<this->
M;i++)to->
vector[i]=this->vector[i];
252 norm=0.;
for(i=0;i<this->
M;i++)norm=
max(norm,fabs(this->vector[i]));
258 for(i=0;i<this->
M;i++)norm+=this->vector[i]*this->vector[i];
267 void Scale(doubletype scale_factor){
270 for(i=0;i<this->
M;i++)this->vector[i]=scale_factor*this->vector[i];
284 for(i=0;i<this->
M;i++)dot+=this->vector[i]*input->
vector[i];
301 for(i=0;i<this->
M;i++)this->vector[i]=x->
vector[i]/y->
vector[i];
305 #endif //#ifndef _ISSM_SEQ_VEC_H_