OpenKalman
is_square_shaped.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-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_IS_SQUARE_SHAPED_HPP
17 #define OPENKALMAN_IS_SQUARE_SHAPED_HPP
18 
19 #include "patterns/patterns.hpp"
21 
22 namespace OpenKalman
23 {
34 #ifdef __cpp_concepts
35  template<auto N = values::unbounded_size, indexible T> requires
36  (values::integral<decltype(N)> or stdex::same_as<std::decay_t<decltype(N)>, values::unbounded_size_t>) and
37  (not values::integral<decltype(N)> or N >= 2)
38 #else
39  template<std::size_t N = values::unbounded_size, typename T, std::enable_if_t<
40  (N == values::unbounded_size or N >= 2) and indexible<T>, int> = 0>
41 #endif
42  constexpr auto
43  is_square_shaped(const T& t)
44  {
45 #ifdef __cpp_concepts
46  if constexpr (std::same_as<std::decay_t<decltype(N)>, values::unbounded_size_t>)
47 #else
48  if constexpr (N == std::size_t(values::unbounded_size))
49 #endif
50  return patterns::get_common_pattern_collection_dimension<std::max(2_uz, index_count_v<T>)>(
52  else
53  return patterns::get_common_pattern_collection_dimension<N>(
55 
56 
57  }
58 
59 
60 }
61 
62 #endif
constexpr auto is_square_shaped(const T &t)
At least 2 and at most N indices have the same extent.
Definition: is_square_shaped.hpp:43
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the patterns::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:36
The root namespace for OpenKalman.
Definition: basics.hpp:34
A type reflecting an unbound size.
Definition: size.hpp:27
constexpr bool integral
T is an integral value.
Definition: integral.hpp:47
Definition of get_pattern_collection function.
constexpr unbounded_size_t unbounded_size
An instance of unbounded_size_t;.
Definition: size.hpp:60