22 static const std::string s_v(
"tools::array");
26 typedef typename std::vector< std::pair<unsigned int,unsigned int> >
cut_t;
27 typedef typename std::vector<unsigned int>
uints_t;
28 typedef typename std::vector<T>::iterator
vec_it_t;
33 mem::increment(
s_class().c_str());
38 mem::increment(
s_class().c_str());
42 array(
unsigned int a_dimension,
unsigned int a_order) {
44 mem::increment(
s_class().c_str());
48 for(
unsigned int index=0;index<a_dimension;index++)
49 _orders[index] = a_order;
54 mem::decrement(
s_class().c_str());
64 mem::increment(
s_class().c_str());
77 return equal(a_array);
117 unsigned int _size = 1;
118 for(
size_t index=0;index<dim;index++) {
129 for(
size_t iaxis=1;iaxis<dim;iaxis++)
139 unsigned int off = 0;
140 if(!
offset(a_is,off))
return false;
145 unsigned int off = 0;
154 unsigned int off = 0;
163 bool fill(
const std::vector<T>& a_values,
cut_t* a_cut = 0) {
164 size_t dsize = a_values.size();
166 unsigned int index = 0;
168 if(!a_cut || (a_cut &&
accept(index,*a_cut)) ) {
169 if(di>=dsize)
return false;
176 bool fill(
unsigned int a_sz,
const T* a_data,
cut_t* a_cut = 0) {
178 unsigned int index = 0;
180 if(!a_cut || (a_cut &&
accept(index,*a_cut)) ) {
181 if(di>=a_sz)
return false;
193 for(;it!=
m_vector.end();++it,++ait) {
194 if((*it)!=(*ait))
return false;
202 for(;it!=
m_vector.end();++it,++ait) {
203 T
diff = (*it) - (*ait);
205 if(
diff>=aEpsilon)
return false;
216 for(;it!=
m_vector.end();++it,++ait) {
217 if( ((*it)==
zero()) && ((*ait)==
zero())) {
219 }
else if( ((*it)!=
zero()) && ((*ait)==
zero())) {
221 }
else if( ((*it)==
zero()) && ((*ait)!=
zero())) {
225 a_factor = (*ait)/(*it);
228 if((*ait)!=(*it)*a_factor)
return false;
238 unsigned int index = 0;
239 for(;it!=
m_vector.end();++it,++ait,index++) {
240 if(!a_cut || (a_cut &&
accept(index,*a_cut)) ) {
250 for(;it!=
m_vector.end();++it,++ait) (*it) -= (*ait);
257 for(;it!=
m_vector.end();++it,++ait) (*it) *= (*ait);
265 for(;it!=
m_vector.end();++it,++ait) {
280 for(;it!=
m_vector.end();++it,++ait) a_value += (*it) * (*ait);
285 unsigned int index = 0;
287 if(!a_cut || (a_cut &&
accept(index,*a_cut)) ) {
296 if(a_T==
zero())
return false;
309 (*it) = v_one/_value;
317 if(a_is.size()!=dim)
return false;
318 if(dim==0)
return false;
319 for(
size_t iaxis=0;iaxis<dim;iaxis++) {
320 unsigned int i = a_is[iaxis];
330 if(a_offset>=
m_vector.size())
return false;
332 unsigned int off = a_offset;
333 for(
int iaxis=
int(dim)-1;iaxis>=0;iaxis--) {
341 if(a_cut.size()!=dim)
return false;
344 for(
size_t iaxis=0;iaxis<dim;iaxis++) {
345 if(
m_is[iaxis]<a_cut[iaxis].first) {good =
false;
break;}
346 if(
m_is[iaxis]>a_cut[iaxis].second) {good =
false;
break;}
400 if(&aR==&aA)
return false;
401 if(&aR==&aB)
return false;
412 if((rdima+rdimb)==0) {
413 std::vector<unsigned int> rorders(1);
416 const std::vector<T>& vA = aA.
vector();
417 const std::vector<T>& vB = aB.
vector();
419 for(
unsigned int index=0;index<vA.size();index++) {
420 value += vA[index]*vB[index];
426 std::vector<unsigned int> rorders(rdima+rdimb);
428 for(index=0;index<aIA;index++)
429 rorders[index] = aA.
orders()[index];
430 for(index=aIA;index<rdima;index++)
431 rorders[index] = aA.
orders()[index+1];
433 for(index=0;index<aIB;index++)
434 rorders[rdima+index] = aB.
orders()[index];
435 for(index=aIB;index<rdimb;index++)
436 rorders[rdima+index] = aB.
orders()[index+1];
440 std::vector<unsigned int> ais(aA.
dimension());
441 std::vector<unsigned int> bis(aB.
dimension());
442 std::vector<unsigned int> ris(aR.
dimension());
445 unsigned int order = aA.
orders()[aIA];
446 unsigned int rsize = aR.
size();
448 std::vector<T>& rvec = aR.
vector();
450 for(
unsigned int roffset=0;roffset<rsize;roffset++) {
451 if(!aR.
indices(roffset,ris))
return false;
453 for(index=0;index<aIA;index++) ais[index] = ris[index];
454 for(index=aIA;index<rdima;index++) ais[index+1] = ris[index];
456 for(index=0;index<aIB;index++) bis[index] = ris[rdima+index];
457 for(index=aIB;index<rdimb;index++) bis[index+1] = ris[rdima+index];
460 for(index=0;index<order;index++) {
463 if(!aA.
value(ais,av))
return false;
467 if(!aB.
value(bis,bv))
return false;
472 rvec[roffset] =
value;
485 if(&aR==&aV)
return false;
488 if(aI1>=dim)
return false;
489 if(aI2>=dim)
return false;
498 std::vector<unsigned int> vis(aV.
dimension());
499 std::vector<unsigned int> ris(aV.
dimension());
501 const std::vector<T>& vvec = aV.
vector();
504 for(
unsigned int offset=0;offset<
size;offset++) {
505 T
value = vvec[offset];
507 if(!aV.
indices(offset,vis))
return false;
508 unsigned int i = vis[aI1];
520 if(a_title.size()) a_out << a_title << std::endl;
521 const std::vector<T>& vec = a_array.
vector();
522 typedef typename std::vector<T>::const_iterator cons_vec_it_t;
523 for(cons_vec_it_t it = vec.begin();it!=vec.end();++it) {
524 a_out << (*it) << std::endl;
531 a_out <<
"tools::arrays::diff : not same orders" << std::endl;
534 bool header_done =
false;
536 std::vector<unsigned int>
is(dim);
537 unsigned int vsize = aA.
vector().size();
538 for(
unsigned int index=0;index<vsize;index++) {
541 if(
diff>=a_epsilon) {
544 a_out <<
"tools::arrays::diff :" << std::endl;
547 for(
unsigned int i=0;i<dim;i++) a_out <<
is[i] <<
" ";
548 a_out << aA.
vector()[index] <<
" " << aB.
vector()[index] << std::endl;
563 unsigned int index = 0;
564 typedef typename std::vector<unsigned int> _uints_t;
565 _uints_t
is(a_order);
567 typedef typename std::vector<T>::iterator _vec_it_t;
568 _vec_it_t it = vec.begin();
569 for(;it!=vec.end();++it,index++) {
572 {
for(
unsigned int iaxis=0;iaxis<a_order;iaxis++) {
573 unsigned int ival =
is[iaxis];
574 for(
unsigned int iaxis2=iaxis+1;iaxis2<a_order;iaxis2++) {
575 if(
is[iaxis2]==ival) {
585 for(
unsigned int iaxis=0;iaxis<a_order;) {
586 unsigned int ival =
is[iaxis];
589 unsigned int old =
is[ival];
597 {
unsigned int n_2 = n/2;