OpenKalman
CwiseTernaryOp.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2023 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_EIGEN_TRAITS_CWISETERNARYOP_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_CWISETERNARYOP_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
25  struct indexible_object_traits<Eigen::CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
26  : Eigen3::indexible_object_traits_base<Eigen::CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
27  {
28  private:
29 
30  using Xpr = Eigen::CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>;
32 
33  public:
34 
35  template<typename Arg, typename N>
36  static constexpr auto
37  get_vector_space_descriptor(const Arg& arg, N n)
38  {
39  if constexpr (square_shaped<Arg1> or square_shaped<Arg2> or square_shaped<Arg3>)
40  return internal::best_vector_space_descriptor(
41  OpenKalman::get_vector_space_descriptor<0>(arg.arg1()),
42  OpenKalman::get_vector_space_descriptor<0>(arg.arg2()),
43  OpenKalman::get_vector_space_descriptor<0>(arg.arg3()),
44  OpenKalman::get_vector_space_descriptor<1>(arg.arg1()),
45  OpenKalman::get_vector_space_descriptor<1>(arg.arg2()),
46  OpenKalman::get_vector_space_descriptor<1>(arg.arg3()));
47  else
48  return internal::best_vector_space_descriptor(
52  }
53 
54 
55  // nested_object not defined
56 
57 
58  template<typename Arg>
59  static constexpr auto get_constant(const Arg& arg)
60  {
62  return Traits::template get_constant<false>(arg);
63  }
64 
65  template<typename Arg>
66  static constexpr auto get_constant_diagonal(const Arg& arg)
67  {
69  return Traits::template get_constant<true>(arg);
70  }
71 
72  template<Applicability b>
73  static constexpr bool one_dimensional =
74  OpenKalman::one_dimensional<Arg1, Applicability::permitted> and
75  OpenKalman::one_dimensional<Arg2, Applicability::permitted> and
76  OpenKalman::one_dimensional<Arg3, Applicability::permitted> and
78  not has_dynamic_dimensions<Xpr> or
79  OpenKalman::one_dimensional<Arg1, b> or
80  OpenKalman::one_dimensional<Arg2, b> or
81  OpenKalman::one_dimensional<Arg3, b>);
82 
83 
84  template<Applicability b>
85  static constexpr bool is_square =
86  square_shaped<Arg1, Applicability::permitted> and
87  square_shaped<Arg2, Applicability::permitted> and
88  square_shaped<Arg3, Applicability::permitted> and
90  not has_dynamic_dimensions<Xpr> or
91  square_shaped<Arg1, b> or
92  square_shaped<Arg2, b> or
93  square_shaped<Arg3, b>);
94 
95 
96  template<TriangleType t>
97  static constexpr bool is_triangular = Eigen3::TernaryFunctorTraits<TernaryOp, Arg1, Arg2, Arg3>::template is_triangular<t>;
98 
99  static constexpr bool is_triangular_adapter = false;
100 
102  };
103 
104 } // namespace OpenKalman::interface
105 
106 #endif //OPENKALMAN_EIGEN_TRAITS_CWISETERNARYOP_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
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
Definition: eigen-comma-initializers.hpp:20
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
Definition: eigen-forward-declarations.hpp:70