16 #ifndef OPENKALMAN_EIGEN_TRAITS_TENSORREF_HPP 17 #define OPENKALMAN_EIGEN_TRAITS_TENSORREF_HPP 22 template<
typename PlainObjectType>
29 using Base::max_indices;
30 using Dimensions =
typename PlainObjectType::Dimensions;
31 using Scalar =
typename Eigen::internal::traits<PlainObjectType>::Scalar;
32 using Index =
typename Eigen::internal::traits<PlainObjectType>::Index;
36 template<
typename Arg,
typename N>
37 static constexpr std::size_t get_index_descriptor(
const Arg& arg, N n) {
return arg.dimension(n); }
46 #ifdef __cpp_lib_concepts 47 template<
typename Arg, std::convertible_to<Index>...I> requires (
sizeof...(I) == index_count_v<PlainObjectType>)
49 template<
typename Arg,
typename...I, std::enable_if_t<(std::is_convertible_v<I, Index> and ...) and
52 static constexpr decltype(
auto)
get(Arg&& arg, I...i)
54 if constexpr ((Eigen::internal::traits<std::decay_t<Arg>>::Flags & Eigen::LvalueBit) != 0)
55 return std::forward<Arg>(arg).coeffRef(std::array<Index,
sizeof...(I)>{
static_cast<Index
>(i)...});
57 return std::forward<Arg>(arg).coeff(std::array<Index,
sizeof...(I)>{
static_cast<Index
>(i)...});
61 #ifdef __cpp_lib_concepts 62 template<
typename Arg, std::convertible_to<Index>...I> requires (
sizeof...(I) == index_count_v<PlainObjectType>) and
63 ((Eigen::internal::traits<std::decay_t<Arg>>::Flags & Eigen::LvalueBit) != 0x0)
65 template<
typename Arg,
typename...I, std::enable_if_t<(std::is_convertible_v<I, Index> and ...) and
70 arg.coeffRef(std::array<Index,
sizeof...(I)>{
static_cast<Index
>(i)...}) = s;
73 static constexpr
bool is_writable =
true;
77 static constexpr
Layout layout = layout_of_v<PlainObjectType>;
83 #endif //OPENKALMAN_EIGEN_TRAITS_TENSORREF_HPP Definition: indexible_object_traits.hpp:36
Definition: basics.hpp:41
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
Definition: eigen-comma-initializers.hpp:20
Trait object providing get and set routines for Eigen tensors.
Definition: eigen-tensor-forward-declarations.hpp:114
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47
The minimum number of indices need to access all the components of an object.
Definition: index_count.hpp:33