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 #include "make_constant.hpp"
20 
21 namespace OpenKalman
22 {
29 #ifdef __cpp_concepts
30  template<values::value C, patterns::pattern_collection P> requires values::fixed<collections::size_of<P>>
31  constexpr zero auto
32 #else
33  template<typename C, typename P, std::enable_if_t<values::value<C> and
34  patterns::pattern_collection<P> and values::fixed<collections::size_of<P>>, int> = 0>
35  constexpr auto
36 #endif
37  make_zero(P&& p)
38  {
39  return make_constant(values::fixed_value<C, 0>{}, std::forward<P>(p));
40  }
41 
42 
47 #ifdef __cpp_concepts
48  template<values::value C, patterns::pattern...Ps>
49  constexpr constant_object auto
50 #else
51  template<typename C, typename...Ps, std::enable_if_t<values::value<C> and (... and patterns::pattern<Ps>), int> = 0>
52  constexpr auto
53 #endif
54  make_zero(Ps&&...ps)
55  {
56  return make_zero<C>(std::tuple{std::forward<Ps>(ps)...});
57  }
58 
59 
64 #ifdef __cpp_concepts
65  template<values::value C, patterns::pattern_collection P> requires
66  std::default_initializable<P> and
67  values::fixed<collections::size_of<P>>
68  constexpr constant_object auto
69 #else
70  template<typename C, typename P, std::enable_if_t<
71  patterns::pattern_collection<P> and
72  values::value<C> and
73  values::fixed<collections::size_of<P>>, int> = 0>
74  constexpr auto
75 #endif
77  {
78  return make_zero<C>(P{});
79  }
80 
81 
82 
83 }
84 
85 #endif
Definition: fixed_value.hpp:41
constexpr bool pattern
An object describing the characteristics (e.g., dimensions, wrapping structure) of an index...
Definition: pattern.hpp:31
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
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:63
constexpr auto make_constant(C c, P &&p)
Make an indexible object in which every element is a constant value.
Definition: make_constant.hpp:41
constexpr bool constant_object
Specifies that all elements of an object are known at compile time to be the same constant value...
Definition: constant_object.hpp:54
constexpr auto make_zero(P &&p)
Make an indexible object in which every element is 0.
Definition: make_zero.hpp:37
Definitions for make_constant.