12 #ifndef HAMMER_MATH_TENSOR
13 #define HAMMER_MATH_TENSOR
42 Tensor(
const std::string& name, std::vector<std::pair<MultiDimensional::SharedTensorData, bool>>&& data);
54 template <
typename... Args>
60 template <
typename... Args>
61 std::complex<double>
value(Args... rest)
const;
101 const std::string&
name()
const;
187 void read(
const Serial::FBTensor* msgreader);
213 Tensor
spinSum(
const Tensor& first);
225 Tensor
operator*(
const Tensor& first,
double val);
231 Tensor
operator*(
double val,
const Tensor& first);
237 Tensor
operator*(
const Tensor& first, std::complex<double> val);
243 Tensor
operator*(std::complex<double> val,
const Tensor& first);
250 Tensor
operator+(
const Tensor& first,
const Tensor& second);
271 Tensor
elementDivide(
const Tensor& first,
const Tensor& second);
Tensor elementDivide(const Tensor &first, const Tensor &second)
divides two tensors of the same rank and same dimensions element by element
Tensor & outerSquare()
creates a tensor with twice the rank by multiplying the tensor with its hermitean conjugate ...
Tensor & spinSum()
trace some of the indices of this tensor
Log & getLog() const
logging facility
std::complex< double > & element(const IndexList &indices={})
access an element given its indices
Forward declaration of serialization related typedefs and includes.
Tensor & spinAverage()
trace over the traceable spin indices and divide by the product of the dimensions of the traced indic...
Tensor & toVector()
forces conversion of a tensor to vector type
Tensor & addAt(const Tensor &t, IndexLabel coord, IndexType position)
add a tensor of rank N-1 to a specific position in a specific coordinate the dimension of the tensor ...
Tensor & operator+=(const Tensor &other)
sums another tensor to itself
LabelsList labels() const
get the labels of all the indices at once
const std::string & name() const
get the tensor name
Tensor outerSquare(const Tensor &first)
creates a tensor with twice the rank by multiplying the tensor with it's hermitean conjugate ...
void write(flatbuffers::FlatBufferBuilder *msgwriter, flatbuffers::Offset< Serial::FBTensor > *msg) const
write the contents of the tensor for serialization
Tensor elementMultiply(const Tensor &first, const Tensor &second)
multiplies two tensors of the same rank and same dimensions element by element
bool hasFFLabels() const
checks if Tensor has indices in the FF range
std::unique_ptr< IContainer > TensorData
std::complex< double > value(Args...rest) const
returns the value of a specific tensor element
Forward declarations of types used in the tensor classes.
size_t rank() const
rank of the tensor
Tensor spinSum(const Tensor &first)
trace a tensor
Tensor & operator*=(double val)
multiply all the elements of the tensor by a real number
MultiDimensional::TensorData _data
std::vector< IndexType > IndexList
void setValue(std::complex< double > value, Args...rest)
set the value of a specific tensor element
IndexLabel
label identifiers of tensor indices they are used to determine which indices can be contracted togeth...
Multidimensional tensor class with complex numbers as elements.
bool isEqualTo(const Tensor &other) const
Tensor operator*(const Tensor &first, double val)
left multiplies a tensor by a real constant
void clearData()
sets all the elements to 0
std::string _name
the tensor name
Hammer tensor class template methods definitions.
std::vector< IndexLabel > LabelsList
std::set< IndexLabel > UniqueLabelsList
Tensor & elementDivideBy(const Tensor &other)
divide two tensors element by element and stores the result in this tensor
Tensor spinAverage(const Tensor &first)
trace a tensor over the traceable spin indices and divide by the product of the dimensions of the tra...
Tensor & dot(const Tensor &other, const UniqueLabelsList &indices={})
contract this tensor with another and stores the result in this tensor
IndexList dims() const
get the dimensions of all the indices at once
Tensor & elementMultiplyBy(const Tensor &other)
multiply two tensors element by element and stores the result in this tensor
void read(const Serial::FBTensor *msgreader)
read the contents of the tensor for serialization
Histogram operator+(const Histogram &first, const Histogram &second)
bool hasFFVarLabels() const
checks if Tensor has indices in the FF Var range
Tensor & operator=(const Tensor &other)
bool hasWCLabels() const
checks if Tensor has indices in the WC range
Tensor dot(const Tensor &first, const Tensor &second, const set< IndexLabel > &indices)