16 #ifndef OHMMS_TENSOR_H 17 #define OHMMS_TENSOR_H 43 template<
class T,
unsigned D>
45 template<
class T,
unsigned D>
54 template<
class T,
unsigned D>
71 for (
size_t d = 0; d <
Size; ++d)
86 for (
size_t d = 0; d <
Size; ++d)
93 for (
size_t d = 0; d <
Size; ++d)
98 Tensor(
const T& x00,
const T& x10,
const T& x01,
const T& x11)
207 for (
int i = 0; i < D; i++)
213 for (
int i = 0; i < D; i++)
214 (*
this)(i, i) += rhs;
254 for (
int j = 0; j < D; j++)
255 res[j] =
X[i * D + j];
262 for (
int j = 0; j < D; j++)
263 res[j] =
X[j * D + i];
325 template<
class T,
unsigned D>
329 for (
int i = 0; i < D; i++)
336 template<
class T,
unsigned D>
340 for (
int j = 0; j < D; j++)
341 for (
int i = 0; i < D; i++)
342 result(i, j) = rhs(j, i);
348 template<
class T1,
class T2,
unsigned D>
352 for (
int i = 0; i < D; i++)
353 for (
int j = 0; j < D; j++)
354 result += a(i, j) * b(j, i);
360 template<
class T,
unsigned D>
364 for (
int i = 0; i < D * D; i++)
365 result += a(i) * b(i);
371 template<
class T1,
class T2,
unsigned D>
376 for (
int i = 0; i < D * D; i++)
377 result += a(i) * b(i);
413 template<
class T1,
class T2,
unsigned D>
424 template<
class T1,
class T2,
unsigned D>
435 template<
class T1,
class T2,
unsigned D>
494 template<
class T,
unsigned D>
495 std::ostream& operator<<(std::ostream& out, const Tensor<T, D>& rhs)
499 for (
int i = 0; i < D; i++)
501 for (
int j = 0; j < D - 1; j++)
503 out << rhs(i, j) <<
" ";
505 out << rhs(i, D - 1) <<
" ";
512 out <<
" " << rhs(0, 0) <<
" ";
517 template<
class T,
unsigned D>
520 for (
int i = 0; i < D * D; i++)
525 template<
class T,
unsigned D>
528 for (
int i = 0; i < D * D; i++)
529 if (lhs[i] != rhs[i])
534 template<
class T,
unsigned D>
537 return !(lhs == rhs);
548 template<
class T,
unsigned D>
551 for (
int i = 0; i < D; ++i)
552 for (
int j = 0; j < D; ++j)
553 (*
this)(i, j) = rhs(i, j);
556 template<
class T,
unsigned D>
559 for (
int i = 0; i < D; ++i)
560 for (
int j = 0; j < D; ++j)
561 (*
this)(i, j) = rhs(i, j);
566 #endif // OHMMS_TENSOR_H typename Promote< T1, T2 >::Type_t Type_t
TinyVector< T, D > getRow(unsigned int i)
helper functions for EinsplineSetBuilder
Tensor< T, D > & operator=(const T &rhs)
Tensor< T, D > & operator+=(const T &rhs)
Tensor< T, D > & operator+=(const Tensor< T1, D > &rhs)
bool operator==(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
const Type_t * end() const
const Type_t * begin() const
T traceAtB(const Tensor< T, D > &a, const Tensor< T, D > &b)
Tr(a^t *b), .
Tensor(const Tensor< T1, D > &rhs)
Tensor< T, D > & operator-=(const T &rhs)
Tensor< T, D > & operator/=(const T &rhs)
TinyVector< T, D > getColumn(unsigned int i)
Tensor<T,D> class for D by D tensor.
Tensor< T, D > & operator=(const Tensor< T1, D > &rhs)
Tensor< T, D > & operator*=(const T &rhs)
Tensor< T, D > & operator-=(const Tensor< T1, D > &rhs)
Tensor & operator=(const Tensor &rhs)=default
#define OHMMS_META_BINARY_OPERATORS(TENT, FUNC, TAG)
AntiSymTensor< T, D > transpose(const AntiSymTensor< T, D > &rhs)
Tensor< T, D > & operator/=(const Tensor< T1, D > &rhs)
Type_t operator[](unsigned int i) const
return the i-th value
void diagonal(const T &rhs)
int size() const
return the size
Tensor< T, D > & operator*=(const Tensor< T1, D > &rhs)
Type_t & operator()(unsigned int i)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
Tensor(const T &x00, const T &x10, const T &x20, const T &x01, const T &x11, const T &x21, const T &x02, const T &x12, const T &x22)
Type_t & operator()(unsigned int i, unsigned int j)
return/assign the (i,j) component
std::istream & operator>>(std::istream &is, Matrix< T, Alloc > &rhs)
const Type_t * data() const
T trace(const AntiSymTensor< T, D > &)
bool operator!=(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
Type_t operator()(unsigned int i, unsigned int j) const
return the (i,j) component
int len() const
return the size
Type_t & operator[](unsigned int i)
return the i-th value or assign
Type_t operator()(unsigned int i) const
Tensor(const T &x00, const T &x10, const T &x01, const T &x11)