5 #include "CORE_Object.h"
8 #include "CORE_Exception.h"
11 #include "CORE_PtrArray.h"
79 static inline CORE_UniquePointer<Self>
New() {
80 return CORE_UniquePointer<Self>(
new Self(),
170 template<
typename Q,
class I1>
180 template<
typename Q,
class I1>
199 template<
typename Q,
class I>
210 template<
typename Q,
class I>
213 Copy(cpy.getSize(),cpy.getValues(),this->getValues());
233 Copy(cpy.getSize(),cpy.getValues(),this->getValues());
243 inline void copy(
const tIndex& n ,
const Q* Vs) {
252 inline void copy(
const tIndex& n,
const std::initializer_list<T>& Vs) {
253 tIndex p=functions_numeric::min(n,Vs.size());
261 inline void copy(
const tIndex& n,std::initializer_list<T>&& Vs) {
262 tIndex p=functions_numeric::min(n,Vs.size());
272 template<
typename Q,
size_t N>
273 inline void copy(
const tIndex& n,
const std::array<Q,N>& Vs) {
274 tIndex p=functions_numeric::min(n,N);
276 Copy(p,Vs.getData(),this->getValues());
285 inline void copy(
const tIndex& n,
const std::valarray<Q>& Vs) {
286 tIndex p=functions_numeric::min(n,Vs.size());
296 inline void copy(
const tIndex&n ,
const std::vector<Q>& Vs) {
297 tIndex p=functions_numeric::min(n,Vs.size());
299 Copy(Vs.size(),Vs,this->getValues());
314 inline static void Copy(
const tIndex& n,
const Q* X,T* R) {
317 OMP_PARALLEL_SHARED((n,X,R)) {
319 tInteger threadId=OMP_GET_THREAD_ID();
322 tInteger nThreads=OMP_GET_THREADS_NUMBER();
325 tIndex start=threadId*n/nThreads;
328 tIndex
end=(threadId+1)*n/nThreads;
338 if (
sizeof(T)==
sizeof(Q)) {
339 memcpy(iR,iX,
sizeof(T)*(
end-start));
364 inline static void Copy(
const tIndex& n,
const std::vector<Q>& X,T *R) {
370 OMP_PARALLEL_SHARED((n,vX,R)) {
372 tInteger threadId=OMP_GET_THREAD_ID();
375 tInteger nThreads=OMP_GET_THREADS_NUMBER();
378 tIndex start=threadId*n/nThreads;
381 tIndex
end=(threadId+1)*n/nThreads;
413 inline static void Copy(
const tIndex& n,
const std::initializer_list<T>& X,T *R) {
419 OMP_PARALLEL_SHARED((n,vX,R)) {
421 tInteger threadId=OMP_GET_THREAD_ID();
424 tInteger nThreads=OMP_GET_THREADS_NUMBER();
427 tIndex start=threadId*n/nThreads;
430 tIndex
end=(threadId+1)*n/nThreads;
461 inline static void Copy(
const tIndex& n,std::initializer_list<T>&& X,T *R) {
467 OMP_PARALLEL_SHARED((n,vX,R)) {
469 tInteger threadId=OMP_GET_THREAD_ID();
472 tInteger nThreads=OMP_GET_THREADS_NUMBER();
475 tIndex start=threadId*n/nThreads;
478 tIndex
end=(threadId+1)*n/nThreads;
520 inline static void Initialize(
const T& v,
const tIndex& n,T* R) {
522 if (fabs(v)<std::numeric_limits<T>::epsilon()) {
526 OMP_PARALLEL_SHARED((n,R)) {
528 tInteger threadId=OMP_GET_THREAD_ID();
531 tInteger nThreads=OMP_GET_THREADS_NUMBER();
534 tIndex start=threadId*n/nThreads;
537 tIndex
end=(threadId+1)*n/nThreads;
539 if (
end>start) memset(&R[start],0,(
end-start)*
sizeof(T));
545 OMP_PARALLEL_SHARED((n,v,R)) {
547 tInteger threadId=OMP_GET_THREAD_ID();
550 tInteger nThreads=OMP_GET_THREADS_NUMBER();
553 tIndex start=threadId*n/nThreads;
556 tIndex
end=(threadId+1)*n/nThreads;
589 const tIndex& n,T* values) {
592 T alpha=(max-min)/RAND_MAX;
596 OMP_PARALLEL_SHARED((alpha,n,min,values)) {
599 tInteger nThreads=OMP_GET_THREADS_NUMBER();
602 tInteger threadId=OMP_GET_THREAD_ID();
606 tIndex start=threadId*n/nThreads;
609 tIndex
end=(threadId+1)*n/nThreads;
612 T* iV=values;iV+=start;
614 const T* iVe=values;iVe+=
end;
618 for(start=0;start<=threadId;start++) {
626 (*iV)=alpha*std::rand()+min;
674 if (fabs(v)<std::numeric_limits<T>::epsilon()) {
676 "OMP_PtrArray::/=("+std::to_string(v)+
")",
689 inline Self&
operator%=(
const T& v) requires functions_type::isIntegerType<T> {
690 auto F=[&v](
const auto &x){
return x%v;};
699 inline Self& operator&=(
const T& v) requires functions_type::isIntegerType<T> {
700 auto F=[&v](
const auto &x){
return x&v;};
708 inline Self& operator|=(
const T& v) requires functions_type::isIntegerType<T> {
709 auto F=[&v](
const auto &x){
return x|v;};
717 inline Self& operator^=(
const T& v) requires functions_type::isIntegerType<T> {
718 auto F=[&v](
const auto &x){
return x^v;};
725 inline Self& operator<<=(
const T& v) requires functions_type::isIntegerType<T> {
726 auto F=[&v](
const auto &x){
return x<<v;};
733 inline Self& operator>>=(
const T& v) requires functions_type::isIntegerType<T> {
734 auto F=[&v](
const auto &x){
return x>>v;};
747 template<
typename Q,
class I>
749 tIndex p=functions_numeric::min(v.getSize(),this->getSize());
750 Add(p,v.getValues(),this->getValues());
761 template<
typename Q,
class I>
763 tIndex p=functions_numeric::min(v.getSize(),this->getSize());
764 Sub(p,v.getValues(),this->getValues());
773 template<
typename Q,
class I>
775 tIndex p=functions_numeric::min(v.getSize(),this->getSize());
776 Multiply(p,v.getValues(),this->getValues());
785 template<
typename Q,
class I>
787 tIndex p=functions_numeric::min(v.getSize(),this->getSize());
788 Divide(p,v.getValues(),this->getValues());
802 template<
typename LambdaFct>
812 template<
typename LambdaFct>
823 template<
typename LambdaFct>
836 template<
typename LambdaFct>
855 OMP_PARALLEL_SHARED((n,iX,iR,F)) {
858 tInteger threadId=OMP_GET_THREAD_ID();
861 tInteger nThreads=OMP_GET_THREADS_NUMBER();
863 tInteger start=threadId*n/nThreads;
864 tInteger
end=(threadId+1)*n/nThreads;
866 std::transform(iX+start,iX+
end,
881 template<
typename LambdaFct>
905 OMP_PARALLEL_SHARED((n,iX,iR,F)) {
908 tInteger threadId=OMP_GET_THREAD_ID();
911 tInteger nThreads=OMP_GET_THREADS_NUMBER();
913 tInteger start=threadId*n/nThreads;
914 tInteger
end=(threadId+1)*n/nThreads;
916 std::transform(iX+start,iX+
end,
931 template<
typename LambdaFct>
942 "OMP_PtrArray::Transform(F,X,Y,R)",
943 "X ("+std::to_string(X.
getSize())+
") & Y ("+std::to_string(Y.
getSize())+
") have not same size");
964 OMP_PARALLEL_SHARED((n,iX,iY,iR,F)) {
967 tInteger threadId=OMP_GET_THREAD_ID();
969 tInteger nThreads=OMP_GET_THREADS_NUMBER();
971 tInteger start=threadId*n/nThreads;
972 tInteger
end=(threadId+1)*n/nThreads;
974 std::transform(iX+start,iX+
end,
989 static void Add(
const Q& v,
const tIndex& n,T* values) {
991 OMP_PARALLEL_SHARED((n,values,v)) {
993 tInteger threadId=OMP_GET_THREAD_ID();
996 tInteger nThreads=OMP_GET_THREADS_NUMBER();
999 tIndex start=threadId*n/nThreads;
1002 tIndex
end=(threadId+1)*n/nThreads;
1006 T* iV=values;iV+=start;
1009 T* iVe=values;iVe+=
end;
1026 template<
typename Q>
1027 inline static void Add(
const tIndex & n,
const Q* Y,T* X) {
1029 OMP_PARALLEL_SHARED((n,X,Y)) {
1031 tInteger threadId=OMP_GET_THREAD_ID();
1034 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1037 tIndex start=threadId*n/nThreads;
1040 tIndex
end=(threadId+1)*n/nThreads;
1047 const Q* iY=Y;iY+=start;
1069 template<
typename Q>
1070 inline static void Sub(
const tIndex & n,
const Q* Y,T* X) {
1072 OMP_PARALLEL_SHARED((n,X,Y)) {
1074 tInteger threadId=OMP_GET_THREAD_ID();
1077 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1080 tIndex start=threadId*n/nThreads;
1083 tIndex
end=(threadId+1)*n/nThreads;
1090 const Q* iY=Y;iY+=start;
1114 template<
typename Q>
1115 static void Multiply(
const Q& v,
const tIndex& n,T* values) {
1117 OMP_PARALLEL_SHARED((n,values,v)) {
1119 tInteger threadId=OMP_GET_THREAD_ID();
1122 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1125 tIndex start=threadId*n/nThreads;
1128 tIndex
end=(threadId+1)*n/nThreads;
1132 T* iV=values;iV+=start;
1135 T* iVe=values;iVe+=
end;
1153 template<
typename Q>
1154 inline static void Multiply(
const tIndex & n,
const Q* Y,T* X) {
1156 OMP_PARALLEL_SHARED((n,X,Y)) {
1158 tInteger threadId=OMP_GET_THREAD_ID();
1161 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1164 tIndex start=threadId*n/nThreads;
1167 tIndex
end=(threadId+1)*n/nThreads;
1174 const Q* iY=Y;iY+=start;
1197 template<
typename Q>
1198 inline static void Divide(
const tIndex & n,
const Q* Y,T* X) {
1200 Q eps=std::numeric_limits<Q>::epsilon();
1202 OMP_PARALLEL_SHARED((eps,n,X,Y)) {
1204 tInteger threadId=OMP_GET_THREAD_ID();
1207 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1210 tIndex start=threadId*n/nThreads;
1213 tIndex
end=(threadId+1)*n/nThreads;
1220 const Q* iY=Y;iY+=start;
1228 "OMP_PtrArray::Divide()",
1229 "division by zero");
1250 inline static T
norm2(
const tIndex& n,
const T *values) {
1254 OMP_PARALLEL_SHARED_REDUCTION((n,values),(+:
norm2)) {
1257 tInteger threadId=OMP_GET_THREAD_ID();
1259 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1262 tIndex start=threadId*n/nThreads;
1264 tIndex
end=(threadId+1)*n/nThreads;;
1266 const T* iV =values;iV+=start;
1268 const T* eiV=values;eiV+=
end;
1286 T inorm=
norm2(n,values);
1287 if (fabs(inorm)>std::numeric_limits<T>::epsilon()) {
1289 inorm=1./sqrt(inorm);
1291 OMP_PARALLEL_SHARED((n,values,inorm)) {
1294 tInteger threadId=OMP_GET_THREAD_ID();
1296 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1299 tIndex start=threadId*n/nThreads;
1301 tIndex
end=(threadId+1)*n/nThreads;;
1302 T* iV =values;iV+=start;
1303 const T* iVe=values;iVe+=
end;
1320 template<
typename Q,
class I>
1322 tIndex p=functions_numeric::min(X.
getSize(),this->getSize());
1334 template<
typename Q>
1335 inline void AXPY(
const tIndex& n,
const Q& alpha,
const Q* X,
const T& beta, T* Y) {
1337 OMP_PARALLEL_SHARED((n,alpha,beta,X,Y)) {
1340 tInteger threadId=OMP_GET_THREAD_ID();
1343 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1346 tIndex start=threadId*n/nThreads;
1349 tIndex
end=(threadId+1)*n/nThreads;
1352 const Q *iX=X+start;
1361 (*iY)=beta*(*iY)+alpha*(*iX);
1387 tBoolean isnan=
false;
1388 OMP_PARALLEL_SHARED_REDUCTION((n,values),(max:isnan)) {
1391 tInteger threadId=OMP_GET_THREAD_ID();
1394 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1397 const T* iV=values+threadId*n/nThreads;
1400 const T* iVe=values+(threadId+1)*n/nThreads;
1405 if (std::isnan(*iV))
break;
1438 inline static T
Sum(
const tIndex& n,
const T* values) {
1443 OMP_PARALLEL_SHARED_REDUCTION((n,values),(+:s)) {
1446 tInteger threadId=OMP_GET_THREAD_ID();
1448 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1451 const T* iV=values+threadId*n/nThreads;
1454 const T* iVe=values+(threadId+1)*n/nThreads;
1459 while (iV!=iVe){s+=(*iV);iV++;}
1478 inline static T
Prod(
const tIndex& n,
const T* values) {
1481 OMP_PARALLEL_SHARED_REDUCTION((n,values),(*:p)) {
1484 tInteger threadId=OMP_GET_THREAD_ID();
1486 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1489 const T* iV=values+threadId*n/nThreads;
1492 const T* iVe=values+(threadId+1)*n/nThreads;
1497 while (iV!=iVe){p*=(*iV);iV++;}
1513 template<
typename Q,
class I>
1529 template<
typename Q>
1537 OMP_PARALLEL_SHARED_REDUCTION((n,Y,X),(+:s)) {
1541 tInteger threadId=OMP_GET_THREAD_ID();
1543 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1546 tIndex start=threadId*n/nThreads;
1548 tIndex
end=(threadId+1)*n/nThreads;;
1551 auto iX=X;iX+=start;
1552 auto iY=Y;iY+=start;
1556 auto iXe=X;iXe+=
end;
1585 template<
typename Q,
class I>
1601 template<
typename Q>
1603 const tIndex& nY,
const T* Ys) {
1610 tIndex n=functions_numeric::min(nX,nY);
1613 OMP_PARALLEL_SHARED_REDUCTION((n,Xs,Ys),(+:d2)) {
1616 tInteger threadId=OMP_GET_THREAD_ID();
1618 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1621 tIndex start=threadId*n/nThreads;
1623 tIndex
end=(threadId+1)*n/nThreads;
1626 const T *iY=Ys+start;
1627 const Q *iX=Xs+start;
1629 const Q *iXe=Xs+
end;
1644 OMP_PARALLEL_SHARED_REDUCTION((p,n,Xs),(+:d2)) {
1647 tInteger threadId=OMP_GET_THREAD_ID();
1649 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1652 tIndex start=threadId*p/nThreads;
1654 tIndex
end=(threadId+1)*p/nThreads;
1657 const Q *iX=Xs+n+start;
1659 const Q *iXe=Xs+n+
end;
1672 OMP_PARALLEL_SHARED_REDUCTION((p,n,Ys),(+:d2)) {
1675 tInteger threadId=OMP_GET_THREAD_ID();
1677 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1680 tIndex start=threadId*p/nThreads;
1682 tIndex
end=(threadId+1)*p/nThreads;
1685 const T *iY=Ys+n+start;
1687 const T *iYe=Ys+n+
end;
1716 template<
typename Q,
class I>
1732 template<
typename Q>
1734 const tIndex& nY,
const T* Ys,
1739 tIndex n=functions_numeric::min(nX,nY);
1743 std::pair<tIndex,tReal> S(0,0);
1746 OMP_PARALLEL_SHARED_REDUCTION((n,Ys,Xs), (argrmax:S)) {
1748 tInteger threadId=OMP_GET_THREAD_ID();
1750 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1753 tIndex start=threadId*n/nThreads;
1755 tIndex
end=(threadId+1)*n/nThreads;
1758 const T *iY=Ys+start;
1761 const Q *iX=Xs+start;
1767 for (i=start;i<
end;i++) {
1770 if (S.second<
norm2) {
1782 OMP_PARALLEL_SHARED_REDUCTION((n,p,Xs), (argrmax:S)) {
1784 tInteger threadId=OMP_GET_THREAD_ID();
1786 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1789 tIndex start=threadId*p/nThreads;
1791 tIndex
end=(threadId+1)*p/nThreads;
1795 const Q*iX=Xs+n+start;
1797 const Q *iXe=Xs+n+
end;
1805 if (S.second<
norm2) {
1817 OMP_PARALLEL_SHARED_REDUCTION((n,p,Ys), (argrmax:S)) {
1819 tInteger threadId=OMP_GET_THREAD_ID();
1821 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1824 tIndex start=threadId*p/nThreads;
1826 tIndex
end=(threadId+1)*p/nThreads;
1830 const T *iY=Ys+n+start;
1832 const T *iYe=Ys+n+
end;
1840 if (S.second<
norm2) {
1854 return sqrt(S.second);
1866 inline void min(T& m)
const requires functions_type::isOrderedType<T> {
1874 inline static T Min(
const tIndex& n,
const T* values) requires functions_type::isOrderedType<T> {
1878 T p=(n>0)?(*values):0;
1879 OMP_PARALLEL_SHARED_REDUCTION((n,values),(min:p)) {
1882 tInteger threadId=OMP_GET_THREAD_ID();
1884 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1887 const T* iV=values+threadId*n/nThreads;
1890 const T* iVe=values+(threadId+1)*n/nThreads;
1892 while (iV!=iVe){p=(p<(*iV))?p:(*iV);iV++;}
1905 inline void max(T& m)
const requires functions_type::isOrderedType<T> {
1913 inline static T Max(
const tIndex& n,
const T* values) requires functions_type::isOrderedType<T> {
1917 T p=(n>0)?(*values):0;
1919 OMP_PARALLEL_SHARED_REDUCTION((n,values),(max:p)) {
1922 tInteger threadId=OMP_GET_THREAD_ID();
1924 tInteger nThreads=OMP_GET_THREADS_NUMBER();
1927 const T* iV=values+threadId*n/nThreads;
1930 const T* iVe=values+(threadId+1)*n/nThreads;
1932 while (iV!=iVe){p=(p>(*iV))?p:(*iV);iV++;}
1946 inline void directionalSort(
const tUChar& order) requires functions_type::isOrderedType<T>{
1949 std::sort(this->
begin(),this->
end(),std::less<T>());
1952 std::sort(this->
begin(),this->
end(),std::greater<T>());
1977 #ifndef DEFAULT_OMP_ARRAY
1978 #define DEFAULT_OMP_ARRAY
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
constexpr auto cbegin() const
return begin iterator for reading
Definition: CORE_Collection.h:143
tIndex getSize() const
return the size of the container
Definition: CORE_Collection.h:111
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
this class describes an arithmetic array type implemented with as a pointer allocation object with im...
Definition: CORE_PtrArray.h:69
const T * getValues() const
get the values of the array for reading
Definition: CORE_PtrArray.h:357
auto begin()
return begin iterator for writing
Definition: CORE_PtrArray.h:312
auto end()
return end iterator for writing
Definition: CORE_PtrArray.h:318
void setSize(const tIndex &n)
set the number of values
Definition: CORE_PtrArray.h:146
constexpr auto cbegin() const
return begin iterator for reading
Definition: CORE_PtrArray.h:300
tIndex getSize() const
return the size of the array for writing
Definition: CORE_PtrArray.h:155
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_PtrArray.h:132
this class define a PTR array with OpenMP vectorization
Definition: OMP_PtrArray.h:22
Self & operator*=(const CORE_Array< Q, I > &v)
array multiply operator
Definition: OMP_PtrArray.h:774
static T norm2(const tIndex &n, const T *values)
computes the square of norm of the norm
Definition: OMP_PtrArray.h:1250
Self & operator-=(const CORE_Array< Q, I > &v)
array sub operator
Definition: OMP_PtrArray.h:762
static void Transform(LambdaFct &&F, const CORE_Array< T, Self > &X, const CORE_Array< T, Self > &Y, Self &R)
transform the transform element with the lambda function Ri = F(const Xi,const Yi)
Definition: OMP_PtrArray.h:932
Self & operator*=(const T &v)
multiplicator operator
Definition: OMP_PtrArray.h:665
Self & operator=(const Self &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:153
void transform(LambdaFct &&F, const CORE_Array< T, Self > &X)
transform the transform element in parallel to the lambda function Ti=F(const Xi)
Definition: OMP_PtrArray.h:813
tReal linfDistance(const CORE_Array< Q, I > &X, tIndex &imax) const
compute the square of L2-distance of this to X
Definition: OMP_PtrArray.h:1717
void copy(const tIndex &n, std::initializer_list< T > &&Vs)
initialize the array to the values of list
Definition: OMP_PtrArray.h:261
Self & operator/=(const T &v)
divisor operator
Definition: OMP_PtrArray.h:673
Self & operator=(Self &&values)
build an array by a copy of c (in mirror with the copy operator)
Definition: OMP_PtrArray.h:160
static void Copy(const tIndex &n, std::initializer_list< T > &&X, T *R)
copy the the n first values of an initializer
Definition: OMP_PtrArray.h:461
void AXPY(const tIndex &n, const Q &alpha, const Q *X, const T &beta, T *Y)
compute Y=beta.Y+ alpha .X
Definition: OMP_PtrArray.h:1335
void uniformRandomize(const T &min, const T &max)
randomize the vector in [min,max]
Definition: OMP_PtrArray.h:638
void copy(Self &&cpy)
copy the container : mv is destroyed after this
Definition: OMP_PtrArray.h:231
tReal l2Distance2(const CORE_Array< Q, I > &X) const
compute the square of L2-distance of this to X
Definition: OMP_PtrArray.h:1586
static void Multiply(const tIndex &n, const Q *Y, T *X)
compute X*=Y
Definition: OMP_PtrArray.h:1154
void copy(const tIndex &n, const std::array< Q, N > &Vs)
initialize the array to the values of array of size N
Definition: OMP_PtrArray.h:273
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: OMP_PtrArray.h:68
void copy(const tIndex &n, const std::vector< Q > &Vs)
initialize the array to the values of vector
Definition: OMP_PtrArray.h:296
void sum(T &s) const
return the sum of all the elements
Definition: OMP_PtrArray.h:1428
Self & operator=(const std::vector< T > &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:146
static void Copy(const tIndex &n, const std::vector< Q > &X, T *R)
copy the the n first values of an initializer
Definition: OMP_PtrArray.h:364
Self & operator=(const CORE_Array< Q, I1 > &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:171
void transform(LambdaFct &&F)
transform the transform element in parallel to the lambda function Ti=F(const Ti)
Definition: OMP_PtrArray.h:803
Self & operator/=(const CORE_Array< Q, I > &v)
array divisor operator
Definition: OMP_PtrArray.h:786
static void UniformRandomize(const T &min, const T &max, const tIndex &n, T *values)
randomize the vector in [0,max]
Definition: OMP_PtrArray.h:588
Self & operator=(const std::valarray< T > &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:138
Self & operator=(std::initializer_list< T > &&values)
build an array by a copy of c
Definition: OMP_PtrArray.h:112
Self & operator%=(const T &v) requires functions_type
modulo operator
Definition: OMP_PtrArray.h:689
Self & operator=(const std::array< T, N > &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:129
static void Add(const Q &v, const tIndex &n, T *values)
add to the values the constant v
Definition: OMP_PtrArray.h:989
void copy(const tIndex &n, const std::initializer_list< T > &Vs)
initialize the array to the values of list
Definition: OMP_PtrArray.h:252
OMP_PtrArray(const tIndex &n)
build an instance of class of size n
Definition: OMP_PtrArray.h:41
static void Copy(const tIndex &n, const std::initializer_list< T > &X, T *R)
copy the the n first values of an initializer
Definition: OMP_PtrArray.h:413
static void Initialize(const T &v, const tIndex &n, T *R)
copy the n values of a pointers array
Definition: OMP_PtrArray.h:520
static T ScalarProduct(const tIndex &n, const Q *X, const T *Y)
return the sclar product
Definition: OMP_PtrArray.h:1530
tReal linfNorm(tIndex &imax) const
compute the Linf-norm of this
Definition: OMP_PtrArray.h:1704
void copy(const tIndex &n, const Q *Vs)
initialize the array to the values of pointer of size n
Definition: OMP_PtrArray.h:243
static void Divide(const tIndex &n, const Q *Y, T *X)
compute X/=Y
Definition: OMP_PtrArray.h:1198
Self & operator=(const std::initializer_list< T > &values)
build an array by a copy of c
Definition: OMP_PtrArray.h:119
Self & operator-=(const T &v)
sub operator
Definition: OMP_PtrArray.h:657
void copy(CORE_Array< Q, I > &&cpy)
copy the container : mv is destroyed after this
Definition: OMP_PtrArray.h:211
void copy(const CORE_Array< Q, I > &cpy)
copy the container
Definition: OMP_PtrArray.h:200
OMP_PtrArray()
build an instance of class
Definition: OMP_PtrArray.h:34
Self & operator=(const CORE_Array< Q, I1 > &&values)
build an array by a copy of c (in mirror with the copy operator)
Definition: OMP_PtrArray.h:181
static tReal LinfDistance(const tIndex &nX, const Q *Xs, const tIndex &nY, const T *Ys, tIndex &imax)
compute the index of the array where the module of the difference between X & Y is max
Definition: OMP_PtrArray.h:1733
static void Multiply(const Q &v, const tIndex &n, T *values)
multiply the values by the constant v
Definition: OMP_PtrArray.h:1115
virtual ~OMP_PtrArray()
destroy an instance of class
Definition: OMP_PtrArray.h:52
void normalize()
normalize the array
Definition: OMP_PtrArray.h:1241
static void Add(const tIndex &n, const Q *Y, T *X)
compute X+=Y
Definition: OMP_PtrArray.h:1027
static void Transform(LambdaFct &&F, const CORE_Array< T, Self > &X, Self &R)
transform the transform element with the lambda function Ri = F(const Xi)
Definition: OMP_PtrArray.h:882
tReal l2Norm2() const
compute the square of L2-norm of this
Definition: OMP_PtrArray.h:1574
static void Sub(const tIndex &n, const Q *Y, T *X)
compute X-=Y
Definition: OMP_PtrArray.h:1070
tBoolean isNANContained() const
return true if one value is Not A Number
Definition: OMP_PtrArray.h:1375
void copy(const tIndex &n, const std::valarray< Q > &Vs)
initialize the array to the values of val array
Definition: OMP_PtrArray.h:285
static void Transform(LambdaFct &&F, Self &X)
transform the transform element with the lambda function Xi = F(const Xi)
Definition: OMP_PtrArray.h:837
void transform(LambdaFct &&F, const CORE_Array< T, Self > &X, const CORE_Array< T, Self > &Y)
transform the transform element with the lambda function Ti := F(const Xi,const Yi)
Definition: OMP_PtrArray.h:824
static void Copy(const tIndex &n, const Q *X, T *R)
copy the n values of a pointers array
Definition: OMP_PtrArray.h:314
void prod(T &p) const
return the produc of all the elements
Definition: OMP_PtrArray.h:1469
Self & operator+=(const T &v)
add operator
Definition: OMP_PtrArray.h:650
static tBoolean IsNANContained(const tIndex &n, const T *values)
return true if one value is Not A Number
Definition: OMP_PtrArray.h:1384
void axpy(const Q &alpha, const CORE_Array< Q, I > &X, const T &beta)
compute This=beta.This+ alpha .X
Definition: OMP_PtrArray.h:1321
static void Normalize(const tIndex &n, T *values)
normalize the array
Definition: OMP_PtrArray.h:1283
static CORE_UniquePointer< Self > New()
return a unique pointer of the class
Definition: OMP_PtrArray.h:79
Self & operator=(const T &v)
fill the values of the array with v
Definition: OMP_PtrArray.h:105
void copy(const Self &cpy)
copy the container
Definition: OMP_PtrArray.h:221
void initialize(const T &x)
initialize the array to the value x
Definition: OMP_PtrArray.h:511
static T Sum(const tIndex &n, const T *values)
return the sum of all the elements
Definition: OMP_PtrArray.h:1438
T & scalarProduct(const CORE_Array< Q, I > &X, T &s) const
return the scalar product
Definition: OMP_PtrArray.h:1514
static T Prod(const tIndex &n, const T *values)
return the product of all the elements
Definition: OMP_PtrArray.h:1478
static tReal L2Distance2(const tIndex &nX, const Q *Xs, const tIndex &nY, const T *Ys)
compute the square of L2 distance of X to Y
Definition: OMP_PtrArray.h:1602