OpenKalman
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) 2019-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_SQUARE_SHAPED_HPP
17 #define OPENKALMAN_SQUARE_SHAPED_HPP
18 
20 
21 namespace OpenKalman
22 {
23  namespace detail
24  {
25  template<typename T, std::size_t I, std::size_t...Is>
26  constexpr bool maybe_square_shaped(std::index_sequence<I, Is...>)
27  {
28  return (... and compares_with<vector_space_descriptor_of_t<T, I>, vector_space_descriptor_of_t<T, Is>, equal_to<>, Applicability::permitted>);
29  }
30 
31 
32 #ifndef __cpp_concepts
33  template<typename T, Applicability b, typename = void>
34  struct square_shaped_impl : std::false_type {};
35 
36  template<typename T, Applicability b>
37  struct square_shaped_impl<T, b, std::enable_if_t<indexible<T> and (index_count<T>::value != dynamic_size) and (index_count<T>::value > 1)>>
38  : std::bool_constant<(b != Applicability::guaranteed or not has_dynamic_dimensions<T>) and
39  (index_count_v<T> != 1 or dimension_size_of_index_is<T, 0, 1, Applicability::permitted>) and
40  (index_count_v<T> < 2 or maybe_square_shaped<T>(std::make_index_sequence<index_count_v<T>>{}))> {};
41 #endif
42 
43  } // namespace detail
44 
45 
46 #ifndef __cpp_concepts
47  namespace internal
48  {
49  template<typename T, Applicability b, typename = void>
50  struct is_explicitly_square : std::false_type {};
51 
52  template<typename T, Applicability b>
53  struct is_explicitly_square<T, b, std::enable_if_t<interface::indexible_object_traits<std::decay_t<T>>::template is_square<b>>>
54  : std::true_type {};
55 
56 
57  template<typename T, TriangleType t, typename = void>
58  struct is_explicitly_triangular : std::false_type {};
59 
60  template<typename T, TriangleType t>
61  struct is_explicitly_triangular<T, t, std::enable_if_t<interface::indexible_object_traits<std::decay_t<T>>::template is_triangular<t>>>
62  : std::true_type {};
63  }
64 #endif
65 
66 
75  template<typename T, Applicability b = Applicability::guaranteed>
76 #ifdef __cpp_concepts
77  concept square_shaped = one_dimensional<T, b> or (indexible<T> and
78  (not interface::is_square_defined_for<T, b> or interface::indexible_object_traits<std::decay_t<T>>::template is_square<b>) and
79  (interface::is_square_defined_for<T, b> or ((b != Applicability::guaranteed or not has_dynamic_dimensions<T>) and
80  (index_count_v<T> != 1 or dimension_size_of_index_is<T, 0, 1, Applicability::permitted>) and
81  (index_count_v<T> < 2 or detail::maybe_square_shaped<T>(std::make_index_sequence<index_count_v<T>>{}))) or
82  (b == Applicability::guaranteed and interface::indexible_object_traits<std::decay_t<T>>::template is_triangular<TriangleType::any, b>)));
83 #else
84  constexpr bool square_shaped = one_dimensional<T, b> or (indexible<T> and
85  (not interface::is_square_defined_for<T, b> or internal::is_explicitly_square<T, b>::value) and
86  (interface::is_square_defined_for<T, b> or detail::square_shaped_impl<T, b>::value or
87  (b == Applicability::guaranteed and internal::is_explicitly_triangular<T, TriangleType::any>::value)));
88 #endif
89 
90 
91 } // namespace OpenKalman
92 
93 #endif //OPENKALMAN_SQUARE_SHAPED_HPP
Definition: square_shaped.hpp:34
Definition for compares_with.
Definition: tuple_reverse.hpp:103
The root namespace for OpenKalman.
Definition: basics.hpp:34
The concept, trait, or restraint is permitted, but whether it applies is not necessarily known at com...