Tensors¶
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.
-
constexpr T *
raw_data() noexcept Returns a pointer to the memory of the array.
-
constexpr T const *
raw_data() const noexcept Returns a constant pointer to the memory of the array.
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
entry_type= typename detail::get_complex_entry_type<T>::type
-
using
value_type= T
-
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)}
Private Functions
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<!DynamicMemory>* = nullptr>
constexpr autocheck_size()¶
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<DynamicMemory>* = nullptr>
constexpr autocheck_size()¶
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<!DynamicMemory>* = nullptr>
constexpr autocheck_size_fill_zeros()¶
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<DynamicMemory>* = nullptr>
constexpr autocheck_size_fill_zeros()¶
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<!DynamicMemory>* = nullptr>
constexpr autodelete_data()¶
-
template<bool
DynamicMemory= dynamic_memory, typename std::enable_if_t<DynamicMemory>* = nullptr>
constexpr autodelete_data()¶
Private Members
-
value_data_type
_data¶
Friends
- friend class tensor
-
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
Adaptor¶
Warning
doxygenclass: Cannot find class “adaptor_wrapper” in doxygen xml output for project “tmech” from directory: _build/xml
Identity¶
-
template<typename
T, std::size_tDim, std::size_tRank>
classeye: public tmech::tensor_base<eye<T, Dim, Rank>>¶ Identity tensor. Only for a Rank which is a multiplier of two.
- Template Parameters
T: The type of the tensor holding the elements.Dim: Dimension of the underlying physical problem.Rank: Rank of the tensor. Rank needs to be a multiplier of two.
Constructors
-
constexpr
eye() noexcept¶ Default constructor.
Data
-
template<typename ...
Indices>
constexpr autooperator()(const Indices... indices) const noexcept¶ Returns the element at the specified position in the expression.
- Parameters
indicies: a list of indices specifying the position in the tensor expression. Indices must be unsigned integers, the number of indices must be equal to the rank of the expression.
Dimension and rank
-
constexpr auto
rank() noexcept¶ Returns the rank.
-
constexpr auto
dimension() noexcept¶ Returns the dimension.
Private functions
-
template<typename ...
Indicies>
constexpr autovalue(size_type const i, size_type const j, Indicies const... indices) noexcept¶ Recursive function to determine the element at the specified position.
- Parameters
indicies: a list of indices specifying the position in the tensor expression. Indices must be unsigned integers, the number of indices must be equal to the rank of the expression.
-
constexpr auto
value(size_type const i, size_type const j) noexcept¶ Determines the element at the specified position.
- Parameters
i: First index specifying the position in the tensor expression.j: Second index specifying the position in the tensor expression. Indices must be unsigned integers, the number of indices must be equal to the rank of the expression.
Public Functions
-
~eye() noexcept¶
Public Static Functions
-
constexpr auto
simple_evaluation() noexcept¶
Zeros¶
-
template<typename
T, std::size_tDim, std::size_tRank>
classzeros: public tmech::tensor_base<zeros<T, Dim, Rank>>¶ Wrapper for a tensor, which contains only zeros. No memory is initialised.
- Template Parameters
T: The type of the tensor holding the elements.Dim: Dimension of the underlying physical problem.Rank: Rank of the tensor.
Constructors
-
constexpr
zeros() noexcept¶ Default constructor
Data