16 #ifndef OPENKALMAN_EIGEN_TRAITS_RESHAPED_HPP 17 #define OPENKALMAN_EIGEN_TRAITS_RESHAPED_HPP 19 #include <type_traits> 26 template<
typename XprType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
27 struct ReshapedNested {
using type =
typename Eigen::Reshaped<XprType, Rows, Cols, Order>::MatrixTypeNested; };
29 template<
typename XprType,
int Rows,
int Cols,
int Order>
32 using type =
typename Eigen::internal::ref_selector<XprType>::non_const_type;
37 template<
typename XprType,
int Rows,
int Cols,
int Order>
45 static constexpr std::size_t nested_components = has_dynamic_dimensions<XprType> ? stdex::dynamic_extent :
46 index_dimension_of_v<XprType, 0> * index_dimension_of_v<XprType, 1>;
48 static constexpr std::size_t xprtypemax = dynamic_index_count_v<XprType> < 2 ? std::max(
49 dynamic_dimension<XprType, 0> ? 0 : index_dimension_of_v<XprType, 0>,
50 dynamic_dimension<XprType, 1> ? 0 : index_dimension_of_v<XprType, 1>) : stdex::dynamic_extent;
52 static constexpr
bool HasDirectAccess = Eigen::internal::traits<Eigen::Reshaped<XprType, Rows, Cols, Order>>::HasDirectAccess;
54 using Nested_t =
typename detail::ReshapedNested<XprType, Rows, Cols, Order, HasDirectAccess>::type;
58 template<
typename Arg,
typename N>
61 if constexpr (values::fixed<N>)
63 constexpr
auto dim = n == 0_uz ? Rows : Cols;
64 constexpr
auto other_dim = n == 0_uz ? Cols : Rows;
65 constexpr std::size_t dimension =
66 dim != Eigen::Dynamic ? dim :
67 other_dim == Eigen::Dynamic or other_dim == 0 ? stdex::dynamic_extent :
68 other_dim == index_dimension_of_v<XprType, 0> ? index_dimension_of_v<XprType, 1> :
69 other_dim == index_dimension_of_v<XprType, 1> ? index_dimension_of_v<XprType, 0> :
70 nested_components != stdex::dynamic_extent and nested_components % other_dim == 0 ? nested_components / other_dim :
71 stdex::dynamic_extent;
73 if constexpr (dimension == stdex::dynamic_extent)
75 if constexpr (n == 0_uz)
return static_cast<std::size_t
>(arg.rows());
76 else return static_cast<std::size_t
>(arg.cols());
78 else return Dimensions<dimension>{};
82 if (n == 0_uz)
return static_cast<std::size_t
>(arg.rows());
83 else return static_cast<std::size_t
>(arg.cols());
88 template<
typename Arg>
91 return std::forward<Arg>(arg).nestedExpression();
95 template<
typename Arg>
96 static constexpr
auto get_constant(
const Arg& arg)
102 template<
typename Arg>
103 static constexpr
auto get_constant_diagonal(
const Arg& arg)
105 if constexpr ((Rows != Eigen::Dynamic and Rows == XprType::RowsAtCompileTime) or (Cols != Eigen::Dynamic and Cols == XprType::ColsAtCompileTime))
106 return constant_diagonal_value {arg.nestedExpression()};
108 return std::monostate{};
112 template<applicability b>
114 (Rows == 1 and Cols == 1 and OpenKalman::one_dimensional<XprType, applicability::permitted>) or
115 ((Rows == 1 or Rows == Eigen::Dynamic) and (Cols == 1 or Cols == Eigen::Dynamic) and OpenKalman::one_dimensional<XprType, b>);
118 template<applicability b>
119 static constexpr
bool is_square =
121 ((Rows != Eigen::Dynamic or Cols != Eigen::Dynamic) and not has_dynamic_dimensions<XprType>)) and
122 (Rows == Eigen::Dynamic or Cols == Eigen::Dynamic or Rows == Cols) and
123 (nested_components == stdex::dynamic_extent or (
125 (Rows == Eigen::Dynamic or Rows * Rows == nested_components))) and
126 (Rows == Eigen::Dynamic or xprtypemax == stdex::dynamic_extent or (Rows * Rows) % xprtypemax == 0) and
127 (Cols == Eigen::Dynamic or xprtypemax == stdex::dynamic_extent or (Cols * Cols) % xprtypemax == 0);
130 template<triangle_type t>
131 static constexpr
bool triangle_type_value = triangular_matrix<XprType, t> and
132 ((Rows != Eigen::Dynamic and Rows == XprType::RowsAtCompileTime) or (Cols != Eigen::Dynamic and Cols == XprType::ColsAtCompileTime));
135 static constexpr
bool is_triangular_adapter =
false;
138 static constexpr
bool is_hermitian = hermitian_matrix<XprType, applicability::permitted> and
139 ((XprType::RowsAtCompileTime == Eigen::Dynamic and XprType::ColsAtCompileTime == Eigen::Dynamic) or
140 (Rows == Eigen::Dynamic or Rows == XprType::RowsAtCompileTime or Rows == XprType::ColsAtCompileTime) and
141 (Cols == Eigen::Dynamic or Cols == XprType::ColsAtCompileTime or Cols == XprType::RowsAtCompileTime));
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:56
Definition: basics.hpp:41
The concept, trait, or restraint represents a compile-time guarantee.
Definition: eigen-comma-initializers.hpp:20
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:59
constexpr auto near(const Arg1 &arg1, const Arg2 &arg2)
Determine whether two numbers are within a rounding tolerance.
Definition: near.hpp:46
Definition: object_traits.hpp:38
constexpr auto sqrt(const Arg &arg)
A constexpr alternative to std::sqrt.
Definition: sqrt.hpp:46
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:35
Definition: Reshaped.hpp:27