17 #ifndef OPENKALMAN_SET_TRIANGLE_HPP 18 #define OPENKALMAN_SET_TRIANGLE_HPP 34 template<triangle_type t, indexible A, indexible B> requires
35 (t !=
triangle_type::any) and (index_count_v<A> == stdex::dynamic_extent or index_count_v<A> <= 2) and
40 template<triangle_type t,
typename A,
typename B, std::enable_if_t<indexible<A> and indexible<B> and
41 (t != triangle_type::any) and (index_count<A>::value == stdex::dynamic_extent or index_count<A>::value <= 2) and
42 (t != triangle_type::lower or dimension_size_of_index_is<A, 0, index_dimension_of<B, 0>::value, applicability::permitted>) and
43 (t != triangle_type::upper or dimension_size_of_index_is<A, 1, index_dimension_of<B, 1>::value, applicability::permitted>) and
44 (not (diagonal_matrix<A> or (triangular_matrix<A> and not triangular_matrix<A, t>)) or t == triangle_type::diagonal or diagonal_matrix<B>),
int> = 0>
47 set_triangle(A&& a, B&& b)
49 if constexpr (
interface::set_triangle_defined_for<A, t, A&&, B&&>)
51 interface::library_
interface<stdex::remove_cvref_t<A>>::
template set_triangle<t>(std::forward<A>(a), std::forward<B>(b));
53 else if constexpr (interface::set_triangle_defined_for<A, t, A&&, decltype(to_native_matrix<A>(std::declval<B&&>()))>)
55 interface::library_interface<stdex::remove_cvref_t<A>>::template set_triangle<t>(std::forward<A>(a), to_native_matrix<A>(std::forward<B>(b)));
57 else if constexpr (triangular_adapter<A>)
61 else if constexpr (hermitian_adapter<A>)
63 if constexpr ((t ==
triangle_type::lower and hermitian_adapter<A, HermitianAdapterType::upper>) or
69 else if constexpr (diagonal_matrix<A> and internal::has_nested_vector<A, 0>)
73 else if constexpr (diagonal_matrix<A> and internal::has_nested_vector<A, 1>)
79 for (
int i = 0; i < get_index_dimension_of<0>(a); i++)
80 for (
int j = i; j < get_index_dimension_of<1>(a); j++)
81 set_component(a, get_component(b, i, i), i, i);
85 for (
int i = 0; i < get_index_dimension_of<0>(a); i++)
86 for (
int j = 0; j < i; j++)
87 set_component(a, get_component(b, i, i), i, i);
91 for (
int i = 0; i < get_index_dimension_of<0>(a); i++) set_component(a, get_component(b, i, i), i, i);
93 return std::forward<A>(a);
102 #ifdef __cpp_concepts 103 template<indexible A, vector_space_descriptors_may_match_with<A> B> requires (triangular_matrix<A> or triangular_matrix<B>) and
105 constexpr vector_space_descriptors_may_match_with<A> decltype(
auto)
107 template<
typename A,
typename B, std::enable_if_t<indexible<A> and vector_space_descriptors_may_match_with<B, A> and
108 (triangular_matrix<A> or triangular_matrix<B>) and
109 (triangle_type_of<A, B>::value != triangle_type::any or triangle_type_of<A>::value == triangle_type::any or
110 triangle_type_of<B>::value == triangle_type::any),
int> = 0>
111 constexpr decltype(
auto)
113 set_triangle(A&& a, B&& b)
118 triangle_type_of_v<A> ==
triangle_type::any ? triangle_type_of_v<B> : triangle_type_of_v<A>;
119 return set_triangle<t>(std::forward<A>(a), std::forward<B>(b));
triangle_type
The type of a triangular matrix.
Definition: enumerations.hpp:26
constexpr bool diagonal_matrix
Specifies that a type is a diagonal matrix or tensor.
Definition: diagonal_matrix.hpp:32
A lower-left triangular matrix.
applicability
The applicability of a concept, trait, or restraint.
Definition: constants.hpp:35
The concept, trait, or restraint is permitted, but whether it applies is not necessarily known at com...
A diagonal matrix (both a lower-left and an upper-right triangular matrix).
constexpr bool triangular_matrix
Specifies that an argument is an indexible object having a given triangle_type (e.g., upper, lower, or diagonal).
Definition: triangular_matrix.hpp:36
Lower, upper, or diagonal matrix.
constexpr bool dimension_size_of_index_is
Specifies that a given index of T has a specified size.
Definition: dimension_size_of_index_is.hpp:35
decltype(auto) constexpr transpose(Arg &&arg)
Swap any two indices of an indexible_object.
Definition: transpose.hpp:163
decltype(auto) constexpr diagonal_of(Arg &&arg)
Extract a column vector (or column slice for rank>2 tensors) comprising the diagonal elements...
Definition: diagonal_of.hpp:36
An upper-right triangular matrix.
decltype(auto) constexpr adjoint(Arg &&arg)
Take the conjugate-transpose of an indexible_object.
Definition: adjoint.hpp:35
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:35
Definition: basics.hpp:48