Tensor¶
-
template<typename
T, std::size_tDim, std::size_tRank>
classtensor: public tmech::tensor_base<tensor<T, Dim, Rank>>¶ Dense multidimensional tensor.
- Template Parameters
T: The type of the tensor holding the elements.Dim: Dimension of the underlying physical problem.Rank: Rank of the tensor.
In-place arithmetic operators
-
template<typename
_Tensor, std::enable_if_t<is_tensor_type<typename std::decay<_Tensor>::type>::value>* = nullptr>
constexpr auto const &operator+=(_Tensor &&__rhs) noexcept¶ In-place tensor subtraction.
- Parameters
rhs: Right hand side tensor expression of subtraction.
-
template<typename
_Tensor, std::enable_if_t<is_tensor_type<typename std::decay<_Tensor>::type>::value>* = nullptr>
constexpr auto const &operator-=(_Tensor &&__rhs) noexcept¶ In-place tensor addition.
- Parameters
rhs: Right hand side tensor expression of addtion.
-
template<typename
_Tensor, std::enable_if_t<is_tensor_type<typename std::decay<_Tensor>::type>::value>* = nullptr>
constexpr auto const &operator*=(_Tensor &&__rhs) noexcept¶ In-place tensor single contraction.
- Parameters
rhs: Right hand side tensor expression of single contraction.
-
constexpr auto const &
operator*=(value_type const value) noexcept¶ In-place tensor element-wise scalar multiplication.
- Parameters
value: Value of element-wise scalar multiplication.
-
constexpr auto const &
operator/=(value_type const value) noexcept¶ In-place tensor element-wise scalar division.
- Parameters
value: Value of element-wise scalar division.
Data
-
template<typename ...
Indicies>
constexpr auto const &operator()(Indicies const... indices) const noexcept¶ Returns a constant reference of the element at the specified position in the tensor.
- Parameters
indicies: a list of indices specifying the position in the tensor. Indices must be unsigned integers, the number of indices must be equal to the rank of the expression.
-
template<typename ...
Indicies>
constexpr auto &operator()(Indicies const... indices) noexcept¶ Returns a reference of the element at the specified position in the tensor.
- Parameters
indicies: a list of indices specifying the position in the tensor. Indices must be unsigned integers, the number of indices must be equal to the rank of the expression.
-
constexpr auto
begin() noexcept¶ Returns an iterator to the first element of the tensor.
-
constexpr auto
end() noexcept¶ Returns an iterator to the element following the last element of the tensor.
-
constexpr auto
begin() const noexcept¶ Returns a constant iterator to the first element of the tensor.
-
constexpr auto
end() const noexcept¶ Returns a constant iterator to the element following the last element of the tensor.
Dimension and rank
-
constexpr auto
rank() noexcept¶ Returns the rank of the tensor.
-
constexpr auto
dimension() noexcept¶ Returns the dimension of the tensor.
-
constexpr auto
size() noexcept¶ Returns the size of the underlying array.
Deconstructor
-
~tensor()¶ Deallocates a Dim-dimensional Rank-tensor.
Constructors
-
tensor()¶ Allocates a Dim-dimensional Rank-tensor. All elements are set to zero.
Constructors from initializer list
-
tensor(std::initializer_list<value_type> const &data)¶ Allocates a Dim-dimensional Rank-tensor.
- Parameters
l: The elements of the tensor.
Extended copy semantic
-
template<typename
_Tensor, std::enable_if_t<is_tensor_type<_Tensor>::value>* = nullptr>tensor(_Tensor const &tensor_base)¶ The extended copy constructor.
-
constexpr std::ostream &
print(std::ostream &os) const¶
-
constexpr auto
fill(value_type const value) noexcept¶
-
auto const &
randu() noexcept¶
-
auto const &
randn() noexcept¶
-
template<typename
_Sequence>
constexpr autochange_basis_view() noexcept¶
Public Types
-
using
size_type= std::size_t¶
Public Functions
-
constexpr auto const &
operator=(tensor const &tensor) noexcept¶ Assigns tensors to each other.
- Note
This is a special case of the templated operator=. Its purpose is to prevent a default operator= from hiding the templated operator=.
-
template<typename
Derived>
constexpr auto const &operator=(tensor_base<Derived> const &tensor_base) noexcept¶
-
template<typename
_Tensor, std::enable_if_t<is_tensor_type<typename std::decay<_Tensor>::type>::value>* = nullptr>
constexpr auto const &operator=(_Tensor &&__tensor) noexcept¶
-
constexpr auto
direct_access(std::size_t __idx) const noexcept¶
Public Static Functions
-
constexpr auto
simple_evaluation()¶
Public Static Attributes
-
constexpr bool dynamic_memory = {((Size <= TMECH_MAX_STATIC_SIZE) ? false : true)}
Friends
-
template<typename
_TensorLHS, typename_TensorRHS, typename, typename>
friend constexpr autooperator==(_TensorLHS &&__lhs, _TensorRHS &&__rhs) noexcept¶
-
template<typename
_TensorLHS, typename_TensorRHS, typename, typename>
friend constexpr autooperator!=(_TensorLHS &&__lhs, _TensorRHS &&__rhs) noexcept¶