4 #include "CORE_Field.h"
7 #include "OMP_PtrArray.h"
15 template <
typename T,
typename K,K D>
67 static inline CORE_UniquePointer<Self>
New() {
99 if (values.size()==D) {
110 if (values.size()==D) {
124 template<
size_t N,
typename Q>
172 template<
typename Q,
class S1,
class I1>
183 template<
typename Q,
class S1,
class I1>
205 auto vA =std::ranges::cbegin(a);
208 const auto iAe=std::ranges::cend(a);
216 OMP_PARALLEL_SHARED((n,vA,iAe,values)) {
219 tInteger threadId=OMP_GET_THREAD_ID();
222 tInteger nThreads=OMP_GET_THREADS_NUMBER();
225 tInteger start=threadId*n/nThreads;
228 tInteger
end=(threadId+1)*n/nThreads;
231 T* iV=values+D*start;
234 const T* iVe=values+D*
end;
265 auto vA =std::ranges::cbegin(a);
268 const auto iAe=std::ranges::cend(a);
276 OMP_PARALLEL_SHARED((n,vA,iAe,values)) {
279 tInteger threadId=OMP_GET_THREAD_ID();
282 tInteger nThreads=OMP_GET_THREADS_NUMBER();
285 tInteger start=threadId*n/nThreads;
288 tInteger
end=(threadId+1)*n/nThreads;
291 T* iV=values+D*start;
294 const T* iVe=values+D*
end;
326 const Q* vA =a.data();
337 OMP_PARALLEL_SHARED((n,vA,iAe,values)) {
340 tInteger threadId=OMP_GET_THREAD_ID();
343 tInteger nThreads=OMP_GET_THREADS_NUMBER();
346 tInteger start=threadId*n/nThreads;
349 tInteger
end=(threadId+1)*n/nThreads;
352 T* iV=values+D*start;
355 const T* iVe=values+D*
end;
431 inline Self& operator&=(
const T& v) requires functions_type::isIntegerType<T>{
439 inline Self& operator|=(
const T& v) requires functions_type::isIntegerType<T>{
447 inline Self& operator^=(
const T& v) requires functions_type::isIntegerType<T> {
454 inline Self& operator<<=(
const T& v) requires functions_type::isIntegerType<T> {
462 inline Self& operator>>=(
const T& v) requires functions_type::isIntegerType<T> {
476 template<
class Q,
class S,
class I>
487 template<
class Q,
class S,
class I>
498 template<
class Q,
class S,
class I>
510 template<
class Q,
class S,
class I>
527 template<
typename LambdaFct>
540 OMP_PARALLEL_SHARED((n,iX,F)) {
543 tInteger threadId=OMP_GET_THREAD_ID();
545 tInteger nThreads=OMP_GET_THREADS_NUMBER();
548 tInteger start=threadId*n/nThreads;
551 tInteger
end=(threadId+1)*n/nThreads;
554 std::transform(iX+start,iX+
end,
568 template<
typename LambdaFct>
582 T eps=std::numeric_limits<T>::epsilon();
594 OMP_PARALLEL_SHARED((n,values,eps)) {
597 tInteger threadId=OMP_GET_THREAD_ID();
599 tInteger nThreads=OMP_GET_THREADS_NUMBER();
601 tInteger start=threadId*n/nThreads;
603 tInteger
end=(threadId+1)*n/nThreads;
606 T* iV=values+D*start;
609 const T* iVe=values+D*
end;
629 norm2+=(*iVd)*(*iVd);
634 norm2=1./sqrt(norm2);
685 OMP_PARALLEL_SHARED((n,vX,values)) {
689 tInteger threadId=OMP_GET_THREAD_ID();
691 tInteger nThreads=OMP_GET_THREADS_NUMBER();
693 tInteger start=threadId*n/nThreads;
695 tInteger
end=(threadId+1)*n/nThreads;
698 const T* iV=values+start*D;
701 const T* iVe=values+
end*D;
736 template<
class Q,
class S1,
class I1>
749 template<
class Q,
class S1,
class I1>
762 if (weights.size()==0) {
765 if ((weights.size()==1)&& (incXs)) {
773 const tReal *Ws=&weights[0];
774 tBoolean incW=(weights.size()!=1);
784 OMP_PARALLEL_SHARED_REDUCTION((n,incW,Ws,Ys,Xs,incXs),
789 tInteger threadId=OMP_GET_THREAD_ID();
791 tInteger nThreads=OMP_GET_THREADS_NUMBER();
794 tIndex start=threadId*n/nThreads;
816 tIndex
end=(threadId+1)*n/nThreads;;
835 s+=(*iW)*(*iXd)*(*iY);
860 #ifndef DIMENSION_TYPE
861 #define DIMENSION_TYPE
862 typedef tUCInt tDimension;
870 #ifndef DEFAULT_OMP_FIELD
871 #define DEFAULT_OMP_FIELD
this class describes an array of values T of dynamical size with algebrical operators and I is an imp...
Definition: CORE_Array.h:91
const T * getValues() const
get the values of the array for reading
Definition: CORE_Array.h:206
void setSize(const tIndex &n)
set the size of the container
Definition: CORE_Collection.h:104
this class describes an field. A field is composed by
Definition: CORE_Field.h:49
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_Field.h:102
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
auto sbegin()
return begin stride iterator for writing
Definition: CORE_Field.h:276
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:135
auto end()
return end iterator for writing
Definition: CORE_Field.h:242
const OMP_PtrArray< T > & getStorage() const
get the storage
Definition: CORE_Field.h:336
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
this class define a PTR array with OpenMP vectorization
Definition: OMP_PtrArray.h:22
this class describes a standart arithmetic array type implemented with a std::valarray object
Definition: OMP_PtrField.h:16
Self & operator%=(const T &v) requires functions_type
modulo operator
Definition: OMP_PtrField.h:423
Self & operator*=(const T &v)
multiplicator operator
Definition: OMP_PtrField.h:405
void elementsTransform(LambdaFct &&F)
apply the transform element with the lambda function Xid = F(Xid)
Definition: OMP_PtrField.h:569
Self & operator/=(const T &v)
divisor operator
Definition: OMP_PtrField.h:413
Self & operator=(Self &&values)
build an array by a copy of values
Definition: OMP_PtrField.h:161
Self & operator=(const std::initializer_list< T > &values)
build an array by a copy of values
Definition: OMP_PtrField.h:98
void normalize()
normalize all the elements of the field return false if the method is not compatible with the floatin...
Definition: OMP_PtrField.h:579
Self & operator=(CORE_Field< Q, K, D, S1, I1 > &&values)
build an array by a copy of c
Definition: OMP_PtrField.h:184
void initialize(const std::initializer_list< Q > &&a)
copy at element elemnt the array of size D
Definition: OMP_PtrField.h:203
static CORE_UniquePointer< Self > New()
return a new unique pointer of this
Definition: OMP_PtrField.h:67
Self & operator=(const std::valarray< Q > &values)
build an array by a copy of values
Definition: OMP_PtrField.h:136
T & scalarProduct(const CORE_Field< Q, K, D, S1, I1 > &X, T &s) const
return the weight scalar product
Definition: OMP_PtrField.h:737
void initialize(const std::array< Q, D > &a)
copy at element elemnt the array of size D
Definition: OMP_PtrField.h:323
OMP_PtrField()
build an array of T*
Definition: OMP_PtrField.h:29
Self & operator=(const Self &values)
build an array by a copy of values
Definition: OMP_PtrField.h:154
Self & operator=(std::initializer_list< T > &&values)
build an array by a copy of values
Definition: OMP_PtrField.h:109
void mod2(CORE_Array< T, I > &X) const
return the norm2 array per each element
Definition: OMP_PtrField.h:668
virtual ~OMP_PtrField()
destroy an array of T*
Definition: OMP_PtrField.h:37
Self & operator=(const T &v)
fill the values of the array with v
Definition: OMP_PtrField.h:91
void initialize(const T &a)
copy at element elemnt the array of size D
Definition: OMP_PtrField.h:195
Self & operator=(const std::array< Q, N > &values)
build an array by a copy of values
Definition: OMP_PtrField.h:125
Self & operator-=(const T &v)
sub operator
Definition: OMP_PtrField.h:396
void initialize(const std::initializer_list< Q > &a)
copy at element elemnt the array of size D
Definition: OMP_PtrField.h:263
Self & operator-=(const CORE_Field< Q, K, D, S, I > &X)
array sub operator
Definition: OMP_PtrField.h:488
Self & operator*=(const CORE_Field< Q, K, D, S, I > &X)
array multiply operator
Definition: OMP_PtrField.h:499
T & scalarProduct(const std::valarray< Q > &weights, const CORE_Field< Q, K, D, S1, I1 > &X, T &s) const
return the weight scalar product
Definition: OMP_PtrField.h:750
Self & operator+=(const T &v)
add operator
Definition: OMP_PtrField.h:389
Self & operator=(const std::vector< Q > &values)
build an array by a copy of values
Definition: OMP_PtrField.h:146
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: OMP_PtrField.h:56
static void ElementsTransform(LambdaFct &&F, Self &X)
apply the transform element with the lambda function Ri = F(Xi)
Definition: OMP_PtrField.h:528
Self & operator=(const CORE_Field< Q, K, D, S1, I1 > &values)
build an array by a copy of values
Definition: OMP_PtrField.h:173
Self & operator/=(const CORE_Field< Q, K, D, S, I > &X)
array divisor operator
Definition: OMP_PtrField.h:511