OpenKalman
TensorReductionOp.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_TRAITS_TENSORREDUCTIONOP_HPP
17 #define OPENKALMAN_EIGEN_TRAITS_TENSORREDUCTIONOP_HPP
18 
19 
20 namespace OpenKalman::interface
21 {
22  template<typename Op, typename Dims, typename XprType, template<typename> typename MakePointer>
23  struct indexible_object_traits<Eigen::TensorReductionOp<Op, Dims, XprType, MakePointer>>
24  : Eigen3::indexible_object_traits_tensor_base<Eigen::TensorReductionOp<Op, Dims, XprType, MakePointer>>
25  {
26  template<typename Arg, typename N>
27  static constexpr auto get_index_descriptor(const Arg& arg, N n)
28  {
29  if constexpr (values::fixed<N>)
31  else
32  return static_cast<std::size_t>(arg.dimension[n]);
33  }
34 
35  template<std::size_t i, typename Arg>
36  static decltype(auto) get_nested_object(Arg&& arg)
37  {
38  if constexpr (i == 0)
39  return std::forward<Arg>(arg).expression();
40  else
41  return std::forward<Arg>(arg).reducer();
42  static_assert(i <= 1);
43  }
44 
45 
46  template<typename Arg>
47  static constexpr auto get_constant(const Arg& arg)
48  {
49  return constant_coefficient {arg};
50  }
51 
52  // get_constant_diagonal() not defined
53 
54  static constexpr bool is_writable = false;
55 
56  // data() not defined
57 
58  // layout not defined
59 
60  };
61 
62 } // namespace OpenKalman::interface
63 
64 #endif //OPENKALMAN_EIGEN_TRAITS_TENSORREDUCTIONOP_HPP
Definition: indexible_object_traits.hpp:36
Definition: basics.hpp:41
static constexpr auto get_constant(const Arg &arg)
Definition: TensorReductionOp.hpp:47
Definition: eigen-comma-initializers.hpp:20
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
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36