16 #ifndef OPENKALMAN_LQ_DECOMPOSITION_HPP 17 #define OPENKALMAN_LQ_DECOMPOSITION_HPP 27 template<indexible A> requires (not euclidean_transformed<A>)
28 constexpr triangular_matrix<triangle_type::lower> decltype(
auto)
30 template<
typename A, std::enable_if_t<indexible<A> and (not eucl
idean_transformed<A>),
int> = 0>
31 constexpr decltype(
auto)
35 if constexpr (triangular_matrix<A, triangle_type::lower>)
37 return internal::clip_square_shaped(std::forward<A>(a));
39 else if constexpr (constant_matrix<A>)
41 using Scalar = scalar_type_of_t<A>;
45 if constexpr (dynamic_dimension<A, 0>)
50 auto m {make_dense_object<A>(dim, dim)};
53 else m = concatenate<1>(std::move(col1), make_zero<A>(dim, dim -
coordinates::Axis{}));
55 auto ret {make_triangular_matrix<triangle_type::lower>(std::move(m))};
58 if constexpr (has_untyped_index<A, 0>)
return ret;
63 auto ret = make_triangular_matrix<triangle_type::lower>([](Scalar elem){
64 constexpr
auto dim = index_dimension_of_v<A, 0>;
66 if constexpr (dim == 1)
return col1;
71 using C = vector_space_descriptor_of_t<A, 0>;
72 if constexpr (coordinates::euclidean_pattern<C>)
return ret;
78 decltype(
auto) ret = [](A&& a) -> decltype(
auto) {
79 if constexpr (interface::LQ_decomposition_defined_for<A, A&&>)
85 static_assert(interface::QR_decomposition_defined_for<A, A&&>,
86 "LQ_decomposition requires definition of at least one of interface::LQ_decomposition or interface::QR_decomposition");
89 }(std::forward<A>(a));
90 using Ret = decltype(ret);
92 static_assert(triangular_matrix<Ret, triangle_type::lower>,
93 "Interface implementation error: interface::library_interface<T>::LQ_decomposition must return a lower triangular_matrix.");
96 if constexpr (has_untyped_index<A, 0>)
return ret;
decltype(auto) constexpr QR_decomposition(A &&a)
Perform a QR decomposition of matrix A=Q[U,0], U is a upper-triangular matrix, and Q is orthogonal...
Definition: QR_decomposition.hpp:33
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
The upper or lower triangle Cholesky factor (square root) of a covariance matrix. ...
Definition: forward-class-declarations.hpp:403
The root namespace for OpenKalman.
Definition: basics.hpp:34
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:42
decltype(auto) constexpr transpose(Arg &&arg)
Swap any two indices of an indexible_object.
Definition: transpose.hpp:163
constexpr auto sqrt(const Arg &arg)
A constexpr alternative to std::sqrt.
Definition: sqrt.hpp:46
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
decltype(auto) constexpr LQ_decomposition(A &&a)
Perform an LQ decomposition of matrix A=[L,0]Q, L is a lower-triangular matrix, and Q is orthogonal...
Definition: LQ_decomposition.hpp:33
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42