|
pRC
multi-purpose Tensor Train library for C++
|
Class storing tensors. More...
#include <tensor.hpp>
Public Types | |
| using | Type = T |
| template<class C > | |
| using | ChangeType = Tensor< C, Ns... > |
| using | Subscripts = pRC::Subscripts< Ns... > |
| using | Sizes = pRC::Sizes< Ns... > |
| template<Size... Ss> | |
| using | ChangeSizes = Tensor< T, Ss... > |
| using | Dimension = typename Sizes::Dimension |
| using | Value = typename T::Value |
| template<class V , If< IsValue< V > > = 0> | |
| using | ChangeValue = Tensor< typename T::template ChangeValue< V >, Ns... > |
| using | Signed = typename T::Signed |
| template<Bool R> | |
| using | ChangeSigned = Tensor< typename T::template ChangeSigned< R >, Ns... > |
| using | Width = typename T::Width |
| template<Size Q> | |
| using | ChangeWidth = Tensor< typename T::template ChangeWidth< Q >, Ns... > |
| using | IsComplexified = typename T::IsComplexified |
| using | Complexify = Tensor< typename T::Complexify, Ns... > |
| using | NonComplex = Tensor< typename T::NonComplex, Ns... > |
Public Member Functions | |
| ~Tensor ()=default | |
| constexpr | Tensor (Tensor const &)=default |
| constexpr | Tensor (Tensor &&)=default |
| constexpr Tensor & | operator= (Tensor const &) &=default |
| constexpr Tensor & | operator= (Tensor &&) &=default |
| constexpr | Tensor ()=default |
| template<class X , If< IsAssignable< TensorViews::Reference< T, Sizes >, X > > = 0> | |
| constexpr | Tensor (X &&other) |
| Tensor initializer from compatible tensorish object. | |
| template<class X , If< IsAssignable< TensorViews::Reference< T, Sizes >, X > > = 0> | |
| constexpr auto & | operator= (X &&rhs) & |
| Tensor assignment from compatible tensorish objects. | |
| template<class... Is, If< All< IsConvertible< Is, Index >... > > = 0, If< IsSatisfied<(sizeof...(Is)==Dimension())> > = 0> | |
| constexpr decltype(auto) | operator() (Is const ... indices) && |
| Getter/setter for rvalue Tensor entries from indices. | |
| template<class... Is, If< All< IsConvertible< Is, Index >... > > = 0, If< IsSatisfied<(sizeof...(Is)==Dimension())> > = 0> | |
| constexpr decltype(auto) | operator() (Is const ... indices) const && |
| Getter for const rvalue Tensor entries from indices. | |
| template<class... Is, If< All< IsConvertible< Is, Index >... > > = 0, If< IsSatisfied<(sizeof...(Is)==Dimension())> > = 0> | |
| constexpr decltype(auto) | operator() (Is const ... indices) & |
| Getter/setter for lvalue Tensor entries from indices. | |
| template<class... Is, If< All< IsConvertible< Is, Index >... > > = 0, If< IsSatisfied<(sizeof...(Is)==Dimension())> > = 0> | |
| constexpr decltype(auto) | operator() (Is const ... indices) const & |
| Getter for const lvalue Tensor entries from indices. | |
| constexpr decltype(auto) | operator() (Subscripts const &subscripts) && |
| Getter/setter for rvalue Tensor entries from indices. | |
| constexpr decltype(auto) | operator() (Subscripts const &subscripts) const && |
| Getter for const rvalue Tensor entries from indices. | |
| constexpr decltype(auto) | operator() (Subscripts const &subscripts) & |
| Getter/setter for lvalue Tensor entries from indices. | |
| constexpr decltype(auto) | operator() (Subscripts const &subscripts) const & |
| Getter for const rvalue Tensor entries from indices. | |
| constexpr decltype(auto) | operator[] (Index const index) && |
| Getter/setter for rvalue Tensor entries from linearized index. | |
| constexpr decltype(auto) | operator[] (Index const index) const && |
| Getter for const rvalue Tensor entries from linearized index. | |
| constexpr decltype(auto) | operator[] (Index const index) & |
| Getter/setter for lvalue Tensor entries from linearized index. | |
| constexpr decltype(auto) | operator[] (Index const index) const & |
| Getter for const lvalue Tensor entries from linearized index. | |
| template<class X , If< IsInvocable< Add, Tensor &, X > > = 0> | |
| constexpr auto & | operator+= (X &&rhs) & |
| += operator for Tensors | |
| template<class X , If< IsInvocable< Sub, Tensor &, X > > = 0> | |
| constexpr auto & | operator-= (X &&rhs) & |
| -= operator for Tensors | |
| template<class X , If< IsInvocable< Mul, X, Tensor & > > = 0> | |
| constexpr auto & | applyOnTheLeft (X &&lhs) & |
| Applies an object from the left. | |
| template<class X , If< IsInvocable< Mul, Tensor &, X > > = 0> | |
| constexpr auto & | applyOnTheRight (X &&rhs) & |
| Applies an object from the right. | |
| template<class X , If< IsInvocable< Mul, Tensor &, X > > = 0> | |
| constexpr auto & | operator*= (X &&rhs) & |
| *= operator for Tensor | |
| template<class X , If< IsInvocable< Div, Tensor &, X > > = 0> | |
| constexpr auto & | operator/= (X &&rhs) & |
| /= operator for Tensor | |
| template<class E = IsSatisfied<(Dimension() == 0)>, If< E > = 0> | |
| constexpr | operator T () const |
| Conversion operator for zero-dimensional Tensors. | |
Static Public Member Functions | |
| template<class E = typename Sizes::IsLinearizable, If< E > = 0> | |
| static constexpr auto | size () |
| Returns the number of entries of the Tensor class. | |
| static constexpr auto | size (Index const dimension) |
| Returns the mode size along a particular axis of the Tensor class. | |
| template<class X , class... Is, If< IsConstructible< T, X > > = 0, If< All< IsConvertible< Is, Index >... > > = 0, If< IsSatisfied<(sizeof...(Is)==Dimension())> > = 0> | |
| static constexpr auto | Single (X &&value, Is const ... indices) |
| Returns a Tensor of the Tensor class with a single non-zero entry. | |
| template<class X , If< IsConstructible< T, X > > = 0> | |
| static constexpr auto | Single (X &&value, Subscripts const &subscripts) |
| Returns a Tensor of the Tensor class with a single non-zero entry. | |
Class storing tensors.
This class is used to store tensors in pRC. All entries of the Tensor have to have the same type, and both type and mode sizes of the Tensor are set at compile time.
Calculations using Tensors use lazy evaluation for more efficient calculations.
See Tensorish Types in pRC for more details.
| T | pRC value class, class of the tensor entries |
| Ns... | parameter pack of class pRC::Size..., mode sizes of the tensor |
| using pRC::Tensor< T, Ns >::ChangeSigned = Tensor<typename T::template ChangeSigned<R>, Ns...> |
| using pRC::Tensor< T, Ns >::ChangeValue = Tensor<typename T::template ChangeValue<V>, Ns...> |
| using pRC::Tensor< T, Ns >::ChangeWidth = Tensor<typename T::template ChangeWidth<Q>, Ns...> |
| using pRC::Tensor< T, Ns >::Dimension = typename Sizes::Dimension |
| using pRC::Tensor< T, Ns >::IsComplexified = typename T::IsComplexified |
| using pRC::Tensor< T, Ns >::Sizes = pRC::Sizes<Ns...> |
| using pRC::Tensor< T, Ns >::Subscripts = pRC::Subscripts<Ns...> |
|
inlineconstexpr |
Tensor initializer from compatible tensorish object.
| X | Tensorish class (inferred) |
| other | object of class X |
Applies an object from the left.
Applies an object from the left to *this, and returns the result.
Depending on the argument, matrix-multiplication or scalar multiplication is performed.
| X | Tensorish class or pRC value class (inferred) |
| lhs | object of class X that is applied from the left |
Applies an object from the right.
Applies an object from the right to *this, and returns the result.
Depending on the argument, matrix-multiplication or scalar multiplication is performed.
| X | Tensorish class or pRC value class (inferred) |
| rhs | object of class X that is applied from the right |
|
inlineexplicitconstexpr |
Conversion operator for zero-dimensional Tensors.
This operator allows for type casting from Tensor<T> to T. This is only defined for zero-dimensional Tensors, i.e. Tensors with only one element, as it is not a well-defined operation otherwise.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
*= operator for Tensor
Multiplies an object to the tensor. This returns the same as calling applyOnTheRight().
| X | Tensorish class or pRC value class (inferred) |
| rhs | object of class X, multiplicator |
|
inlineconstexpr |
+= operator for Tensors
| X | Tensorish class (inferred) |
| rhs | object of class X, addend |
|
inlineconstexpr |
-= operator for Tensors
| X | Tensorish class (inferred) |
| rhs | object of class X, subtrahend |
|
inlineconstexpr |
/= operator for Tensor
Divides the tensor by an object. This function does element-wise division if given a Tensor of the same size. If given a value, every entry of the tensor is divided by the value.
| X | Tensorish class or pRC value class (inferred) |
| rhs | object of class X, numerator |
|
constexprdefault |
|
constexprdefault |
|
inlineconstexpr |
Tensor assignment from compatible tensorish objects.
| X | Tensorish class (inferred) |
| other | object of class X |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlinestaticconstexpr |
Returns a Tensor of the Tensor class with a single non-zero entry.
The class of the value passed has to be compatible with the Tensor's value class, meaning the Tensor's value class has to be constructible from an object of class X. Additionally, the number of indices passed has to match the Tensor's dimension.
| X | pRC value class (inferred) |
| Is... | parameter pack of classes convertible to Index (inferred) |
| value | object of class X, value of the non-zero entry |
| indices... | parameter pack of classes Is..., indices of the non-zero entry |
|
inlinestaticconstexpr |
Returns a Tensor of the Tensor class with a single non-zero entry.
The class of the value passed has to be compatible with the tensor's value class, meaning the Tensor's value class has to be constructible from an object of class X.
| X | pRC value class (inferred) |
| value | object of class X, value of the non-zero entry |
| subscripts | pRC::Subscripts object specifying the indices of the non-zero entry |
Returns the number of entries of the Tensor class.
Returns the mode size along a particular axis of the Tensor class.
| dimension | pRC::Index specifying the axis |