OpenKalman
make_identity_matrix.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) 2026 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_IDENTITY_MATRIX_HPP
17 #define OPENKALMAN_MAKE_IDENTITY_MATRIX_HPP
18 
19 #include "patterns/patterns.hpp"
22 
23 namespace OpenKalman
24 {
30 #ifdef __cpp_concepts
31  template<values::value C, patterns::pattern_collection P>
32  constexpr identity_matrix auto
33 #else
34  template<typename C, typename P, std::enable_if_t<values::value<C> and patterns::pattern_collection<P>, int> = 0>
35  constexpr auto
36 #endif
38  {
40  return make_constant_diagonal(std::move(c), std::forward<P>(p));
41  }
42 
43 
48 #ifdef __cpp_concepts
49  template<values::value C, patterns::pattern...Ps>
50  constexpr identity_matrix auto
51 #else
52  template<typename C, typename...Ps, std::enable_if_t<values::value<C> and (... and patterns::pattern<Ps>), int> = 0>
53  constexpr auto
54 #endif
56  {
57  return make_identity_matrix<C>(std::tuple{std::forward<Ps>(ps)...});
58  }
59 
60 
65 #ifdef __cpp_concepts
66  template<values::value C, patterns::pattern_collection P> requires
67  std::default_initializable<P> and
68  values::fixed<collections::size_of<P>>
69  constexpr identity_matrix auto
70 #else
71  template<typename C, typename P, std::enable_if_t<
72  values::value<C> and
73  patterns::pattern_collection<P> and
74  values::fixed<collections::size_of<P>>, int> = 0>
75  constexpr auto
76 #endif
78  {
79  return make_identity_matrix<C>(P{});
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
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
constexpr auto make_identity_matrix(P &&p)
Make an identity_matrix with a given shape pattern.
Definition: make_identity_matrix.hpp:37
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool identity_matrix
Specifies that a type is known at compile time to be a rank-2 or lower identity matrix.
Definition: identity_matrix.hpp:50
Definitions for make_constant_diagonal.
Definition for identity_matrix.