OpenKalman
eigen-tensor-forward-declarations.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_TENSOR_FORWARD_DECLARATIONS_HPP
17 #define OPENKALMAN_EIGEN_TENSOR_FORWARD_DECLARATIONS_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::Eigen3
23 {
29  template<typename Derived, typename NestedMatrix>
31 
32 
37  template<typename T, bool must_be_native = false>
38 #ifdef __cpp_concepts
39  concept eigen_tensor_general =
40 #else
41  constexpr bool eigen_tensor_general =
42 #endif
43  std::is_base_of_v<Eigen::TensorBase<std::decay_t<T>, Eigen::ReadOnlyAccessors>, std::decay_t<T>> and
44  (not must_be_native or not std::is_base_of_v<EigenCustomBase, std::decay_t<T>>);
45 
46 
47  namespace detail
48  {
49  template<typename T>
50  struct is_eigen_tensor_wrapper : std::false_type {};
51 
52  template<typename N, typename L>
53  struct is_eigen_tensor_wrapper<OpenKalman::internal::LibraryWrapper<N, L>> : std::bool_constant<eigen_tensor_general<L, true>> {};
54  } // namespace detail
55 
56 
61  template<typename T>
62 #ifdef __cpp_concepts
63  concept eigen_tensor_wrapper =
64 #else
65  constexpr bool eigen_tensor_wrapper =
66 #endif
68 
69 
70  namespace detail
71  {
72  template<typename>
73  struct eigen_sizes;
74 
75  template<typename...Ds>
76  struct eigen_sizes<std::tuple<Ds...>> { using type = Eigen::Sizes<static_cast<std::ptrdiff_t>(coordinates::dimension_of_v<Ds>)...>; };
77 
78  } // namespace detail
79 
80 
87 #ifdef __cpp_concepts
88  template<indexible NestedObject>
89 #else
90  template<typename NestedObject>
91 #endif
92  using EigenTensorWrapper = OpenKalman::internal::LibraryWrapper<NestedObject, std::conditional_t<
93  has_dynamic_dimensions<NestedObject>,
94  Eigen::Tensor<
96  static_cast<int>(index_count_v<NestedObject>),
97  layout_of_v<NestedObject> == Layout::right ? Eigen::RowMajor : Eigen::ColMajor,
98  Eigen::DenseIndex>,
99  Eigen::TensorFixedSize<
100  scalar_type_of_t<NestedObject>,
101  typename detail::eigen_sizes<std::decay_t<decltype(all_vector_space_descriptors(std::declval<NestedObject>()))>>::type,
102  layout_of_v<NestedObject> == Layout::right ? Eigen::RowMajor : Eigen::ColMajor,
103  Eigen::DenseIndex>>>;
104 
105 
109 #ifdef __cpp_concepts
110  template<typename T>
112 #else
113  template<typename T, typename = void>
115 #endif
116 
117 
118 } // namespace OpenKalman::Eigen3
119 
120 
121 #endif //OPENKALMAN_EIGEN_TENSOR_FORWARD_DECLARATIONS_HPP
constexpr bool eigen_tensor_general
Specifies any descendant of Eigen::TensorBase.
Definition: eigen-tensor-forward-declarations.hpp:41
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: tuple_reverse.hpp:103
Trait object providing get and set routines for Eigen tensors.
Definition: eigen-tensor-forward-declarations.hpp:114
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
decltype(auto) constexpr all_vector_space_descriptors(const T &t)
Return a collection of coordinates::pattern objects associated with T.
Definition: all_vector_space_descriptors.hpp:52
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: eigen-tensor-forward-declarations.hpp:30
Definition: eigen-forward-declarations.hpp:22
Definition: eigen-tensor-forward-declarations.hpp:73
Definition: eigen-forward-declarations.hpp:79
Definition: forward-class-declarations.hpp:580
Definition: eigen-tensor-forward-declarations.hpp:50