C++ mpi module for stochmagnet_main Package
CORE_Field.h
1 #ifndef CORE_Field_H
2 #define CORE_Field_H
3 
4 //inherited class header
5 #include "CORE_Collection.h"
6 
7 //storage header
8 #include "CORE_Array.h"
9 
10 //file header
11 #include <fstream>
12 
13 //string functions headers
14 #include "functions_string.h"
15 
48 template <typename T,typename K,K D,class S,class I>
49 class CORE_Field : public CORE_Collection<T,I> {
50 
51 
52 private:
53 
54  //storage class of type T and with storage implementation S
55  S mStorage;
56 
57  //shorter class name
59 
60  // CONSTRUCTORS
61 protected:
65 
66  }
67 
68 
69  // DESTRUCTORS
72  virtual ~CORE_Field() {
73  }
74 
75 
76 public:
77 
78  //memory method
79  //=============
80 
88  virtual tMemSize getMemorySize() const override {
89  return sizeof(*this)+this->getContentsMemorySize();
90  }
91 
92 
93 
102  virtual tMemSize getContentsMemorySize() const override {
104  mem+=mStorage.getContentsMemorySize();
105  return mem;
106  }
107 
108 
109 
110 public:
111 
112 
113  //allocation methods
114  //===================
115 
121  inline void setElementsNumber(const tInteger& n) {
122  mStorage.setSize(n*D);
123  };
129  inline void fitToElementsNumber(const tInteger& n) {
130  mStorage.fitToSize(n*D);
131  };
135  inline tIndex getElementsNumber() const {
136  return mStorage.getSize()/D;
137  };
138 
144  inline void setSize(const tIndex& n) {
145  mStorage.setSize(D*(n/D));
146  };
147 
153  inline void resize(const tIndex& n) {
154  mStorage.resize(D*(n/D));
155  };
156 
157 
161  inline tIndex getSize() const {
162  return mStorage.getSize();
163  };
164 
165 
169  inline K getDimension() const {
170  return D;
171  }
172 
173  //accessor operators
174  //====================
175 
179  inline const T& operator[](const tIndex& i) const {
180  return mStorage[i];
181  };
185  inline T& operator[](const tIndex& i) {
186  return mStorage[i];
187  };
188 
189 
190 
195  inline const T& operator()(const tInteger& i,const K& d) const {
196  return mStorage[D*i+d];
197  };
202  inline T& operator()(const tInteger& i,const K d) {
203  return mStorage[D*i+d];
204  };
205 
209  inline const T* operator()(const tInteger& i) const {
210  return &mStorage[D*i];
211  };
215  inline T* operator()(const tInteger& i) {
216  return &mStorage[D*i];
217  };
218 
219  //accessor iterator
220  //==================
224  inline constexpr auto cbegin() const {
225  return getStorage().cbegin();
226  }
230  inline constexpr auto cend() const {
231  return getStorage().cend();
232  }
236  inline auto begin() {
237  return getStorage().begin();
238  }
242  inline auto end() {
243  return getStorage().end();
244  }
245 
249  inline auto rbegin() {
250  return getStorage().rbegin();
251  }
255  inline auto rend() {
256  return getStorage().rend();
257  }
258 
262  inline constexpr auto crbegin() const {
263  return getStorage().crbegin();
264  }
268  inline constexpr auto crend() const {
269  return getStorage().crend();
270  }
271 
272 
276  inline auto sbegin() {
277  return CORE_StrideIterator<T*,D>(&mStorage[0]);
278  }
282  inline auto send() {
283  return CORE_StrideIterator<T*,D>(&mStorage[0]+mStorage.getSize());
284  }
285 
289  inline constexpr auto csbegin() const {
290  return CORE_ConstantStrideIterator<const T*,D>(&mStorage[0]);
291  }
295  inline constexpr auto csend() const {
296  return CORE_ConstantStrideIterator<const T*,D>(&mStorage[0]+mStorage.getSize());
297  }
298 
299 
300 
301  //accessor methods
302  //==================
303 
308  inline const T& get(const tIndex& i,const K& d) const {
309  return mStorage[i*D+d];
310  };
315  inline T& get(const tIndex& i,const K& d) {
316  return mStorage[i*D+d];
317  }
318 
319 
323  inline const T* getValues() const {
324  return mStorage.getValues();
325  }
329  inline T* getValues() {
330  return mStorage.getValues();
331  }
332 
336  inline const S& getStorage() const {
337  return mStorage;
338  }
342  inline S& getStorage() {
343  return mStorage;
344  }
345 
346  //assignment operators
347  //====================
351  inline Self& operator=(const T& v) {
352  initialize(v);
353  return *this;
354  }
358  inline Self& operator=(const std::initializer_list<T>& values) {
359  mStorage.copy(D*(values.size()/D),values);
360  return *this;
361  }
365  inline Self& operator=(std::initializer_list<T>&& values) {
366  mStorage.copy(D*(values.size()/D),values);
367  return *this;
368  }
369 
373  template<size_t N,typename Q>
374  inline Self& operator=(const std::array<Q,N>& values) {
375  mStorage.copy(D*(N/D),values);
376  return *this;
377  }
378 
382  template<typename Q>
383  inline Self& operator=(const std::array<Q,D>& values) {
384  this->copy(values);
385  return *this;
386  }
387 
391  template<typename Q>
392  inline Self& operator=(const std::valarray<Q>& values) {
393  mStorage.copy(D*(values.size()/D),values);
394  return *this;
395  }
396 
400  template<typename Q>
401  inline Self& operator=(const std::vector<Q>& values) {
402  mStorage.copy(D*(values.size()/D),values);
403  return *this;
404  }
408  inline Self& operator=(const Self& cpy) {
409  mStorage.copy(cpy.getStorage());
410  return *this;
411  }
415  inline Self& operator=(Self&& cpy) {
416  mStorage.copy(cpy.getStorage());
417  return *this;
418  }
422  template<typename Q,class S1,class I1>
423  inline Self& operator=(const CORE_Field<Q,K,D,S1,I1>& cpy) {
424  mStorage.copy(cpy.getStorage());
425  return *this;
426  }
430  template<typename Q,class S1,class I1>
432  mStorage.copy(cpy.getStorage());
433  return *this;
434  }
435 
436  //copy methods
437  //============
438 public:
439 
440 
441 
446  template<typename Q>
447  inline void copy(const tIndex& n , const Q* vs) {
448  mStorage.copy(D*(n/D),vs);
449  }
450 
451 
455  template<typename Q,size_t N>
456  inline void copy(const std::array<Q,N>& vs) {
457  mStorage.copy(D*(vs.size()/D),vs);
458  }
459 
460 
464  template<typename Q>
465  inline void copy(const std::array<Q,D>& vs) {
466  initialize(vs);
467  }
468 
472  template<typename Q>
473  inline void copy(const std::valarray<Q>& vs) {
474  mStorage.copy(D*(vs.size()/D),vs);
475  }
476 
480  template<typename Q>
481  inline void copy(std::valarray<Q>&& vs) {
482  mStorage.copy(D*(vs.size()/D),vs);
483  }
484 
485 
489  template<typename Q>
490  inline void copy(const std::vector<Q>& vs) {
491  mStorage.copy(D*(vs.size()/D),vs);
492  }
493 
494 
498  inline void copy(const std::initializer_list<T>& vs) {
499  mStorage.copy(D*(vs.size()/D),vs);
500  }
504  inline void copy(std::initializer_list<T>&& vs) {
505  mStorage.copy(D*(vs.size()/D),vs);
506  }
507 
508 
512  template<typename Q,class S1,class I1>
513  inline void copy(const CORE_Field<Q,K,D,S1,I1>& cpy) {
514  mStorage.copy(cpy.getStorage());
515  }
516 
520  template<typename Q,class S1,class I1>
521  inline void copy(CORE_Field<Q,K,D,S1,I1>&& cpy) {
522  mStorage.copy(cpy->getStorage());
523  }
524 
525 
526 
527  //initializers methods
528  //====================
529 
533  inline void initialize(const T& v) {
534  getStorage().initialize(v);
535  }
536 
540  template<typename Q>
541  inline void initialize(const std::array<Q,D>& vs) {
542  static_cast<I*>(this)->initialize(vs);
543  }
544 
548  inline void setUniformRandomizeSeed(const tULLInt& seed) {
549  getStorage().setUniformRandomizeSeed(seed);
550  }
553  inline void setUniformRandomizeSeed() {
554  getStorage().setUniformRandomizeSeed();
555  }
556 
561  inline void uniformRandomize(const T& min,const T& max) {
562  getStorage().uniformRandomize(min,max);
563  }
564 
565  //compound assignement operators (+=,-=,*=,/=,^=...)
566  //=================================================
567 
568 
569  //T compound assignement operators (+=,-=,*=,/=,^=...)
570  //-----------------------------------------------------
574  inline Self& operator+=(const T& v) {
575  mStorage+=v;
576  return (*this);
577  }
581  inline Self& operator-=(const T& v) {
582  mStorage-=v;
583  return (*this);
584 
585  }
586 
590  inline Self& operator*=(const T& v) {
591  mStorage*=v;
592  return (*this);
593 
594  }
598  inline Self& operator/=(const T& v) {
599  mStorage/=v;
600  return (*this);
601 
602  }
603 
604 
605 
606  //integer compound assignement operators (+=,-=,*=,/=,^=...)
607  //-----------------------------------------------------
608 
612  inline Self& operator%=(const T& v) requires functions_type::isIntegerType<T> {
613  mStorage%=v;
614  return (*this);
615  }
616 
620  inline Self& operator&=(const T& v) requires functions_type::isIntegerType<T> {
621  mStorage&=v;
622  return (*this);
623  }
624 
628  inline Self& operator|=(const T& v) requires functions_type::isIntegerType<T> {
629  mStorage|=v;
630  return (*this);
631  }
632 
636  inline Self& operator^=(const T& v) requires functions_type::isIntegerType<T> {
637  mStorage^=v;
638  return (*this);
639  }
643  inline Self& operator<<=(const T& v) requires functions_type::isIntegerType<T> {
644  mStorage<<=v;
645  return (*this);
646  }
647 
651  inline Self& operator>>=(const T& v) requires functions_type::isIntegerType<T> {
652  mStorage>>=v;
653  return (*this);
654  }
655 
656  //I compound assignement operators (+=,-=,*=,/=,^=...)
657  //-----------------------------------------------------
661  template<typename T1,class S1,class I1>
662  inline Self& operator+=(const CORE_Field<T1,K,D,S1,I1>& v) {
663  mStorage+=v.getStorage();
664  return (*this);
665  }
669  template<typename T1,class S1,class I1>
671  mStorage-=v.getStorage();
672  return (*this);
673  }
677  template<typename T1,class S1,class I1>
679  mStorage*=v.getStorage();
680  return (*this);
681  }
685  template<typename T1,class S1,class I1>
687  mStorage/=v.getStorage();
688  return (*this);
689  }
690 
691 
692 
693  //transformation methods
694  //=======================
695 
699  template<typename LambdaFct>
700  inline void transform(LambdaFct&& F) {
701  getStorage().transform(F);
702  }
703 
708  template<typename LambdaFct>
709  inline void transform(LambdaFct&& F,
710  const Self& X) {
711  getStorage().transform(F,X.getStorage());
712  }
713 
719  template<typename LambdaFct>
720  inline void transform(LambdaFct&& F,
721  const Self& X,
722  const Self& Y) {
723  getStorage().transform(F,X.getStorage(),Y.getStorage());
724  }
725 
726 
727 
728 
732  template<typename LambdaFct>
733  inline void elementsTransform(LambdaFct&& F) {
734  static_cast<I*>(this)->elementsTransform(F);
735 
736  }
737 
741  inline void swap(CORE_Array<T,I>& a) {
742  getStorage().swap(a);
743  }
744 
745 
749  inline void swap(CORE_Field<T,K,D,S,I>& a) {
750  getStorage().swap(a.getStorage());
751  }
752 
753 
754 
755 
760  inline void normalize() {
761  static_cast<I*>(this)->normalize();
762  }
763 
769  template<typename Q,class S1,class I1>
770  inline void axpy(const Q& alpha, const CORE_Field<Q,K,D,S1,I1>& X,const T& beta) {
771  getStorage().axpy(alpha,X.getStorage(),beta);
772  }
773 
774 
775 
776  //data consistency methods
777  //========================
782  inline tBoolean isNANContained() const {
783  return getStorage().isNANContained();
784  }
785 
786 
787  //algebric methods
788  //================
792  template<class I1>
793  inline void mod2(CORE_Array<T,I1>& X) const {
794  static_cast<const I*>(this)->mod2(X);
795  }
796 
797 
802  inline tReal linfNorm(tIndex& i) const {
803  return getStorage().linfNorm(i);
804  }
809  template<typename Q,class I1>
810  inline tReal linfDistance(const CORE_Field<Q,K,D,S,I1>& X,tIndex& i) const {
811  tReal linf=getStorage().linfDistance(X.getStorage(),i);
812  i/=getDimension();
813  return linf;
814  }
815 
819  inline void sum(T& s) const {
820  return getStorage().sum(s);
821  }
825  inline void prod(T& p) const {
826  return getStorage().prod(p);
827 
828  }
829 
835  template<class Q,class S1,class I1>
836  inline T& scalarProduct(const CORE_Field<Q,K,D,S1,I1>& X,T& s) const {
837  return static_cast<const I*>(this)->scalarProduct(X,s);
838  }
839 
846  template<class Q,class S1,class I1>
847  inline T& scalarProduct(const std::valarray<Q>& weights,const CORE_Field<Q,K,D,S1,I1>& X,T& s) const {
848  return static_cast<I*>(this)->scalarProduct(weights,X,s);
849  }
850 
851  //ordonal methods
852  //===============
856  inline void min(T& m) const requires functions_type::isOrderedType<T>{
857  return getStorage().min(m);
858 
859  }
863  inline void max(T& m) const requires functions_type::isOrderedType<T> {
864  return getStorage().max(m);
865  }
866 
867 
871  inline void directionalSort(const tUChar& order) requires functions_type::isOrderedType<T>{
872  directionalSort(order,0);
873  }
874 
879  inline void directionalSort(const tUChar& order,const K& k) requires functions_type::isOrderedType<T>{
880  switch(order) {
881  case 'i':
882  std::sort(this->sbegin()+k,this->send()+k,std::less<T>());
883  break;
884  case 'd':
885  std::sort(this->sbegin()+k,this->send()+k,std::greater<T>());
886  break;
887  }
888 
889  }
890 
891 
892 
893 public:
894 
895 
896 
897 
898 
899  //IO methods
900  //===========
901 
915  inline tBoolean saveToFile(const tString& fileName) const {
916  return saveToFile("",fileName,12);
917  }
932  inline tBoolean saveToFile(const tString& comments,const tString& filename,const tUCInt& nDigits) const {
933  std::ofstream f(filename.c_str(),std::ios::out);
934  if (f) {
935  //save dimension & size
936  tString comment=comments;
937  functions_string::replaceAll("\n","\n#",comment);
938  f<<"#"<<comment<<"\n";
939  tInteger N=getElementsNumber();
940  f<<N<<"\t"<<((tIndex)D)<<"\n";
941  //get the values
942  const T* iV=getValues();
943  //end iterator iterator on values
944  const T* iVe=iV+this->getSize();
945  //iden itertaor on element
946  const T* iVde=null;
947 
948  while (iV!=iVe) {//loop on elements
949  iVde=iV+D;
950  while (iV!=iVde) {//loop on coordinates
951  f<<std::setprecision(nDigits)<<(*iV)<<"\t";
952  //next value to print
953  iV++;
954  }
955  f<<"\n";
956  }
957  //close the file
958  f.close();
959 
960  return true;
961  }
962  return false;
963  }
979  inline tBoolean loadFromFile(const tString& fileName) {
980  tString comment;
981  tInt retCode;
982  return loadFromFile(fileName,comment,retCode);
983  }
984 
1003  inline tBoolean loadFromFile(const tString& filename,tString& comment,tInt& retCode) {
1004  std::ifstream f(filename.c_str(),std::ios::in);
1005  if (f) {
1006  std::stringstream sscomment;
1007 
1008  //for reading a line
1009  tString line;
1010  while ( std::getline(f,line) ) {
1011 
1012  //ignore if the line is a comment
1013  if (line.find("#")==0) {
1014  functions_string::replaceAll("#","",line);
1015  sscomment<<line<<"\n";
1016  continue;
1017  }
1018  //set the comment
1019  comment=sscomment.str();
1020  //no comment line
1021  //read size & dimension
1022  tInteger N;
1023  tInt dim;
1024  std::stringstream iss(line);
1025  iss>>N;
1026  if (N==0) {
1027  //close the file
1028  f.close();
1029  //return false
1030  retCode=-1;
1031  return false;
1032  }
1033  iss >>dim;
1034  if (dim!=D) {
1035 
1036  //close the file
1037  f.close();
1038  //return false
1039  retCode=-2;
1040  return false;
1041  }
1042 
1043  //set the number of elements number
1044  setElementsNumber(N);
1045 
1046  //get the values
1047  T *iV=this->getValues();
1048  //get th end of values
1049  const T* iVe=iV+this->getSize();
1050  //read the values
1051  while ((iV!=iVe)&&(!f.eof())) {
1052  f>>(*iV);
1053  iV++;
1054  }
1055 
1056  f.close();
1057  if (iV!=iVe) retCode=0;
1058  else retCode=1;
1059  return (retCode==1);
1060  }//end loop of reading next line
1061 
1062 
1063  f.close();
1064  retCode=1;
1065  return true;
1066  }//end file exists
1067 
1068  //file does not exist
1069  retCode=-3;
1070  return false;
1071  }
1072 
1073 
1074 
1078  virtual tString toString() const override {
1079  std::stringstream cstr;
1080  tIndex k=0;
1081  cstr<<this->getIdentityString()<<"{\n ";
1082  if (getSize()>0) {
1083  std::for_each(this->csbegin(),this->csend(),
1084  [&cstr,&k](const auto& Vi) {//Vi=values[D*i]
1085  //[&i,&N,&d,&dim,&cstr](const auto& Vi) {
1086  cstr<<k<<"-(";
1087  //d=0;
1088  std::for_each_n(&Vi,D,
1089  [&cstr](const auto& Vid){//Vid=values[D*i+d]
1090  //[&i,&N,&d,&cstr](const auto& Vid){
1091  //std::cout<<"print V["<<i<<"/"<<N<<"]["<<((int)d)<<"]="<<Vid<<"\n";
1092  cstr<<std::setprecision(12)<<Vid<<",";
1093  //d++;
1094  }
1095  );
1096  k++;
1097  cstr.seekp(-1, std::ios_base::end);
1098  cstr<<")\n";
1099  });
1100  cstr.seekp(-1, std::ios_base::end);
1101  }
1102  cstr<<"}\n";
1103  return cstr.str();
1104  }
1105 
1106 };
1107 
1108 
1109 #endif
this class describes an array of values T of dynamical size with algebrical operators and I is an imp...
Definition: CORE_Array.h:91
this class describes a general container of values of type T where implemented class is I
Definition: CORE_Collection.h:49
this class describes a const iterator with a constant stride
Definition: CORE_ConstantStrideIterator.h:12
this class describes an field. A field is composed by
Definition: CORE_Field.h:49
Self & operator=(const T &v)
fill the values of the field with v
Definition: CORE_Field.h:351
const T * operator()(const tInteger &i) const
get the i-th element for reading. Do not verify the bounds
Definition: CORE_Field.h:209
void axpy(const Q &alpha, const CORE_Field< Q, K, D, S1, I1 > &X, const T &beta)
compute This=beta.This+ alpha .X
Definition: CORE_Field.h:770
T & operator()(const tInteger &i, const K d)
get the i-th element for writting. Do not verify the bounds
Definition: CORE_Field.h:202
tBoolean isNANContained() const
return true if one value is Not A Number
Definition: CORE_Field.h:782
K getDimension() const
get the dimension of the field
Definition: CORE_Field.h:169
Self & operator-=(const T &v)
sub operator
Definition: CORE_Field.h:581
S & getStorage()
get the storage
Definition: CORE_Field.h:342
void copy(const CORE_Field< Q, K, D, S1, I1 > &cpy)
copy the the field
Definition: CORE_Field.h:513
Self & operator=(Self &&cpy)
build an field by a copy of cpy
Definition: CORE_Field.h:415
void initialize(const std::array< Q, D > &vs)
initialize the field to the values of array of size D
Definition: CORE_Field.h:541
constexpr auto crbegin() const
return reverse begin iterator for reading
Definition: CORE_Field.h:262
Self & operator=(CORE_Field< Q, K, D, S1, I1 > &&cpy)
build an field by a copy of cpy
Definition: CORE_Field.h:431
void transform(LambdaFct &&F, const Self &X, const Self &Y)
transform the transform element with the lambda function Ti = F(Xi,Yi)
Definition: CORE_Field.h:720
T & get(const tIndex &i, const K &d)
get the d-th coordinate of the i-th element for writting
Definition: CORE_Field.h:315
void copy(CORE_Field< Q, K, D, S1, I1 > &&cpy)
copy the field : mv is destroyed after this
Definition: CORE_Field.h:521
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_Field.h:102
void swap(CORE_Array< T, I > &a)
swap the contents of the array
Definition: CORE_Field.h:741
void transform(LambdaFct &&F)
transform the transform element with the lambda function Ti = F(Ti)
Definition: CORE_Field.h:700
tReal linfNorm(tIndex &i) const
compute the L infinity norm
Definition: CORE_Field.h:802
auto rbegin()
return reverse begin iterator for writing
Definition: CORE_Field.h:249
Self & operator*=(const T &v)
multiplicator operator
Definition: CORE_Field.h:590
void copy(const tIndex &n, const Q *vs)
initialize the field to the values of pointer of size n
Definition: CORE_Field.h:447
const T * getValues() const
get the values of the array for reading
Definition: CORE_Field.h:323
void uniformRandomize(const T &min, const T &max)
randomize the field
Definition: CORE_Field.h:561
void copy(std::valarray< Q > &&vs)
initialize the field to the values of val array
Definition: CORE_Field.h:481
auto sbegin()
return begin stride iterator for writing
Definition: CORE_Field.h:276
void prod(T &p) const
return the produc of all the elements
Definition: CORE_Field.h:825
Self & operator=(const std::initializer_list< T > &values)
build an field by a copy of c
Definition: CORE_Field.h:358
Self & operator=(std::initializer_list< T > &&values)
build an field by a copy of c
Definition: CORE_Field.h:365
Self & operator*=(const CORE_Field< T1, K, D, S1, I1 > &v)
array multiply operator
Definition: CORE_Field.h:678
void elementsTransform(LambdaFct &&F)
apply the transform element with the lambda function Xid = F(Xid)
Definition: CORE_Field.h:733
Self & operator%=(const T &v) requires functions_type
modulo operator
Definition: CORE_Field.h:612
void mod2(CORE_Array< T, I1 > &X) const
return the norm2 array per each element
Definition: CORE_Field.h:793
auto send()
return end N-stride iterator for writing
Definition: CORE_Field.h:282
T & scalarProduct(const std::valarray< Q > &weights, const CORE_Field< Q, K, D, S1, I1 > &X, T &s) const
return the scalar product
Definition: CORE_Field.h:847
T * getValues()
get the values of the array
Definition: CORE_Field.h:329
auto begin()
return begin iterator for writing
Definition: CORE_Field.h:236
void copy(std::initializer_list< T > &&vs)
initialize the field to the values of list
Definition: CORE_Field.h:504
Self & operator=(const std::array< Q, N > &values)
build an field by a copy of c
Definition: CORE_Field.h:374
void setUniformRandomizeSeed()
set the uniform randomize seed
Definition: CORE_Field.h:553
Self & operator/=(const T &v)
divisor operator
Definition: CORE_Field.h:598
void copy(const std::array< Q, D > &vs)
initialize the field to the values of array of size D
Definition: CORE_Field.h:465
const T & operator()(const tInteger &i, const K &d) const
get the i-th element for reading. Do not verify the bounds
Definition: CORE_Field.h:195
const T & get(const tIndex &i, const K &d) const
get the d-th coordinate of the i-th element for reading
Definition: CORE_Field.h:308
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:135
Self & operator=(const CORE_Field< Q, K, D, S1, I1 > &cpy)
build a field by a copy of cpy
Definition: CORE_Field.h:423
virtual ~CORE_Field()
destroy an instance of class
Definition: CORE_Field.h:72
const T & operator[](const tIndex &i) const
get the i-th value for reading.
Definition: CORE_Field.h:179
tBoolean loadFromFile(const tString &filename, tString &comment, tInt &retCode)
load the field from a txt file with the format :
Definition: CORE_Field.h:1003
auto end()
return end iterator for writing
Definition: CORE_Field.h:242
void copy(const std::initializer_list< T > &vs)
initialize the field to the values of list
Definition: CORE_Field.h:498
constexpr auto csend() const
return end N-stride const iterator for writing
Definition: CORE_Field.h:295
virtual tMemSize getMemorySize() const override
return the memory size of the class and the memory size of all its attributes/associations
Definition: CORE_Field.h:88
void transform(LambdaFct &&F, const Self &X)
transform the transform element with the lambda function Ti = F(Xi)
Definition: CORE_Field.h:709
constexpr auto csbegin() const
return begin N-stride const iterator for writing
Definition: CORE_Field.h:289
Self & operator=(const std::valarray< Q > &values)
build an field by a copy of c
Definition: CORE_Field.h:392
T & operator[](const tIndex &i)
get the i-th value for writting.
Definition: CORE_Field.h:185
Self & operator=(const Self &cpy)
build a field by a copy of cpy
Definition: CORE_Field.h:408
auto rend()
return reverse end iterator for writing
Definition: CORE_Field.h:255
void initialize(const T &v)
initialize the field to v
Definition: CORE_Field.h:533
tReal linfDistance(const CORE_Field< Q, K, D, S, I1 > &X, tIndex &i) const
compute the Linfinitty norm
Definition: CORE_Field.h:810
void sum(T &s) const
return the sum of all the elements
Definition: CORE_Field.h:819
tIndex getSize() const
return the number values of the container
Definition: CORE_Field.h:161
Self & operator/=(const CORE_Field< T1, K, D, S1, I1 > &v)
array divisor operator
Definition: CORE_Field.h:686
Self & operator-=(const CORE_Field< T1, K, D, S1, I1 > &v)
array sub operator
Definition: CORE_Field.h:670
Self & operator=(const std::array< Q, D > &values)
build an field by a copy of c
Definition: CORE_Field.h:383
void fitToElementsNumber(const tInteger &n)
set the number of element of the container without erasing values
Definition: CORE_Field.h:129
void resize(const tIndex &n)
set the number of values of the container
Definition: CORE_Field.h:153
T * operator()(const tInteger &i)
get the i-th element for writting. Do not verify the bounds
Definition: CORE_Field.h:215
constexpr auto cbegin() const
return begin iterator for reading
Definition: CORE_Field.h:224
void copy(const std::valarray< Q > &vs)
initialize the field to the values of val array
Definition: CORE_Field.h:473
void swap(CORE_Field< T, K, D, S, I > &a)
swap the contents of the array
Definition: CORE_Field.h:749
Self & operator+=(const T &v)
add operator
Definition: CORE_Field.h:574
T & scalarProduct(const CORE_Field< Q, K, D, S1, I1 > &X, T &s) const
return the scalar product
Definition: CORE_Field.h:836
void setUniformRandomizeSeed(const tULLInt &seed)
set the uniform randomize seed
Definition: CORE_Field.h:548
Self & operator=(const std::vector< Q > &values)
build an field by a copy of c
Definition: CORE_Field.h:401
void copy(const std::array< Q, N > &vs)
initialize the field at eche element with Vs
Definition: CORE_Field.h:456
constexpr auto cend() const
return end iterator for reading
Definition: CORE_Field.h:230
void setElementsNumber(const tInteger &n)
set the number of element of the container
Definition: CORE_Field.h:121
const S & getStorage() const
get the storage
Definition: CORE_Field.h:336
void normalize()
normalize all the elements of the field return false if the method is not compatible with the floatin...
Definition: CORE_Field.h:760
constexpr auto crend() const
return reverse end iterator for reading
Definition: CORE_Field.h:268
void min(T &m) const requires functions_type
return the min value of all the elements
Definition: CORE_Field.h:856
void copy(const std::vector< Q > &vs)
initialize the field to the values of vector
Definition: CORE_Field.h:490
CORE_Field()
instanciation method of a class
Definition: CORE_Field.h:64
void setSize(const tIndex &n)
set the number of values of the container
Definition: CORE_Field.h:144
virtual tString toString() const override
return the string representation of the object node
Definition: CORE_Field.h:1078
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:321
this class describes a const iterator with a constant stride 2 templates parameter:
Definition: CORE_StrideIterator.h:12