OpenKalman
eigen-wrapper.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_WRAPPER_HPP
17 #define OPENKALMAN_EIGEN_WRAPPER_HPP
18 
19 namespace OpenKalman::Eigen3
20 {
21 
22  namespace detail
23  {
24  template<typename T>
25  struct is_eigen_wrapper : std::false_type {};
26 
27  template<typename N, typename L>
28  struct is_eigen_wrapper<internal::LibraryWrapper<N, L>> : std::bool_constant<eigen_general<L, true>> {};
29  } // namespace detail
30 
31 
36  template<typename T>
37 #ifdef __cpp_concepts
38  concept eigen_wrapper =
39 #else
40  constexpr bool eigen_wrapper =
41 #endif
43 
44 
51 #ifdef __cpp_concepts
52  template<indexible NestedObject> requires (index_count_v<NestedObject> <= 2)
53 #else
54  template<typename NestedObject>
55 #endif
56  using EigenWrapper = internal::LibraryWrapper<NestedObject,
57  std::conditional_t<eigen_array_general<NestedObject>,
58  Eigen::Array<
60  dynamic_dimension<NestedObject, 0> ? Eigen::Dynamic : static_cast<int>(index_dimension_of_v<NestedObject, 0>),
61  dynamic_dimension<NestedObject, 1> ? Eigen::Dynamic : static_cast<int>(index_dimension_of_v<NestedObject, 1>),
62  layout_of_v<NestedObject> == Layout::right ? Eigen::RowMajor : Eigen::ColMajor>,
63  Eigen::Matrix<
64  scalar_type_of_t<NestedObject>,
65  dynamic_dimension<NestedObject, 0> ? Eigen::Dynamic : static_cast<int>(index_dimension_of_v<NestedObject, 0>),
66  dynamic_dimension<NestedObject, 1> ? Eigen::Dynamic : static_cast<int>(index_dimension_of_v<NestedObject, 1>),
67  layout_of_v<NestedObject> == Layout::right ? Eigen::RowMajor : Eigen::ColMajor>>>;
68 
69 
73 #ifdef __cpp_concepts
74  template<indexible Arg> requires (index_count_v<Arg> <= 2)
75 #else
76  template<typename Arg, std::enable_if_t<indexible<Arg> and (index_count_v<Arg> <= 2), int> = 0>
77 #endif
78  inline auto
79  make_eigen_wrapper(Arg&& arg)
80  {
81  return EigenWrapper<Arg> {std::forward<Arg>(arg)};
82  }
83 
84 } // namespace OpenKalman::Eigen3
85 
86 
87 #endif //OPENKALMAN_EIGEN_WRAPPER_HPP
Row-major storage (C or C++ style): contiguous storage in which the right-most index has a stride of ...
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
Definition: eigen-wrapper.hpp:25
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definition: eigen-forward-declarations.hpp:22
Definition: forward-class-declarations.hpp:580