16 #ifndef OPENKALMAN_EIGEN_PARTIALREDUXEXPR_HPP 17 #define OPENKALMAN_EIGEN_PARTIALREDUXEXPR_HPP 19 #include <type_traits> 25 template<
typename Dim,
typename OtherDim>
28 template<
typename Dim,
typename OtherDim,
typename =
void>
31 template<
typename Dim,
typename OtherDim>
33 values::fixed<Dim> and values::fixed<OtherDim>>>
34 : std::bool_constant<std::decay_t<Dim>::value >= std::decay_t<OtherDim>
::value> {};
36 template<
typename Dim,
typename OtherDim>
41 template<
typename MemberOp, std::
size_t direction,
typename XprType,
typename Factor,
typename DirDim,
typename Func>
42 constexpr
auto get_constant_redux(
const XprType& xpr,
const Factor& factor,
const DirDim& dir_dim, Func&& func)
44 auto dim = internal::most_fixed_pattern(dir_dim, get_index_dimension_of<direction>(xpr));
46 if constexpr (Eigen3::eigen_MatrixWrapper<XprType> or Eigen3::eigen_ArrayWrapper<XprType> or
47 internal::fixed_size_adapter<XprType> or Eigen3::eigen_wrapper<XprType>)
49 return get_constant_redux<MemberOp, direction>(
nested_object(xpr), factor, dim, std::forward<Func>(func));
51 else if constexpr (Eigen3::eigen_CwiseUnaryOp<XprType> or Eigen3::eigen_CwiseUnaryView<XprType>)
54 return get_constant_redux<MemberOp, direction>(xpr.nestedExpression(), factor, dim, std::move(new_func));
56 else if constexpr (Eigen3::eigen_Replicate<XprType>)
59 const auto& n_xpr = xpr.nestedExpression();
60 auto n_dim = get_index_dimension_of<direction>(n_xpr);
62 auto f = [](
const auto& dim,
const auto& n_dim) {
63 if constexpr (
F::value != stdex::dynamic_extent)
return F{};
67 auto new_dim = [](
const auto& dim,
const auto& n_dim) {
76 return get_constant_redux<MemberOp, direction>(n_xpr, new_f, new_dim, std::forward<Func>(func));
80 if constexpr (constant_matrix<XprType>)
85 else if constexpr (constant_diagonal_matrix<XprType>)
87 constexpr
bool als = at_least_square<decltype(dim), decltype(get_index_dimension_of<direction == 1 ? 0 : 1>(xpr))>;
88 auto c =
values::operation(std::forward<Func>(func), constant_diagonal_value {xpr});
93 return std::monostate {};
108 template<
typename MatrixType,
typename MemberOp,
int Direction>
118 template<
typename Arg>
121 return std::forward<Arg>(arg).nestedExpression();
128 template<
typename Arg>
129 static constexpr
auto get_constant(
const Arg& arg)
132 constexpr std::size_t direction = Direction == Eigen::Horizontal ? 1 : 0;
133 const auto& x = arg.nestedExpression();
134 auto dim = get_index_dimension_of<direction>(x);
135 std::integral_constant<std::size_t, 1> f;
136 return OpenKalman::Eigen3::detail::get_constant_redux<MemberOp, direction>(x, f, dim,
stdex::identity{});
Definition: language-features.hpp:228
Definition: basics.hpp:41
Definition: eigen-comma-initializers.hpp:20
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition: eigen-forward-declarations.hpp:97
Definition: object_traits.hpp:38
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
Definition: PartialReduxExpr.hpp:29
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
The replication factor for Eigen::Replicate in a given direction.
Definition: eigen-forward-declarations.hpp:310
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
Compose two Eigen functors F1 and F2.
Definition: functor_composition.hpp:29
Basic definitions for OpenKalman as a whole.
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:35
constexpr auto operation(Operation &&op, Args &&...args)
A potentially constant-evaluated operation involving some number of values.
Definition: operation.hpp:98