4 #include "CORE_Field.h"
7 #include "OMP_ValArray.h"
15 template <
typename T,
typename K,K D>
66 static inline CORE_UniquePointer<Self>
New() {
115 template<
size_t N,
typename Q>
163 template<
typename Q,
class S1,
class I1>
174 template<
typename Q,
class S1,
class I1>
201 OMP_PARALLEL_SHARED((n,iA,iV)) {
204 tInteger threadId=OMP_GET_THREAD_ID();
206 tInteger nThreads=OMP_GET_THREADS_NUMBER();
209 tInteger start=threadId*n/nThreads;
212 tInteger
end=(threadId+1)*n/nThreads;
215 auto F=[&iA](
auto& Vi) {
218 std::for_each_n(iA,D,[&Vid](
const auto& Aid){(*Vid)=Aid;Vid++;});
225 std::transform(iV+start,iV+
end,
284 inline Self& operator&=(
const T& v) requires functions_type::isIntegerType<T>{
292 inline Self& operator|=(
const T& v) requires functions_type::isIntegerType<T>{
300 inline Self& operator^=(
const T& v) requires functions_type::isIntegerType<T> {
307 inline Self& operator<<=(
const T& v) requires functions_type::isIntegerType<T> {
315 inline Self& operator>>=(
const T& v) requires functions_type::isIntegerType<T> {
329 template<
class Q,
class S,
class I>
340 template<
class Q,
class S,
class I>
351 template<
class Q,
class S,
class I>
363 template<
class Q,
class S,
class I>
380 template<
typename LambdaFct>
393 OMP_PARALLEL_SHARED((n,iX,F)) {
396 tInteger threadId=OMP_GET_THREAD_ID();
398 tInteger nThreads=OMP_GET_THREADS_NUMBER();
400 tInteger start=threadId*n/nThreads;
401 tInteger
end=(threadId+1)*n/nThreads;
404 std::transform(iX+start,iX+
end,
418 template<
typename LambdaFct>
432 T eps=std::numeric_limits<T>::epsilon();
444 OMP_PARALLEL_SHARED((n,iV,eps)) {
447 tInteger threadId=OMP_GET_THREAD_ID();
449 tInteger nThreads=OMP_GET_THREADS_NUMBER();
451 tInteger start=threadId*n/nThreads;
453 tInteger
end=(threadId+1)*n/nThreads;
457 auto F=[&norm,&eps](
auto& Vi) {
460 std::for_each_n(&Vi,D,[&norm](
const auto& Vid){
470 std::for_each_n(&Vi,D,[&norm](
auto& Vid){Vid*=norm;});
475 std::transform(iV+start,iV+
end,
518 OMP_PARALLEL_SHARED((n,iX,iV)) {
522 tInteger threadId=OMP_GET_THREAD_ID();
524 tInteger nThreads=OMP_GET_THREADS_NUMBER();
526 tInteger start=threadId*n/nThreads;
528 tInteger
end=(threadId+1)*n/nThreads;
531 std::transform(iV+start,iV+
end,
532 iX+start,[&norm2](
const auto& Vi) {
535 std::for_each_n(&Vi,D,[&norm2](
const auto& Vid) {norm2+=Vid*Vid;});
552 template<
class Q,
class S1,
class I1>
566 template<
class Q,
class S1,
class I1>
575 if (weights.size()==0) {
580 tBoolean incW=(weights.size()>1);
582 const tReal *Ws=&weights[0];
593 OMP_PARALLEL_SHARED_REDUCTION((n,incW,Ws,Ys,Xs,incXs),
598 tInteger threadId=OMP_GET_THREAD_ID();
600 tInteger nThreads=OMP_GET_THREADS_NUMBER();
603 tIndex start=threadId*n/nThreads;
606 tIndex
end=(threadId+1)*n/nThreads;;
609 const Q* iX=Xs;iX+=incXs*start*D;
612 const T* iY=Ys;iY+=start*D;
614 const T* iYe=Ys;iYe+=
end*D;
619 const Q* iW=Ws;iW+=start*incW;
628 s+=(*iW)*(*iXd)*(*iY);
650 #ifndef DIMENSION_TYPE
651 #define DIMENSION_TYPE
652 typedef tUCInt tDimension;
this class describes an array of values T of dynamical size with algebrical operators and I is an imp...
Definition: CORE_Array.h:91
auto begin()
return begin iterator for writing
Definition: CORE_Collection.h:155
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
constexpr auto csbegin() const
return begin N-stride const iterator for writing
Definition: CORE_Field.h:289
const OMP_ValArray< 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 describes a standart arithmetic array type implemented with a std::valarray object of type...
Definition: OMP_ValArray.h:19
this class describes a standart arithmetic array type implemented with a std::valarray object
Definition: OMP_ValField.h:16
Self & operator-=(const CORE_Field< Q, K, D, S, I > &X)
array sub operator
Definition: OMP_ValField.h:341
void elementsTransform(LambdaFct &&F)
apply the transform element with the lambda function Xid = F(Xid)
Definition: OMP_ValField.h:419
virtual ~OMP_ValField()
destroy an array of T*
Definition: OMP_ValField.h:36
Self & operator%=(const T &v) requires functions_type
modulo operator
Definition: OMP_ValField.h:276
Self & operator*=(const CORE_Field< Q, K, D, S, I > &X)
array multiply operator
Definition: OMP_ValField.h:352
Self & operator=(Self &&values)
build an array by a copy of values
Definition: OMP_ValField.h:152
OMP_ValField()
build an array of T*
Definition: OMP_ValField.h:28
Self & operator=(const CORE_Field< Q, K, D, S1, I1 > &values)
build an array by a copy of values
Definition: OMP_ValField.h:164
T & scalarProduct(const CORE_Field< Q, K, D, S1, I1 > &X, T &s) const
return the weight scalar product
Definition: OMP_ValField.h:553
void mod2(CORE_Array< T, I > &X) const
return the norm2 array per exch element
Definition: OMP_ValField.h:501
Self & operator=(const std::vector< Q > &values)
build an array by a copy of values
Definition: OMP_ValField.h:137
Self & operator/=(const CORE_Field< Q, K, D, S, I > &X)
array divisor operator
Definition: OMP_ValField.h:364
Self & operator/=(const T &v)
divisor operator
Definition: OMP_ValField.h:266
void initialize(const std::array< Q, D > &a)
copy at element elemnt the array of size D
Definition: OMP_ValField.h:190
static CORE_UniquePointer< Self > New()
return a new unique pointer of this
Definition: OMP_ValField.h:66
Self & operator=(const std::initializer_list< T > &values)
build an array by a copy of values
Definition: OMP_ValField.h:97
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: OMP_ValField.h:55
static void ElementsTransform(LambdaFct &&F, Self &X)
apply the transform element with the lambda function Ri = F(Xi)
Definition: OMP_ValField.h:381
Self & operator=(CORE_Field< Q, K, D, S1, I1 > &&values)
build an array by a copy of values
Definition: OMP_ValField.h:175
Self & operator=(const T &v)
fill the values of the array with v
Definition: OMP_ValField.h:90
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_ValField.h:567
Self & operator+=(const T &v)
add operator
Definition: OMP_ValField.h:242
Self & operator=(const std::valarray< Q > &values)
build an array by a copy of values
Definition: OMP_ValField.h:127
Self & operator=(std::initializer_list< T > &&values)
build an array by a copy of values
Definition: OMP_ValField.h:104
Self & operator=(const std::array< Q, N > &values)
build an array by a copy of values
Definition: OMP_ValField.h:116
Self & operator-=(const T &v)
sub operator
Definition: OMP_ValField.h:249
void normalize()
normalize all the elements of the field return false if the method is not compatible with the floatin...
Definition: OMP_ValField.h:429
Self & operator*=(const T &v)
multiplicator operator
Definition: OMP_ValField.h:258
Self & operator=(const Self &values)
build an array by a copy of values
Definition: OMP_ValField.h:145