16 #ifndef OPENKALMAN_EIGEN_TRAITS_TENSORCWISEBINARYOP_HPP 17 #define OPENKALMAN_EIGEN_TRAITS_TENSORCWISEBINARYOP_HPP 22 template<
typename BinaryOp,
typename LhsXprType,
typename RhsXprType>
28 using Xpr = Eigen::TensorCwiseBinaryOp<BinaryOp, LhsXprType, RhsXprType>;
34 template<
typename Arg,
typename N>
38 if constexpr (values::fixed<N>)
40 if constexpr (not dynamic_dimension<LhsXprType, n>)
53 #ifndef __cpp_concepts 54 template<
typename T = Traits,
typename =
void>
55 struct custom_get_constant_defined : std::false_type {};
58 struct custom_get_constant_defined<T, std::void_t<decltype(T::template get_constant<LhsXprType, RhsXprType>(std::declval<const Xpr&>()))>>
61 template<
typename T = Traits,
typename =
void>
62 struct constexpr_operation_defined : std::false_type {};
65 struct constexpr_operation_defined<T, std::void_t<decltype(T::constexpr_operation())>>
71 template<
typename Arg>
72 static constexpr
auto get_constant(
const Arg& arg)
75 if constexpr (requires { Traits::template get_constant<LhsXprType, RhsXprType>(arg); })
79 return Traits::template get_constant<LhsXprType, RhsXprType>(arg);
80 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<LhsXprType>)
82 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<RhsXprType>)
84 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<LhsXprType>)
86 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<RhsXprType>)
89 else if constexpr (requires { Traits::constexpr_operation(); })
102 #ifndef __cpp_concepts 103 template<
typename T = Traits,
typename =
void>
104 struct custom_get_constant_diagonal_defined : std::false_type {};
107 struct custom_get_constant_diagonal_defined<T, std::void_t<decltype(T::template get_constant_diagonal<LhsXprType, RhsXprType>(std::declval<const Xpr&>()))>>
113 template<
typename Arg>
114 static constexpr
auto get_constant_diagonal(
const Arg& arg)
116 #ifdef __cpp_concepts 117 if constexpr (requires { Traits::template get_constant_diagonal<LhsXprType, RhsXprType>(arg); })
121 return Traits::template get_constant_diagonal<LhsXprType, RhsXprType>(arg);
122 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<LhsXprType>)
124 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum and zero<RhsXprType>)
126 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<LhsXprType>)
128 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and zero<RhsXprType>)
130 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::product)
132 auto c_left = [](
const Arg& arg){
136 auto c_right = [](
const Arg& arg){
140 #ifdef __cpp_concepts 141 if constexpr (requires { Traits::constexpr_operation(); })
149 else if constexpr (Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum or Traits::preserves_constant_diagonal)
151 #ifdef __cpp_concepts 152 if constexpr (requires { Traits::constexpr_operation(); })
164 return std::monostate{};
169 template<Applicability b>
171 OpenKalman::one_dimensional<LhsXprType, Applicability::permitted> and OpenKalman::one_dimensional<RhsXprType, Applicability::permitted> and
173 (square_shaped<LhsXprType, b> and (dimension_size_of_index_is<RhsXprType, 0, 1> or dimension_size_of_index_is<RhsXprType, 1, 1>)) or
174 ((dimension_size_of_index_is<LhsXprType, 0, 1> or dimension_size_of_index_is<LhsXprType, 1, 1>) and square_shaped<RhsXprType, b>));
177 template<Applicability b>
178 static constexpr
bool is_square =
179 square_shaped<LhsXprType, Applicability::permitted> and square_shaped<RhsXprType, Applicability::permitted> and
181 square_shaped<LhsXprType, b> or square_shaped<RhsXprType, b>);
184 static constexpr
bool is_triangular_adapter =
false;
187 template<TriangleType t>
188 static constexpr
bool is_triangular =
189 Traits::binary_functor_type == Eigen3::BinaryFunctorType::sum ?
190 triangular_matrix<LhsXprType, t> and triangular_matrix<RhsXprType, t> and
192 Traits::binary_functor_type == Eigen3::BinaryFunctorType::product and
193 (triangular_matrix<LhsXprType, t> or triangular_matrix<RhsXprType, t> or
194 (triangular_matrix<LhsXprType, TriangleType::lower> and triangular_matrix<RhsXprType, TriangleType::upper>) or
195 (triangular_matrix<LhsXprType, TriangleType::upper> and triangular_matrix<RhsXprType, TriangleType::lower>));
198 static constexpr
bool is_hermitian = Traits::preserves_hermitian and
199 hermitian_matrix<LhsXprType, Applicability::permitted> and hermitian_matrix<RhsXprType, Applicability::permitted>;;
205 #endif //OPENKALMAN_EIGEN_TRAITS_TENSORCWISEBINARYOP_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
Lower, upper, or diagonal matrix.
Definition: eigen-comma-initializers.hpp:20
Trait object providing get and set routines for Eigen tensors.
Definition: eigen-tensor-forward-declarations.hpp:114
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
constexpr bool has_dynamic_dimensions
Specifies that T has at least one index with dynamic dimensions.
Definition: has_dynamic_dimensions.hpp:29
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