34 #ifndef OHMMS_PARTICLEATTRIB_OPS_H    35 #define OHMMS_PARTICLEATTRIB_OPS_H    41 template<
class T1, 
class T2, 
unsigned D>
    47     Type_t res = lhs[0].real() * rhs[0].real() - lhs[0].imag() * rhs[0].imag();
    48     for (
unsigned d = 1; d < D; ++d)
    49       res += lhs[d].
real() * rhs[d].real() - lhs[d].imag() * rhs[d].imag();
    56     std::complex<Type_t> res = lhs[0] * rhs[0];
    57     for (
unsigned d = 1; d < D; ++d)
    58       res += lhs[d] * rhs[d];
    64 template<
class T1, 
class T2, 
unsigned D>
    70     Type_t res = lhs[0].real() * rhs[0].real() + lhs[0].imag() * rhs[0].imag();
    71     for (
unsigned d = 1; d < D; ++d)
    72       res += lhs[d].
real() * rhs[d].real() + lhs[d].imag() * rhs[d].imag();
    77 template<
class T1, 
class T2>
    83     return lhs[0].real() * rhs[0].real() - lhs[0].imag() * rhs[0].imag() + lhs[1].real() * rhs[1].real() -
    84         lhs[1].imag() * rhs[1].imag() + lhs[2].real() * rhs[2].real() - lhs[2].imag() * rhs[2].imag();
    90     return lhs[0] * rhs[0] + lhs[1] * rhs[1] + lhs[2] * rhs[2];
    95 template<
class T1, 
class T2>
   101     return lhs[0].real() * rhs[0].real() + lhs[0].imag() * rhs[0].imag() + lhs[1].real() * rhs[1].real() +
   102         lhs[1].imag() * rhs[1].imag() + lhs[2].real() * rhs[2].real() + lhs[2].imag() * rhs[2].imag();
   106 template<
class T, 
unsigned D>
   109   T factor = 
Dot(pa, pa);
   110   factor   = 1.0 / 
sqrt(factor);
   121 template<
typename T, 
unsigned D>
   125   for (
int i = 0; i < pa.size(); i++)
   127     sum += 
dot(pa[i], pb[i]);
   132 template<
typename T, 
unsigned D>
   137   for (
int i = 0; i < pa.size(); i++)
   144 template<
typename T, 
unsigned D>
   148   std::complex<T> sum(0.0, 0.0);
   149   for (
int i = 0; i < pa.size(); i++)
   162   for (
int i = 0; i < pa.size(); i++)
   173   for (
int i = 0; i < pa.
size(); i++)
   184   for (
int i = 0; i < pa.size(); i++)
   194   std::complex<T> sum(0.0, 0.0);
   195   for (
int i = 0; i < pa.size(); i++)
   202 template<
class T, 
unsigned D>
   205   for (
int i = 0; i < c.size(); i++)
   208     for (
int j = 0; j < D; j++)
   209       r[i][j] = c[i][j].
real();
   213 template<
class T, 
unsigned D>
   222 template<
class T, 
unsigned D, 
class T1 = T>
   227 template<
class T, 
class T1>
   238     for (
int i = 0; i < pa.
size(); i++)
   240       pb[i][0] = a * pa[i][0].real();
   241       pb[i][1] = a * pa[i][1].real();
   242       pb[i][2] = a * pa[i][2].real();
   250     for (
int i = 0; i < pa.
size(); ++i)
   252       pb[i][0] += a * pa[i][0].real();
   253       pb[i][1] += a * pa[i][1].real();
   254       pb[i][2] += a * pa[i][2].real();
   260     for (
int i = 0; i < pa.
size(); ++i)
   262       pb[i][0] += a * pa[i][0];
   263       pb[i][1] += a * pa[i][1];
   264       pb[i][2] += a * pa[i][2];
   273     for (
int i = 0; i < pa.
size(); ++i)
   275       py[i][0] = a * pa[i][0].real() + pb[i][0];
   276       py[i][1] = a * pa[i][1].real() + pb[i][1];
   277       py[i][2] = a * pa[i][2].real() + pb[i][2];
   286     for (
int i = 0; i < pa.
size(); ++i)
   288       py[i][0] = a * pa[i][0] + pb[i][0];
   289       py[i][1] = a * pa[i][1] + pb[i][1];
   290       py[i][2] = a * pa[i][2] + pb[i][2];
   298     for (
int i = 0; i < px.
size(); ++i)
   300       py[i][0] = px[i][0].real();
   301       py[i][1] = px[i][1].real();
   302       py[i][2] = px[i][2].real();
   308 template<
class T, 
class T1>
   319     for (
int i = 0; i < pa.
size(); i++)
   321       pb[i][0] = a * pa[i][0].real();
   322       pb[i][1] = a * pa[i][1].real();
   331     for (
int i = 0; i < pa.
size(); i++)
   333       pb[i][0] += a * pa[i][0].real();
   334       pb[i][1] += a * pa[i][1].real();
   340     for (
int i = 0; i < pa.
size(); i++)
   342       pb[i][0] += a * pa[i][0];
   343       pb[i][1] += a * pa[i][1];
   352     for (
int i = 0; i < pa.
size(); i++)
   354       py[i][0] = a * pa[i][0].real() + pb[i][0];
   355       py[i][1] = a * pa[i][1].real() + pb[i][1];
   364     for (
int i = 0; i < pa.
size(); i++)
   366       py[i][0] = a * pa[i][0] + pb[i][0];
   367       py[i][1] = a * pa[i][1] + pb[i][1];
   372 #endif // OHMMS_PARTICLEATTRIB_OPS_H static void axpy(T a, const ParticleAttrib< cpos_type > &pa, ParticleAttrib< rpos_type > &pb)
static void axpy(T a, const ParticleAttrib< cpos_type > &pa, ParticleAttrib< rpos_type > &pb)
void normalize(ParticleAttrib< TinyVector< T, D >> &pa)
typename Promote< T1, T2 >::Type_t Type_t
static void axpy(T a, const ParticleAttrib< ipos_type > &pa, const ParticleAttrib< ipos_type > &pb, ParticleAttrib< rpos_type > &py)
static void scale(T a, const ParticleAttrib< cpos_type > &pa, ParticleAttrib< rpos_type > &pb)
T Sum(const ParticleAttrib< T > &pa)
static void scale(T a, const ParticleAttrib< cpos_type > &pa, ParticleAttrib< rpos_type > &pb)
std::complex< T > CplxDot(const ParticleAttrib< TinyVector< std::complex< T >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< T >, D >> &pb)
static std::complex< Type_t > cplx_apply(const TinyVector< std::complex< T1 >, 3 > &lhs, const TinyVector< std::complex< T2 >, 3 > &rhs)
helper functions for EinsplineSetBuilder 
static void axpy(T a, const ParticleAttrib< ipos_type > &pa, ParticleAttrib< rpos_type > &pb)
static Type_t apply(const TinyVector< std::complex< T1 >, D > &lhs, const TinyVector< std::complex< T2 >, D > &rhs)
static Type_t apply(const TinyVector< std::complex< T1 >, D > &lhs, const TinyVector< std::complex< T2 >, D > &rhs)
std::complex< T > CplxSum(const ParticleAttrib< std::complex< T >> &pa)
static Type_t apply(const TinyVector< std::complex< T1 >, 3 > &lhs, const TinyVector< std::complex< T2 >, 3 > &rhs)
static void axpy(T a, const ParticleAttrib< ipos_type > &pa, const ParticleAttrib< ipos_type > &pb, ParticleAttrib< rpos_type > &py)
std::complex< T > complex_type
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs. 
static std::complex< Type_t > cplx_apply(const TinyVector< std::complex< T1 >, D > &lhs, const TinyVector< std::complex< T2 >, D > &rhs)
Attaches a unit to a Vector for IO. 
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
static void copy(const ParticleAttrib< cpos_type > &px, ParticleAttrib< rpos_type > &py)
void Copy(const ParticleAttrib< TinyVector< std::complex< T >, D >> &c, ParticleAttrib< TinyVector< T, D >> &r)
typename BinaryReturn< T1, T2, OpMultiply >::Type_t Type_t
static void axpy(T a, const ParticleAttrib< ipos_type > &pa, ParticleAttrib< rpos_type > &pb)
static void axpy(T a, const ParticleAttrib< cpos_type > &pa, const ParticleAttrib< ipos_type > &pb, ParticleAttrib< rpos_type > &py)
typename BinaryReturn< T1, T2, OpMultiply >::Type_t Type_t
size_type size() const
return the current size 
typename BinaryReturn< T1, T2, OpMultiply >::Type_t Type_t
static void scale(T a, const ParticleAttrib< ipos_type > &pa, ParticleAttrib< rpos_type > &pb)
static void axpy(T a, const ParticleAttrib< cpos_type > &pa, const ParticleAttrib< ipos_type > &pb, ParticleAttrib< rpos_type > &py)
static Type_t apply(const TinyVector< std::complex< T1 >, 3 > &lhs, const TinyVector< std::complex< T2 >, 3 > &rhs)
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
std::complex< T > complex_type
double Dot_CC(const ParticleAttrib< TinyVector< std::complex< double >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< double >, D >> &pb)
static void copy(const ParticleAttrib< ipos_type > &px, ParticleAttrib< rpos_type > &py)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
typename BinaryReturn< T1, T2, OpMultiply >::Type_t Type_t
static void scale(T a, const ParticleAttrib< ipos_type > &pa, ParticleAttrib< rpos_type > &pb)