QMCPACK
qmcplusplus::simd Namespace Reference

Functions

template<typename T1 , typename T2 >
T2 accumulate_n (const T1 *restrict in, size_t n, T2 res)
 
template<typename T1 , typename T2 >
void copy (T1 *restrict target, const T2 *restrict source, size_t n)
 copy function using memcpy More...
 
template<typename T >
void copy (T *restrict target, const T *restrict source, size_t n)
 copy function using memcpy More...
 
template<typename T1 , typename T2 >
void copy (T1 *restrict target_r, T1 *restrict target_i, const std::complex< T2 > *restrict source, size_t n)
 copy complex to two real containers More...
 
template<typename T >
void accumulate_phases (const int &n, const std::complex< T > *restrict x, const std::complex< T > *restrict y, T &rN, T &iN, T &riN)
 
template<typename T , typename TO >
void transpose (const T *restrict A, size_t m, size_t lda, TO *restrict B, size_t n, size_t ldb)
 transpose of A(m,n) to B(n,m) More...
 
template<typename T , typename TO >
void remapCopy (size_t m, size_t n, const T *restrict A, size_t lda, TO *restrict B, size_t ldb)
 copy of A(m,n) to B(m,n) More...
 
template<typename T , typename TRES = T>
dot (const T *restrict a, const T *restrict b, int n, TRES res=TRES())
 dot product More...
 
template<class T , unsigned D, class TRES = T>
TinyVector< T, D > dot (const T *a, const TinyVector< T, D > *b, int n, TinyVector< TRES, D > res=TinyVector< T, D >())
 inline dot product More...
 
template<class T , unsigned D, class TRES = T>
Tensor< T, D > dot (const T *a, const Tensor< T, D > *b, int n, Tensor< TRES, D > res=Tensor< TRES, D >())
 inline dot product More...
 
template<typename T >
dot (int n, const T *restrict x, int incx, const T *restrict y, int incy)
 x*y dot product of two vectors using the same argument list for blas::dot More...
 
template<typename T , typename SIZET >
void remainder (const T *restrict in, T *restrict out, SIZET n)
 mod on an array out[i]=in[i]-floor(in[i]) More...
 
template<typename T , typename SIZET >
void remainder (T *restrict inout, SIZET n)
 
template<typename T , typename SIZET >
void sqrt (T *restrict inout, SIZET n)
 
template<typename T >
void sqrt (const T *restrict in, T *restrict out, int n)
 
template<typename T >
void inv (const T *restrict in, T *restrict out, int n)
 
template<typename T >
void add (int n, const T *restrict in, T *restrict out)
 

Function Documentation

◆ accumulate_n()

T2 qmcplusplus::simd::accumulate_n ( const T1 *restrict  in,
size_t  n,
T2  res 
)
inline

◆ accumulate_phases()

void qmcplusplus::simd::accumulate_phases ( const int &  n,
const std::complex< T > *restrict  x,
const std::complex< T > *restrict  y,
T &  rN,
T &  iN,
T &  riN 
)
inline

Definition at line 69 of file algorithm.hpp.

References qmcplusplus::n.

75 {
76  for (int i = 0; i < n; ++i)
77  {
78  T tr = x[i].real() * y[i].real() - x[i].imag() * y[i].imag();
79  T ti = x[i].real() * y[i].imag() + x[i].imag() * y[i].real();
80  rN += tr * tr;
81  iN += ti * ti;
82  riN += tr * ti;
83  } //
84 }

◆ add()

void qmcplusplus::simd::add ( int  n,
const T *restrict  in,
T *restrict  out 
)
inline

Definition at line 95 of file vmath.hpp.

References qmcplusplus::n.

Referenced by SPOSetInfo::add(), and ci_configuration::isSingle().

96 {
97  for (int i = 0; i < n; ++i)
98  out[i] += in[i];
99 }

◆ copy() [1/3]

void qmcplusplus::simd::copy ( T1 *restrict  target,
const T2 *restrict  source,
size_t  n 
)
inline

copy function using memcpy

Parameters
targetstarting address of the target
sourcestarting address of the source
nsize of the data to copy

Definition at line 40 of file algorithm.hpp.

References qmcplusplus::n.

Referenced by DiracDeterminant< DU_TYPE >::acceptMove(), and DiracDeterminantBatched< PL, VT, FPVT >::acceptMove().

41 {
42  for (size_t i = 0; i < n; ++i)
43  target[i] = static_cast<T1>(source[i]);
44 }

◆ copy() [2/3]

void qmcplusplus::simd::copy ( T *restrict  target,
const T *restrict  source,
size_t  n 
)
inline

copy function using memcpy

Parameters
targetstarting address of the target
sourcestarting address of the source
nsize of the data to copy

Definition at line 52 of file algorithm.hpp.

References qmcplusplus::n.

53 {
54  memcpy(target, source, sizeof(T) * n);
55 }

◆ copy() [3/3]

void qmcplusplus::simd::copy ( T1 *restrict  target_r,
T1 *restrict  target_i,
const std::complex< T2 > *restrict  source,
size_t  n 
)
inline

copy complex to two real containers

Definition at line 59 of file algorithm.hpp.

References qmcplusplus::n.

60 {
61  for (int i = 0; i < n; ++i)
62  {
63  *target_r++ = static_cast<T1>(source[i].real());
64  *target_i++ = static_cast<T1>(source[i].imag());
65  }
66 }

◆ dot() [1/4]

T qmcplusplus::simd::dot ( const T *restrict  a,
const T *restrict  b,
int  n,
TRES  res = TRES() 
)
inline

dot product

Parameters
astarting address of an array of type T
bstarting address of an array of type T
nsize
resinitial value, can be used to override precision in reduction
Returns
$ res = \sum_i a[i] b[i]$

Definition at line 41 of file inner_product.hpp.

References qmcplusplus::n.

Referenced by MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl(), MultiDiracDeterminant::buildTableMatrix_calculateRatiosValueMatrixOneParticle(), DiracDeterminantBatched< PL, VT, FPVT >::computeGL(), qmcplusplus::DetRatioByColumn(), qmcplusplus::DetRatioByRow(), DiracDeterminantWithBackflow::dummyEvalLi(), DiracDeterminant< DU_TYPE >::evalGrad(), DiracDeterminantBatched< PL, VT, FPVT >::evalGrad(), DiracDeterminant< DU_TYPE >::evalGradSource(), DiracDeterminantBatched< PL, VT, FPVT >::evalGradSource(), DiracDeterminant< DU_TYPE >::evalGradWithSpin(), DiracDeterminantBatched< PL, VT, FPVT >::evalGradWithSpin(), DiracDeterminantWithBackflow::evaluateDerivatives(), LCAOrbitalSet::evaluateDetRatios(), HybridRepCplx< SPLINEBASE >::evaluateDetRatios(), HybridRepReal< SPLINEBASE >::evaluateDetRatios(), SplineC2R< ST >::evaluateDetRatios(), SplineC2C< ST >::evaluateDetRatios(), SplineR2R< ST >::evaluateDetRatios(), SPOSet::evaluateDetRatios(), SpinorSet::evaluateDetSpinorRatios(), DiracDeterminant< DU_TYPE >::evaluateHessian(), DiracDeterminantBatched< PL, VT, FPVT >::evaluateHessian(), DiracDeterminantWithBackflow::evaluateLog(), DiracDeterminant< DU_TYPE >::evaluateLog(), AGPDeterminant::evaluateLogAndStore(), DiracDeterminantBatched< PL, VT, FPVT >::evaluateRatiosAlltoOne(), LCAOrbitalSet::mw_evaluateDetRatios(), LCAOrbitalSet::mw_evaluateVGLandDetRatioGrads(), SPOSet::mw_evaluateVGLandDetRatioGrads(), AGPDeterminant::ratio(), DiracDeterminant< DU_TYPE >::ratio(), DiracDeterminantBatched< PL, VT, FPVT >::ratio(), AGPDeterminant::ratioDown(), DiracDeterminantWithBackflow::ratioGrad(), DiracDeterminantBatched< PL, VT, FPVT >::ratioGrad(), DiracDeterminant< DU_TYPE >::ratioGrad_compute(), DiracDeterminant< DU_TYPE >::ratioGradWithSpin(), DiracDeterminantBatched< PL, VT, FPVT >::ratioGradWithSpin(), AGPDeterminant::ratioUp(), qmcplusplus::TEST_CASE(), DiracDeterminantWithBackflow::testDerivFjj(), DiracDeterminantWithBackflow::testL(), and DiracDeterminant< DU_TYPE >::updateAfterSweep().

42 {
43  for (int i = 0; i < n; i++)
44  res += a[i] * b[i];
45  return res;
46 }

◆ dot() [2/4]

TinyVector<T, D> qmcplusplus::simd::dot ( const T *  a,
const TinyVector< T, D > *  b,
int  n,
TinyVector< TRES, D >  res = TinyVector<T, D>() 
)
inline

inline dot product

Parameters
astarting address of an array of type T
bstarting address of an array of type TinyVector<T,D>
nsize
resinitial value, can be used to override precision in reduction

Definition at line 55 of file inner_product.hpp.

References qmcplusplus::n.

56 {
57  for (int i = 0; i < n; i++)
58  res += a[i] * b[i];
59  return res;
60 }

◆ dot() [3/4]

Tensor<T, D> qmcplusplus::simd::dot ( const T *  a,
const Tensor< T, D > *  b,
int  n,
Tensor< TRES, D >  res = Tensor<TRES, D>() 
)
inline

inline dot product

Parameters
astarting address of an array of type T
bstarting address of an array of type Tensor<T, D>
nsize
resinitial value, can be used to override precision in reduction
Returns
$ {\bf v} = \sum_i a[i] {\bf b}[i]$

Definition at line 70 of file inner_product.hpp.

References qmcplusplus::n.

71 {
72  for (int i = 0; i < n; i++)
73  res += a[i] * b[i];
74  return res;
75 }

◆ dot() [4/4]

T qmcplusplus::simd::dot ( int  n,
const T *restrict  x,
int  incx,
const T *restrict  y,
int  incy 
)
inline

x*y dot product of two vectors using the same argument list for blas::dot

Parameters
nsize
xstarting address of x
incxstride of x
ystarting address of y
incxstride of y
return$\sum_i x[i+=incx]*y[i+=incy]$

Definition at line 86 of file inner_product.hpp.

References qmcplusplus::n.

87 {
88  const int xmax = incx * n;
89  T res = 0.0;
90  for (int ic = 0, jc = 0; ic < xmax; ic += incx, jc += incy)
91  res += x[ic] * y[jc];
92  return res;
93 }

◆ inv()

◆ remainder() [1/2]

void qmcplusplus::simd::remainder ( const T *restrict  in,
T *restrict  out,
SIZET  n 
)
inline

mod on an array out[i]=in[i]-floor(in[i])

Definition at line 38 of file vmath.hpp.

References qmcplusplus::floor(), and qmcplusplus::n.

Referenced by qmcplusplus::put2box().

39 {
40  for (SIZET i = 0; i < n; ++i)
41  out[i] = in[i] - std::floor(in[i]);
42 }
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ remainder() [2/2]

void qmcplusplus::simd::remainder ( T *restrict  inout,
SIZET  n 
)
inline

Definition at line 45 of file vmath.hpp.

References qmcplusplus::floor(), and qmcplusplus::n.

46 {
47  for (SIZET i = 0; i < n; ++i)
48  inout[i] -= std::floor(inout[i]);
49 }
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ remapCopy()

void qmcplusplus::simd::remapCopy ( size_t  m,
size_t  n,
const T *restrict  A,
size_t  lda,
TO *restrict  B,
size_t  ldb 
)
inline

copy of A(m,n) to B(m,n)

Parameters
Astarting address, A(m,lda)
mnumber of A rows
ldastride of A's row
Bstarting address B(m,ldb)
mnumber of B rows
ldbstride of B's row

Blas-like interface

Definition at line 115 of file algorithm.hpp.

References qmcplusplus::Units::distance::A, B(), qmcplusplus::lda, qmcplusplus::Units::distance::m, and qmcplusplus::n.

Referenced by DiracMatrixComputeOMPTarget< VALUE_FP >::invert_transpose(), and DiracMatrixComputeCUDA< VALUE_FP >::mw_computeInvertAndLog().

116 {
117  for (size_t j = 0; j < m; ++j)
118  for (size_t i = 0; i < n; ++i)
119  B[j * ldb + i] = A[j * lda + i];
120 }
double B(double x, int k, int i, const std::vector< double > &t)

◆ sqrt() [1/2]

◆ sqrt() [2/2]

void qmcplusplus::simd::sqrt ( const T *restrict  in,
T *restrict  out,
int  n 
)
inline

Definition at line 59 of file vmath.hpp.

References qmcplusplus::n.

Referenced by sqrt().

60 {
61  for (int i = 0; i < n; ++i)
62  out[i] = std::sqrt(in[i]);
63 }
void sqrt(const T *restrict in, T *restrict out, int n)
Definition: vmath.hpp:59

◆ transpose()

void qmcplusplus::simd::transpose ( const T *restrict  A,
size_t  m,
size_t  lda,
TO *restrict  B,
size_t  n,
size_t  ldb 
)
inline