OpenKalman
Ref.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_REF_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_REF_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename PlainObjectType, int Options, typename StrideType>
25  struct object_traits<Eigen::Ref<PlainObjectType, Options, StrideType>>
26  : Eigen3::object_traits_base<Eigen::Ref<PlainObjectType, Options, StrideType>>
27  {
28  template<typename Arg>
29  static constexpr auto get_constant(const Arg& arg)
30  {
31  if constexpr (values::fixed<constant_value<PlainObjectType>>)
32  return constant_value<PlainObjectType> {};
33  else
34  return std::monostate {};
35  }
36 
37  template<typename Arg>
38  static constexpr auto get_constant_diagonal(const Arg& arg)
39  {
40  if constexpr (values::fixed<constant_diagonal_value<PlainObjectType>>)
41  return constant_diagonal_value<PlainObjectType> {};
42  else
43  return std::monostate {};
44  }
45 
46 
47  static constexpr data_layout layout = std::is_same_v<StrideType, Eigen::Stride<0, 0>> ? layout_of_v<PlainObjectType> : data_layout::stride;
48 
49  };
50 
51 
52 }
53 
54 #endif
Definition: basics.hpp:41
Definition: eigen-comma-initializers.hpp:20
Definition: object_traits.hpp:38
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66