16#include "dune/common/fvector.hh"
17#include "dune/common/fmatrix.hh"
28 template <
int first,
int last>
32 template <
class Entry,
int Size0,
int ... Sizes>
38 namespace TensorDetail
40 template <
class Entry,
int Size>
43 template <
class Entry,
int SizePre,
int Size0,
int ... Sizes>
44 struct Prepend<Tensor<Entry,Size0,Sizes...>,SizePre> {
using type = Tensor<Entry,SizePre,Size0,Sizes...>; };
48 namespace ScalarDetail
50 template <
class K,
int Size0,
int ... Sizes>
51 struct Rank<Tensor<K,Size0,Sizes...>>
53 static constexpr int value = Tensor<K,Size0,Sizes...>
::rank;
60 namespace TensorAccess
84 template <
class Entry,
int Size0,
int ... Sizes>
88 static_assert(Size0>0);
89 static constexpr int Size1 =
Tensor<Entry,Sizes...>::dimension;
128 static_assert(
rank==2);
129 if constexpr (
rank==2)
130 for (
int i=0; i<Size0; ++i)
162 template <
class ... Access>
165 return (*
this)[i0](is...);
168 template <
int first,
int last,
class ... Access>
171 constexpr int s =
std::min(Size0,last-first);
172 using SubT =
decltype( (*this)[0](is...) );
173 using R =
typename TensorDetail::Prepend<SubT,s>::type;
175 for (
int i=0; i<s; ++i)
176 r[i] = (*
this)[i+first](is...);
187 operator std::conditional_t<
rank==2,
191 if constexpr(
rank==2)
197 for (
int i=0; i<Size0; ++i)
210 template <
class Entry,
int Size0>
236 static_cast<Base&
>(*this) = v;
245 template <
int first,
int last>
248 constexpr int s =
std::min(Size0,last-first);
251 for (
int i=0; i<s; ++i)
252 r[i] = (*
this)[i+first];
258 static_cast<Base&
>(*this) *= x;
265 template <
class Entry,
int ... Sizes>
280 template <
class Entry,
int Size0,
int ...Sizes>
294 template <
class Entry,
int n>
298 for (
int i=0; i<n; ++i)
306 template <
class Entry,
int ... Sizes>
310 for (
int i=1; i<std::size(t); ++i)
329 template <
class K,
int Size0,
int ... Sizes>
330 struct FieldTraits<
Kaskade::Tensor<K,Size0,Sizes...>>
332 using field_type =
typename FieldTraits<K>::field_type;
333 using real_type =
typename FieldTraits<K>::real_type;
Scalar Real
The real type on which the scalar field is based.
Tensor & operator=(Base const &v)
auto operator()(StaticIndexRange< first, last >) const
Entry operator()(int i) const
Tensor & operator*=(field_type const &x)
Tensor & operator=(Entry const &e)
typename EntryTraits< Entry >::field_type field_type
A class for representing tensors of arbitrary static rank and extents.
auto operator()(int i0, Access... is) const
static constexpr int rank
The rank of the tensor.
Tensor & operator=(Entry const &e)
Assignment from a scalar.
Tensor & operator=(Dune::FieldMatrix< Entry, Size0, Size1 > const &a)
auto operator()(StaticIndexRange< first, last >, Access... is) const
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
Entry trace(Tensor< Entry, n, n > const &A)
Trace of a square matrix-shaped tensor.
constexpr int rank
Reports the rank of vector, matrix, and tensor types of static size.
constexpr StaticIndexRange< 0, std::numeric_limits< int >::max()> _
Convenience static range denoting the full available range, analogous to Matlab's :.
Dune::FieldVector< T, n > min(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise minimum.
Dune::BlockVector< FieldType > operator*(Dune::Matrix< FieldType > const &A, Dune::BlockVector< FieldType > const &x)
std::ostream & operator<<(std::ostream &s, std::vector< Scalar > const &vec)
typename EntryTraits< Entry >::field_type field_type
typename ScalarTraits< field_type >::Real real_type
static int const lapackLayout
A compile-time index range.