OpenKalman
make_dense_object.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-2024 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_MAKE_DENSE_OBJECT_HPP
17 #define OPENKALMAN_MAKE_DENSE_OBJECT_HPP
18 
19 namespace OpenKalman
20 {
30 #ifdef __cpp_concepts
31  template<indexible T, Layout layout = Layout::none, values::number Scalar = scalar_type_of_t<T>, pattern_collection Descriptors>
32  requires (layout != Layout::stride) and
33  interface::make_default_defined_for<T, layout, Scalar, decltype(internal::to_euclidean_vector_space_descriptor_collection(std::declval<Descriptors&&>()))>
34  constexpr writable auto
35 #else
36  template<typename T, Layout layout = Layout::none, typename Scalar = scalar_type_of_t<T>, typename Descriptors, std::enable_if_t<
37  indexible<T> and values::number<Scalar> and pattern_collection<D> and (layout != Layout::stride) and
38  interface::make_default_defined_for<T, layout, Scalar, decltype(internal::to_euclidean_vector_space_descriptor_collection(std::declval<Descriptors&&>()))>, int> = 0>
39  constexpr auto
40 #endif
41  make_dense_object(Descriptors&& descriptors)
42  {
43  decltype(auto) d = internal::remove_trailing_1D_descriptors(std::forward<Descriptors>(descriptors));
44  using D = decltype(d);
46  if constexpr (coordinates::euclidean_pattern_collection<D>)
47  {
48  return Traits::template make_default<layout, Scalar>(std::forward<D>(d));
49  }
50  else
51  {
52  auto ed = internal::to_euclidean_vector_space_descriptor_collection(d);
53  return make_vector_space_adapter(Traits::template make_default<layout, Scalar>(ed), std::forward<D>(d));
54  }
55  }
56 
57 
62 #ifdef __cpp_concepts
63  template<indexible T, Layout layout = Layout::none, values::number Scalar = scalar_type_of_t<T>, coordinates::pattern...Ds>
64  requires (layout != Layout::stride) and
65  interface::make_default_defined_for<T, layout, Scalar, decltype(std::tuple {get_dimension(std::declval<Ds&&>())...})>
66  constexpr writable auto
67 #else
68  template<typename T, Layout layout = Layout::none, typename Scalar = scalar_type_of_t<T>, typename...Ds, std::enable_if_t<
69  indexible<T> and values::number<Scalar> and (... and coordinates::pattern<Ds>) and (layout != Layout::stride) and
70  interface::make_default_defined_for<T, layout, Scalar, std::tuple<Ds&&...>>, int> = 0>
71  constexpr auto
72 #endif
73  make_dense_object(Ds&&...ds)
74  {
75  return make_dense_object<T, layout, Scalar>(std::tuple {std::forward<Ds>(ds)...});
76  }
77 
78 
79 } // namespace OpenKalman
80 
81 #endif //OPENKALMAN_MAKE_DENSE_OBJECT_HPP
No storage layout (e.g., if the elements are calculated rather than stored).
auto make_vector_space_adapter(Arg &&arg, Descriptors &&descriptors)
If necessary, wrap an object in a wrapper that adds vector space descriptors for each index...
Definition: make_vector_space_adapter.hpp:37
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
constexpr auto make_dense_object(Descriptors &&descriptors)
Make a default, dense, writable matrix with a set of coordinates::pattern objects defining the dimens...
Definition: make_dense_object.hpp:41
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
A generalization of the above: a custom stride is specified for each index.
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47