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 
19 #include "patterns/patterns.hpp"
21 #include "make_constant.hpp"
22 #include "to_diagonal.hpp"
23 
24 namespace OpenKalman
25 {
32 #ifdef __cpp_concepts
33  template<values::value C, patterns::pattern_collection P>
34  constexpr constant_diagonal_object auto
35 #else
36  template<typename C, typename P, std::enable_if_t<
37  values::value<C> and patterns::pattern_collection<P>, int> = 0>
38  constexpr auto
39 #endif
41  {
43  return to_diagonal(make_constant(std::move(c), std::move(nested_p)), std::forward<P>(p));
44  }
45 
46 
51 #ifdef __cpp_concepts
52  template<values::value C, patterns::pattern...Ps>
53  constexpr constant_diagonal_object auto
54 #else
55  template<typename C, typename...Ps, std::enable_if_t<values::value<C> and (... and patterns::pattern<Ps>), int> = 0>
56  constexpr auto
57 #endif
58  make_constant_diagonal(C c, Ps&&...ps)
59  {
60  return make_constant_diagonal(std::move(c), std::tuple{std::forward<Ps>(ps)...});
61  }
62 
63 
68 #ifdef __cpp_concepts
69  template<patterns::pattern_collection P, values::value C> requires
70  std::default_initializable<P> and
71  values::fixed<collections::size_of<P>>
72  constexpr constant_diagonal_object auto
73 #else
74  template<typename C, typename P, std::enable_if_t<
75  patterns::pattern_collection<P> and
76  values::value<C> and
77  values::fixed<collections::size_of<P>>, int> = 0>
78  constexpr auto
79 #endif
81  {
82  return make_constant_diagonal(std::move(c), P{});
83  }
84 
85 
86 }
87 
88 #endif
Definition for constant_diagonal_object.
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
constexpr auto make_constant_diagonal(C c, P &&p)
Make an indexible object in which every diagonal element is a constant value.
Definition: make_constant_diagonal.hpp:40
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(C c, P &&p)
Make an indexible object in which every element is a constant value.
Definition: make_constant.hpp:41
constexpr detail::diagonal_of_adapter diagonal_of
A RangeAdapterObject that converts one pattern_collection to another corresponding to the diagonal_ma...
Definition: diagonal_of.hpp:153
decltype(auto) constexpr to_diagonal(Arg &&arg, P &&p)
Convert a column vector (or any other array with a 1D second index) into a diagonal_matrix.
Definition: to_diagonal.hpp:46
Definitions for make_constant.
Definition for to_diagonal function.
constexpr auto to_extents(P &&p)
Convert a pattern_collection to std::extents.
Definition: to_extents.hpp:78