OpenKalman
Product.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) 2019-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_PRODUCT_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_PRODUCT_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename LhsType, typename RhsType, int Option>
25  struct indexible_object_traits<Eigen::Product<LhsType, RhsType, Option>>
26  : Eigen3::indexible_object_traits_base<Eigen::Product<LhsType, RhsType, Option>>
27  {
28  private:
29 
30  using Xpr = Eigen::Product<LhsType, RhsType, Option>;
32 
33  public:
34 
35  using typename Base::scalar_type;
36 
37 
38  // nested_object not defined
39 
40 
41  template<typename Arg>
42  static constexpr auto get_constant(const Arg& arg)
43  {
44  if constexpr (zero<LhsType>)
45  {
46  return constant_coefficient{arg.lhs()};
47  }
48  else if constexpr (zero<RhsType>)
49  {
50  return constant_coefficient{arg.rhs()};
51  }
52  else if constexpr (constant_diagonal_matrix<LhsType> and constant_matrix<RhsType>)
53  {
54  return values::operation {
55  std::multiplies<scalar_type>{},
57  constant_coefficient{arg.rhs()}};
58  }
59  else if constexpr (constant_matrix<LhsType> and constant_diagonal_matrix<RhsType>)
60  {
61  return values::operation {
62  std::multiplies<scalar_type>{},
63  constant_coefficient{arg.lhs()},
65  }
66  else
67  {
68  constexpr auto dim = dynamic_dimension<LhsType, 1> ? index_dimension_of_v<RhsType, 0> : index_dimension_of_v<LhsType, 1>;
69  if constexpr (dim == dynamic_size)
70  {
71  return values::operation {
72  std::multiplies<scalar_type>{},
73  get_index_dimension_of<1>(arg.lhs()),
74  values::operation {std::multiplies<scalar_type>{}, constant_coefficient{arg.lhs()}, constant_coefficient{arg.rhs()}}};
75  }
76  else if constexpr (values::fixed<constant_coefficient<LhsType>>)
77  {
78  return values::operation {
79  std::multiplies<scalar_type>{},
80  values::operation {std::multiplies<scalar_type>{}, std::integral_constant<std::size_t, dim>{}, constant_coefficient{arg.lhs()}},
81  constant_coefficient{arg.rhs()}};
82  }
83  else
84  {
85  return values::operation {
86  std::multiplies<scalar_type>{},
87  values::operation {std::multiplies<scalar_type>{}, std::integral_constant<std::size_t, dim>{}, constant_coefficient{arg.rhs()}},
88  constant_coefficient{arg.lhs()}};
89  }
90  }
91  }
92 
93 
94  template<typename Arg>
95  static constexpr auto get_constant_diagonal(const Arg& arg)
96  {
97  return values::operation {std::multiplies<scalar_type>{},
99  }
100 
101 
102  template<TriangleType t>
103  static constexpr bool is_triangular = triangular_matrix<LhsType, t> and triangular_matrix<RhsType, t>;
104 
105 
106  static constexpr bool is_triangular_adapter = false;
107 
108 
110  static constexpr bool is_hermitian =
111  (constant_diagonal_matrix<LhsType> and
114  (constant_diagonal_matrix<RhsType> and
115  (not values::complex<scalar_type_of_t<RhsType>> or values::not_complex<constant_diagonal_coefficient<RhsType>>) and
117 
118  };
119 
120 
121 } // namespace OpenKalman::interface
122 
123 #endif //OPENKALMAN_EIGEN_TRAITS_PRODUCT_HPP
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
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
constexpr bool complex
T is a values::value that reduces to std::complex or a custom complex type.
Definition: complex.hpp:46
Definition: eigen-comma-initializers.hpp:20
constexpr bool not_complex
T is a values::value in which either its type is not a values::complex or its imaginary component is ...
Definition: not_complex.hpp:47
constexpr bool constant_diagonal_matrix
Specifies that all diagonal elements of a diagonal object are the same constant value.
Definition: constant_diagonal_matrix.hpp:34
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
The concept, trait, or restraint is permitted, but whether it applies is not necessarily known at com...
The constant associated with T, assuming T is a constant_diagonal_matrix.
Definition: constant_diagonal_coefficient.hpp:32
Applicability
The applicability of a concept, trait, or restraint.
Definition: global-definitions.hpp:93
constexpr bool fixed
T is a values::value that is determinable at compile time.
Definition: fixed.hpp:60
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33
constexpr bool hermitian_matrix
Specifies that a type is a hermitian matrix (assuming it is square_shaped).
Definition: hermitian_matrix.hpp:50