OpenKalman
MatrixWrapper.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_MATRIXWRAPPER_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_MATRIXWRAPPER_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename XprType>
25  struct object_traits<Eigen::MatrixWrapper<XprType>>
26  : Eigen3::object_traits_base<Eigen::MatrixWrapper<XprType>>
27  {
28  private:
29 
30  using NestedXpr = typename Eigen::MatrixWrapper<XprType>::NestedExpressionType;
32 
33  public:
34 
35  template<typename Arg, typename N>
36  static constexpr auto get_pattern_collection(const Arg& arg, N n)
37  {
38  return OpenKalman::get_pattern_collection(arg.nestedExpression(), n);
39  }
40 
41 
42  template<typename Arg>
43  static NestedXpr nested_object(Arg&& arg)
44  {
45  if constexpr (std::is_lvalue_reference_v<NestedXpr>)
46  return const_cast<NestedXpr>(std::forward<Arg>(arg).nestedExpression());
47  else
48  return static_cast<NestedXpr>(std::forward<Arg>(arg).nestedExpression());
49  }
50 
51 
52  template<typename Arg>
53  static constexpr auto get_constant(const Arg& arg)
54  {
55  return constant_value{arg.nestedExpression()};
56  }
57 
58 
59  template<typename Arg>
60  static constexpr auto get_constant_diagonal(const Arg& arg)
61  {
62  return constant_diagonal_value {arg.nestedExpression()};
63  }
64 
65 
66  template<applicability b>
67  static constexpr bool one_dimensional = OpenKalman::one_dimensional<XprType, b>;
68 
69 
70  template<applicability b>
71  static constexpr bool is_square = square_shaped<XprType, b>;
72 
73 
74  template<triangle_type t>
75  static constexpr bool triangle_type_value = triangular_matrix<XprType, t>;
76 
77 
78  static constexpr bool is_triangular_adapter = false;
79 
80 
81  static constexpr bool is_hermitian = hermitian_matrix<XprType, applicability::permitted>;
82 
83 
84  static constexpr data_layout layout = layout_of_v<XprType>;
85  };
86 
87 
88 }
89 
90 #endif
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:56
Definition: basics.hpp:41
Definition: eigen-comma-initializers.hpp:20
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:59
Definition: object_traits.hpp:38
Trait object providing get and set routines.
Definition: eigen-forward-declarations.hpp:502
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:35