16 #ifndef OPENKALMAN_EIGEN_TRAITS_CWISEBINARYOP_HPP 17 #define OPENKALMAN_EIGEN_TRAITS_CWISEBINARYOP_HPP 22 template<
typename BinaryOp,
typename LhsType,
typename RhsType>
28 using Xpr = Eigen::CwiseBinaryOp<BinaryOp, LhsType, RhsType>;
34 template<
typename Arg,
typename N>
38 if constexpr (square_shaped<LhsType> or square_shaped<RhsType>)
39 return internal::best_vector_space_descriptor(
40 OpenKalman::get_vector_space_descriptor<0>(arg.lhs()),
41 OpenKalman::get_vector_space_descriptor<0>(arg.rhs()),
42 OpenKalman::get_vector_space_descriptor<1>(arg.lhs()),
43 OpenKalman::get_vector_space_descriptor<1>(arg.rhs()));
45 return internal::best_vector_space_descriptor(
55 #ifndef __cpp_concepts 56 template<
typename T = Traits,
typename =
void>
57 struct custom_get_constant_defined : std::false_type {};
60 struct custom_get_constant_defined<T, std::void_t<decltype(T::template get_constant<LhsType, RhsType>(std::declval<const Xpr&>()))>>
63 template<
typename T = Traits,
typename =
void>
64 struct constexpr_operation_defined : std::false_type {};
67 struct constexpr_operation_defined<T, std::void_t<decltype(T::constexpr_operation())>>
73 template<
typename Arg>
74 static constexpr
auto get_constant(
const Arg& arg)
77 if constexpr (requires { Traits::template get_constant<LhsType, RhsType>(arg); })
81 return Traits::template get_constant<LhsType, RhsType>(arg);
82 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<LhsType>)
84 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<RhsType>)
86 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<LhsType>)
88 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<RhsType>)
91 else if constexpr (requires { Traits::constexpr_operation(); })
104 #ifndef __cpp_concepts 105 template<
typename T = Traits,
typename =
void>
106 struct custom_get_constant_diagonal_defined : std::false_type {};
109 struct custom_get_constant_diagonal_defined<T, std::void_t<decltype(T::template get_constant_diagonal<LhsType, RhsType>(std::declval<const Xpr&>()))>>
115 template<
typename Arg>
116 static constexpr
auto get_constant_diagonal(
const Arg& arg)
118 #ifdef __cpp_concepts 119 if constexpr (requires { Traits::template get_constant_diagonal<LhsType, RhsType>(arg); })
123 return Traits::template get_constant_diagonal<LhsType, RhsType>(arg);
124 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<LhsType>)
126 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<RhsType>)
128 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<LhsType>)
130 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<RhsType>)
132 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product)
134 auto c_left = [](
const Arg& arg){
138 auto c_right = [](
const Arg& arg){
142 #ifdef __cpp_concepts 143 if constexpr (requires { Traits::constexpr_operation(); })
151 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum or Traits::preserves_constant_diagonal)
153 #ifdef __cpp_concepts 154 if constexpr (requires { Traits::constexpr_operation(); })
166 return std::monostate{};
171 template<Applicability b>
173 OpenKalman::one_dimensional<LhsType, Applicability::permitted> and
174 OpenKalman::one_dimensional<RhsType, Applicability::permitted> and
176 not has_dynamic_dimensions<Xpr> or
177 OpenKalman::one_dimensional<LhsType, b> or
178 OpenKalman::one_dimensional<RhsType, b>);
181 template<Applicability b>
182 static constexpr
bool is_square =
183 square_shaped<LhsType, Applicability::permitted> and
184 square_shaped<RhsType, Applicability::permitted> and
186 not has_dynamic_dimensions<Xpr> or
187 square_shaped<LhsType, b> or
188 square_shaped<RhsType, b>);
191 static constexpr
bool is_triangular_adapter =
false;
194 template<TriangleType t>
195 static constexpr
bool is_triangular =
196 Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum ?
197 triangular_matrix<LhsType, t> and triangular_matrix<RhsType, t> and
199 Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and
200 (triangular_matrix<LhsType, t> or triangular_matrix<RhsType, t> or
201 (triangular_matrix<LhsType, TriangleType::lower> and triangular_matrix<RhsType, TriangleType::upper>) or
202 (triangular_matrix<LhsType, TriangleType::upper> and triangular_matrix<RhsType, TriangleType::lower>));
205 static constexpr
bool is_hermitian = Traits::preserves_hermitian and
206 hermitian_matrix<LhsType, Applicability::permitted> and hermitian_matrix<RhsType, Applicability::permitted>;;
213 #endif //OPENKALMAN_EIGEN_TRAITS_CWISEBINARYOP_HPP constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:83
Definition: indexible_object_traits.hpp:36
Definition: basics.hpp:41
An operation involving some number of values.
Definition: operation.hpp:69
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
Lower, upper, or diagonal matrix.
Definition: eigen-comma-initializers.hpp:20
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
The constant associated with T, assuming T is a constant_diagonal_matrix.
Definition: constant_diagonal_coefficient.hpp:32
Definition: eigen-forward-declarations.hpp:61
The concept, trait, or restraint represents a compile-time guarantee.
constexpr auto get_vector_space_descriptor(const T &t, const N &n)
Get the coordinates::pattern object for index N of indexible object T.
Definition: get_vector_space_descriptor.hpp:56