1#ifndef __DUNE_ACFEM_TENSORS_TENSORRESULT_HH__
2#define __DUNE_ACFEM_TENSORS_TENSORRESULT_HH__
4#include "../../../expressions/storage.hh"
5#include "../../../common/literals.hh"
6#include "../../tensorbase.hh"
7#include "densevectorview.hh"
30 template<
class Tensor>
35 :
public DenseVectorView<T, Expressions::Storage<OperationTraits<IdentityOperation>, T> >
36 ,
public TensorBase<typename TensorTraits<T>::FieldType, typename TensorTraits<T>::Signature, TensorResult<T> >
38 static_assert(IsTensor<T>::value,
39 "TensorResult should only be applied to tensors.");
41 using TensorType = std::decay_t<T>;
45 using StorageType::operation;
46 using StorageType::operand;
47 using StorageType::arity;
48 using StorageType::OperandType;
49 using typename StorageType::FunctorType;
50 using typename StorageType::OperationType;
51 using ExpressionType = std::decay_t<T>;
53 using typename BaseType::FieldType;
66 && std::is_assignable<typename TensorTraits<T>::ElementZero,
67 typename TensorTraits<Other>::FieldType>::value
71 operand(0_c) = std::forward<Other>(other);
76 using StorageType::t0_;
79 ExpressionType* operator->()
84 const ExpressionType* operator->()
const
89 decltype(
auto) storage() &
94 decltype(
auto) storage() &&
99 decltype(
auto) storage()
const&
105 template<
class... Dims,
106 std::enable_if_t<(
sizeof...(Dims) == rank
110 decltype(
auto)
operator()(Dims... indices)
112 return operand(0_c)(indices...);
116 template<
class... Dims,
117 std::enable_if_t<(
sizeof...(Dims) == rank
121 decltype(
auto)
operator()(Dims... indices)
const
123 return operand(0_c)(indices...);
127 template<std::size_t... Indices, std::enable_if_t<
sizeof...(Indices) == rank,
int> = 0>
130 return operand(0_c)(Seq<Indices...>{});
134 template<std::size_t... Indices, std::enable_if_t<
sizeof...(Indices) == rank,
int> = 0>
137 return operand(0_c)(Seq<Indices...>{});
141 template<std::
size_t I>
144 return operand(0_c)[i];
148 template<std::
size_t I>
151 return operand(0_c)[i];
155 template<std::
size_t I>
158 return operand(0_c)[i];
162 template<std::size_t... Indices,
class Pos =
MakeIndexSequence<
sizeof...(Indices)> >
163 static bool constexpr isZero(Seq<Indices...> = Seq<Indices...>{}, Pos = Pos{})
165 return TensorType::isZero(Seq<Indices...>{}, Pos{});
168 std::string name()
const
170 std::string pfx = std::is_reference<T>::value ? (RefersConst<T>::value ?
"cref" :
"ref") :
"";
171 return "<cls "+pfx+operand(0_c).name()+
"/>";
177 return std::move(operand(0_c));
180 operator decltype(
auto) ()
const&
185 operator decltype(
auto) ()&
197 struct FieldTraits<ACFem::Tensor::TensorResult<T> >
198 : FieldTraits<std::decay_t<T> >
Definition: densevectorview.hh:113
The wrapper class wrapped around each expression result.
Definition: tensorresult.hh:37
decltype(auto) constexpr operator()(Seq< Indices... >) const
Compile-time constant access from index-sequence.
Definition: tensorresult.hh:135
decltype(auto) constexpr operator()(Seq< Indices... >)
Compile-time constant access from index-sequence.
Definition: tensorresult.hh:128
static bool constexpr isZero(Seq< Indices... >=Seq< Indices... >{}, Pos=Pos{})
Compile-time constant access from index-sequence.
Definition: tensorresult.hh:163
MakeSequence< std::size_t, N, Offset, Stride, Repeat > MakeIndexSequence
Make a sequence of std::size_t elements.
Definition: generators.hh:34
decltype(isIntegralPack(std::declval< T >()...)) IsIntegralPack
Decide whether the given parameter pack contains only integral types.
Definition: compare.hh:377
Constant< std::size_t, V > IndexConstant
Short-cut for integral constant of type std::size_t.
Definition: types.hh:44
Definition: tensorbase.hh:117
Base class for all tensors.
Definition: tensorbase.hh:144