OpenKalman
nullary.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_NULLARYFUNCTORTRAITS_HPP
17 #define OPENKALMAN_EIGEN_NULLARYFUNCTORTRAITS_HPP
18 
20 
21 namespace OpenKalman::Eigen3
22 {
23  // Default nullary traits, if NullaryOp is not specifically matched.
24  template<typename NullaryOp, typename PlainObjectType>
25  struct NullaryFunctorTraits
26  {
27  template<typename Arg>
28  static constexpr auto get_constant(const Arg& arg) { return arg.functor()(); }
29 
30  template<typename Arg>
31  static constexpr auto get_constant_diagonal(const Arg&) { return std::monostate {}; }
32 
33  template<triangle_type t>
34  static constexpr bool triangle_type_value = false;
35 
36  static constexpr bool is_hermitian = false;
37  };
38 
39 
40  template<typename Scalar, typename PlainObjectType>
41  struct NullaryFunctorTraits<Eigen::internal::scalar_identity_op<Scalar>, PlainObjectType>
42  {
43  template<typename Arg>
44  static constexpr auto get_constant(const Arg&) { return std::monostate {}; }
45 
46  template<typename Arg>
47  static constexpr auto get_constant_diagonal(const Arg&) { return values::fixed_value<Scalar, 1>{}; }
48 
49  static constexpr triangle_type triangle_type_value = triangle_type::diagonal;
50 
51  static constexpr bool is_hermitian = true;
52  };
53 
54 
55  template<typename Scalar, typename PlainObjectType>
56  struct NullaryFunctorTraits<Eigen::internal::linspaced_op<Scalar>, PlainObjectType>
57  {
58  template<typename Arg>
59  static constexpr auto get_constant(const Arg&) { return std::monostate {}; }
60 
61  template<typename Arg>
62  static constexpr auto get_constant_diagonal(const Arg&) { return std::monostate {}; }
63 
64  template<triangle_type t>
65  static constexpr bool triangle_type_value = false;
66 
67  static constexpr bool is_hermitian = false;
68  };
69 
70 
71  template<typename Scalar, typename PlainObjectType>
72  struct NullaryFunctorTraits<Eigen::internal::scalar_constant_op<Scalar>, PlainObjectType>
73  {
74  template<typename Arg>
75  static constexpr auto get_constant(const Arg& arg) { return arg.functor()(); }
76 
77  template<typename Arg>
78  static constexpr auto get_constant_diagonal(const Arg&) { return std::monostate {}; }
79 
80  template<triangle_type t>
81  static constexpr bool triangle_type_value = false;
82 
83  static constexpr bool is_hermitian = not values::complex<Scalar>;
84  };
85 
86 }
87 
88 #endif
triangle_type
The type of a triangular matrix.
Definition: enumerations.hpp:26
Definition: fixed_value.hpp:41
Definition: eigen-forward-declarations.hpp:32
Definition: eigen-comma-initializers.hpp:20
A diagonal matrix (both a lower-left and an upper-right triangular matrix).
Definition: eigen-forward-declarations.hpp:22
Definition for triangle_type_of.