16 #ifndef QMCPLUSPLUS_SIMD_ALGORITHM_HPP 17 #define QMCPLUSPLUS_SIMD_ALGORITHM_HPP 25 template<
typename T1,
typename T2>
28 #pragma omp simd reduction(+ : res) 29 for (
int i = 0; i <
n; ++i)
39 template<
typename T1,
typename T2>
40 inline void copy(T1* restrict target,
const T2* restrict source,
size_t n)
42 for (
size_t i = 0; i <
n; ++i)
43 target[i] = static_cast<T1>(source[i]);
52 inline void copy(T* restrict target,
const T* restrict source,
size_t n)
54 memcpy(target, source,
sizeof(T) *
n);
58 template<
typename T1,
typename T2>
59 inline void copy(T1* restrict target_r, T1* restrict target_i,
const std::complex<T2>* restrict source,
size_t n)
61 for (
int i = 0; i <
n; ++i)
63 *target_r++ =
static_cast<T1
>(source[i].real());
64 *target_i++ =
static_cast<T1
>(source[i].imag());
70 const std::complex<T>* restrict x,
71 const std::complex<T>* restrict y,
76 for (
int i = 0; i <
n; ++i)
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();
96 template<
typename T,
typename TO>
97 inline void transpose(
const T* restrict
A,
size_t m,
size_t lda, TO* restrict
B,
size_t n,
size_t ldb)
99 for (
size_t i = 0; i <
n; ++i)
100 for (
size_t j = 0; j <
m; ++j)
101 B[i * ldb + j] =
A[j *
lda + i];
114 template<
typename T,
typename TO>
115 inline void remapCopy(
size_t m,
size_t n,
const T* restrict
A,
size_t lda, TO* restrict
B,
size_t ldb)
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];
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
helper functions for EinsplineSetBuilder
void accumulate_phases(const int &n, const std::complex< T > *restrict x, const std::complex< T > *restrict y, T &rN, T &iN, T &riN)
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)
void copy(T1 *restrict target, const T2 *restrict source, size_t n)
copy function using memcpy
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)
double B(double x, int k, int i, const std::vector< double > &t)