OpenKalman
SelfAdjointView.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_SELFADJOINTVIEW_HPP
17 #define OPENKALMAN_EIGEN_SELFADJOINTVIEW_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman
23 {
24  namespace interface
25  {
26  template<typename MatrixType, unsigned int UpLo>
27  struct indexible_object_traits<Eigen::SelfAdjointView<MatrixType, UpLo>>
28  {
29  private:
30 
31  using Xpr = Eigen::SelfAdjointView<MatrixType, UpLo>;
32  using IndexType = typename MatrixType::Index;
33 
34  public:
35 
36  using scalar_type = scalar_type_of_t<MatrixType>;
37 
38 
39  template<typename Arg>
40  static constexpr auto count_indices(const Arg& arg) { return OpenKalman::count_indices(arg.nestedExpression()); }
41 
42 
43  template<typename Arg, typename N>
44  static constexpr auto get_vector_space_descriptor(const Arg& arg, N n)
45  {
46  return OpenKalman::get_vector_space_descriptor(arg.nestedExpression(), n);
47  }
48 
49 
50  template<typename Arg>
51  static decltype(auto) nested_object(Arg&& arg)
52  {
53  return std::forward<Arg>(arg).nestedExpression();
54  }
55 
56 
57  template<typename Arg>
58  static constexpr auto get_constant(const Arg& arg)
59  {
61  return constant_coefficient{arg.nestedExpression()};
63  {
65  return constant_coefficient{arg.nestedExpression()};
66  else return std::monostate{};
67  }
68  else return std::monostate{};
69  }
70 
71 
72  template<typename Arg>
73  static constexpr auto get_constant_diagonal(const Arg& arg)
74  {
75  return constant_diagonal_coefficient {arg.nestedExpression()};
76  }
77 
78 
79  template<Applicability b>
80  static constexpr bool one_dimensional = OpenKalman::one_dimensional<MatrixType, b>;
81 
82 
83  template<Applicability b>
84  static constexpr bool is_square = square_shaped<MatrixType, b>;
85 
86 
87  template<TriangleType t>
88  static constexpr bool is_triangular = diagonal_matrix<MatrixType>;
89 
90 
91  static constexpr bool is_triangular_adapter = false;
92 
93 
94  static constexpr bool is_hermitian =
95  (not values::complex<typename Eigen::internal::traits<MatrixType>::Scalar>) or
98 
99 
100  static constexpr HermitianAdapterType hermitian_adapter_type =
101  (UpLo & Eigen::Upper) != 0 ? HermitianAdapterType::upper : HermitianAdapterType::lower;
102 
103  };
104 
105  } // namespace interface
106 
107 
111 #ifdef __cpp_concepts
112  template<Eigen3::eigen_SelfAdjointView M>
113 #else
114  template<typename M, std::enable_if_t<Eigen3::eigen_SelfAdjointView<M>, int> = 0>
115 #endif
116  HermitianAdapter(M&&) -> HermitianAdapter<nested_object_of_t<M>, hermitian_adapter_type_of_v<M>>;
117 
118 } // namespace OpenKalman
119 
120 #endif //OPENKALMAN_EIGEN_SELFADJOINTVIEW_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
A hermitian matrix wrapper.
Definition: HermitianAdapter.hpp:31
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:83
Definition: indexible_object_traits.hpp:36
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
HermitianAdapterType
The type of a hermitian adapter, indicating which triangle of the nested matrix is used...
Definition: global-definitions.hpp:78
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
HermitianAdapter(M &&) -> HermitianAdapter< std::conditional_t< hermitian_adapter< M >, nested_object_of_t< M >, M >, hermitian_adapter< M > ? hermitian_adapter_type_of_v< M > :HermitianAdapterType::lower >
Deduction guide for converting Eigen::SelfAdjointView to HermitianAdapter.
An upper-right triangular matrix.
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
The root namespace for OpenKalman.
Definition: basics.hpp:34
The constant associated with T, assuming T is a constant_diagonal_matrix.
Definition: constant_diagonal_coefficient.hpp:32
constexpr bool fixed
T is a values::value that is determinable at compile time.
Definition: fixed.hpp:60
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:34
A lower-left triangular matrix.
constexpr auto get_vector_space_descriptor(const T &t, const N &n)
Get the coordinates::pattern object for index N of indexible object T.
Definition: get_vector_space_descriptor.hpp:56