OpenKalman
VectorBlock.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_VECTORBLOCK_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_VECTORBLOCK_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename VectorType, int Size>
25  struct indexible_object_traits<Eigen::VectorBlock<VectorType, Size>>
26  : Eigen3::indexible_object_traits_base<Eigen::VectorBlock<VectorType, Size>>
27  {
28  private:
29 
31 
32  public:
33 
34  template<typename Arg>
35  static constexpr auto
36  count_indices(const Arg& arg)
37  {
38  constexpr bool is_row_major = (Eigen::internal::traits<std::decay_t<typename Arg::NestedExpression>>::Flags & Eigen::RowMajorBit) != 0x0;
39  return std::integral_constant<std::size_t, is_row_major ? 1 : 0>{};
40  }
41 
42 
43  template<typename Arg>
44  static decltype(auto) nested_object(Arg&& arg)
45  {
46  return std::forward<Arg>(arg).nestedExpression();
47  }
48 
49 
50  // Eigen::VectorBlock should always be converted to Matrix
51 
52 
53  template<typename Arg>
54  static constexpr auto get_constant(const Arg& arg)
55  {
56  return constant_coefficient {arg.nestedExpression()};
57  }
58  };
59 
60 
61 } // namespace OpenKalman::interface
62 
63 #endif //OPENKALMAN_EIGEN_TRAITS_VECTORBLOCK_HPP
constexpr auto count_indices(const T &t)
Get the number of indices available to address the components of an indexible object.
Definition: count_indices.hpp:33
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 constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:34