OpenKalman
VectorWiseOp.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_VECTORWISEOP_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_VECTORWISEOP_HPP
18 
19 #include <type_traits>
20 
21 
22 namespace OpenKalman::interface
23 {
24  template<typename ExpressionType, int Direction>
25  struct object_traits<Eigen::VectorwiseOp<ExpressionType, Direction>>
26  {
27  using scalar_type = scalar_type_of_t<ExpressionType>;
28 
29  template<typename Arg>
30  static constexpr auto count_indices(const Arg& arg) { return std::integral_constant<std::size_t, 2>{}; }
31 
32  template<typename Arg, typename N>
33  static constexpr auto get_pattern_collection(const Arg& arg, N n)
34  {
35  return OpenKalman::get_pattern_collection(arg._expression(), n);
36  }
37 
38  template<typename Arg>
39  static decltype(auto) nested_object(Arg&& arg)
40  {
41  return std::forward<Arg>(arg)._expression();
42  }
43 
44  template<typename Arg>
45  static constexpr auto get_constant(const Arg& arg)
46  {
47  return constant_value {arg._expression()};
48  }
49 
50  template<applicability b>
51  static constexpr bool one_dimensional = OpenKalman::one_dimensional<ExpressionType, b>;
52 
53  template<applicability b>
54  static constexpr bool is_square = square_shaped<ExpressionType, b>;
55 
56  // No get or set defined.
57  };
58 
59 }
60 
61 #endif
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:56
Definition: basics.hpp:41
constexpr auto count_indices(const T &)
Get the number of indices necessary to address all the components of an indexible object...
Definition: count_indices.hpp:51
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
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