OpenKalman
fill_components.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) 2022-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_FILL_COMPONENTS_HPP
17 #define OPENKALMAN_FILL_COMPONENTS_HPP
18 
19 
20 namespace OpenKalman
21 {
32 #ifdef __cpp_concepts
33  template<Layout layout = Layout::right, indexible Arg, values::number ... S> requires
34  (layout == Layout::right or layout == Layout::left) and internal::may_hold_components<Arg, S...> and
35  (sizeof...(S) == 0 or interface::fill_components_defined_for<Arg, layout, std::add_lvalue_reference_t<Arg>, S...>)
36  inline Arg&&
37 #else
38  template<Layout layout = Layout::right, typename Arg, typename...S, std::enable_if_t<
39  indexible<Arg> and (values::number<S> and ...) and (layout == Layout::right or layout == Layout::left) and
40  internal::may_hold_components<Arg, S...> and
41  (sizeof...(S) == 0 or interface::fill_components_defined_for<Arg, layout, std::add_lvalue_reference_t<Arg>, S...>), int> = 0>
42  inline Arg&&
43 #endif
44  fill_components(Arg&& arg, S...s)
45  {
46  if constexpr (sizeof...(S) == 0)
47  {
48  return std::forward<Arg>(arg);
49  }
50  else
51  {
52  using Scalar = scalar_type_of_t<Arg>;
54  Trait::template fill_components<layout>(arg, static_cast<const Scalar>(s)...);
55  return std::forward<Arg>(arg);
56  }
57  }
58 
59 
60 } // namespace OpenKalman
61 
62 #endif //OPENKALMAN_FILL_COMPONENTS_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
constexpr bool indexible
T is a generalized tensor type.
Definition: indexible.hpp:32
constexpr bool number
T is a numerical type.
Definition: number.hpp:33
The root namespace for OpenKalman.
Definition: basics.hpp:34
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:37
Column-major storage (Fortran, Matlab, or Eigen style): contiguous storage in which the left-most ext...
Arg && fill_components(Arg &&arg, S...s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: fill_components.hpp:44
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47