OpenKalman
make_zero.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_ZERO_HPP
17 #define OPENKALMAN_MAKE_ZERO_HPP
18 
19 namespace OpenKalman
20 {
28 #ifdef __cpp_concepts
29  template<indexible T, values::number Scalar = scalar_type_of_t<T>, pattern_collection Descriptors>
30  constexpr zero auto
31 #else
32  template<typename T, typename Scalar = scalar_type_of_t<T>, typename...Ds, std::enable_if_t<indexible<T> and
33  values::number<Scalar> and pattern_collection<Descriptors>, int> = 0>
34  constexpr auto
35 #endif
36  make_zero(Descriptors&& descriptors)
37  {
38  return make_constant<T, Scalar, 0>(std::forward<Descriptors>(descriptors));
39  }
40 
41 
46 #ifdef __cpp_concepts
47  template<indexible T, values::number Scalar = scalar_type_of_t<T>, coordinates::pattern...Ds>
48  constexpr zero auto
49 #else
50  template<typename T, typename Scalar = scalar_type_of_t<T>, typename...Ds, std::enable_if_t<indexible<T> and
51  values::number<Scalar> and (... and coordinates::pattern<Ds>), int> = 0>
52  constexpr auto
53 #endif
54  make_zero(Ds&&...ds)
55  {
56  return make_zero<T, Scalar>(std::tuple {std::forward<Ds>(ds)...});
57  }
58 
59 
66 #ifdef __cpp_concepts
67  template<values::number Scalar, indexible T>
68  constexpr zero auto
69 #else
70  template<typename Scalar, typename T, std::enable_if_t<values::number<Scalar> and indexible<T>, int> = 0>
71  constexpr auto
72 #endif
73  make_zero(const T& t)
74  {
75  return make_constant<Scalar, 0>(t);
76  }
77 
78 
84 #ifdef __cpp_concepts
85  template<indexible T>
86  constexpr zero auto
87 #else
88  template<typename T, std::enable_if_t<indexible<T>, int> = 0>
89  constexpr auto
90 #endif
91  make_zero(const T& t)
92  {
93  return make_constant<scalar_type_of_t<T>, 0>(t);
94  }
95 
96 
97 } // namespace OpenKalman
98 
99 #endif //OPENKALMAN_MAKE_ZERO_HPP
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool zero
Specifies that a type is known at compile time to be a constant matrix of value zero.
Definition: zero.hpp:43
constexpr auto make_zero(Descriptors &&descriptors)
Make a zero associated with a particular library.
Definition: make_zero.hpp:36