OpenKalman
make_constant_diagonal.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) 2025 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_CONSTANT_DIAGONAL_HPP
17 #define OPENKALMAN_MAKE_CONSTANT_DIAGONAL_HPP
18 
20 #include "to_diagonal.hpp"
21 #include "make_constant.hpp"
22 
23 namespace OpenKalman
24 {
31 #ifdef __cpp_concepts
32  template<values::value C, typename IndexType, std::size_t...Extents>
33  constexpr constant_diagonal_object auto
34 #else
35  template<typename C, typename IndexType, std::size_t...Extents, std::enable_if_t<values::value<C>, int> = 0>
36  constexpr auto
37 #endif
39  {
40  return to_diagonal(make_constant(std::move(c), std::move(extents)));
41  }
42 
43 
44 
49 #ifdef __cpp_concepts
50  template<values::value C, coordinates::pattern_collection P> requires values::fixed<collections::size_of<P>>
51  constexpr constant_diagonal_object auto
52 #else
53  template<typename C, typename P, std::enable_if_t<
54  values::value<C> and
55  coordinates::pattern_collection<P> and
56  values::fixed<collections::size_of<P>>, int> = 0>
57  constexpr auto
58 #endif
60  {
61  return to_diagonal(make_constant(std::move(c), std::forward<P>(p)));
62  }
63 
64 
69 #ifdef __cpp_concepts
70  template<values::value C, coordinates::pattern...Ps>
71  constexpr constant_diagonal_object auto
72 #else
73  template<typename C, typename...Ps, std::enable_if_t<values::value<C> and (... and coordinates::pattern<Ps>), int> = 0>
74  constexpr auto
75 #endif
76  make_constant_diagonal(C c, Ps&&...ps)
77  {
78  return make_constant_diagonal(std::move(c), std::tuple{std::forward<Ps>(ps)...});
79  }
80 
81 
86 #ifdef __cpp_concepts
87  template<coordinates::pattern_collection P, values::value C> requires
88  std::default_initializable<P> and
89  values::fixed<collections::size_of<P>>
90  constexpr constant_diagonal_object auto
91 #else
92  template<typename C, typename P, std::enable_if_t<
93  coordinates::pattern_collection<P> and
94  values::value<C> and
95  values::fixed<collections::size_of<P>>, int> = 0>
96  constexpr auto
97 #endif
99  {
100  return make_constant_diagonal(std::move(c), P{});
101  }
102 
103 
104 }
105 
106 #endif
Definition for constant_diagonal_object.
constexpr bool pattern
An object describing the set of coordinates associated with a tensor 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
decltype(auto) constexpr to_diagonal(Arg &&arg)
Convert an indexible object into a diagonal matrix.
Definition: to_diagonal.hpp:33
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool constant_diagonal_object
Specifies that all diagonal elements of a diagonal object are known at compile time to be the same co...
Definition: constant_diagonal_object.hpp:38
constexpr auto make_constant_diagonal(C c, stdex::extents< IndexType, Extents... > extents)
Make an indexible object in which every diagonal element is a constant value.
Definition: make_constant_diagonal.hpp:38
constexpr auto make_constant(C c, stdex::extents< IndexType, Extents... > extents)
Make an indexible object in which every element is a constant value.
Definition: make_constant.hpp:39
Definition for to_diagonal function.
Definitions for make_constant.
Definition: extents.hpp:372