11 #ifndef OPENKALMAN_SQUAREROOTCOVARIANCE_HPP 12 #define OPENKALMAN_SQUAREROOTCOVARIANCE_HPP 25 template<fixed_pattern StaticDescriptor, covariance_nestable NestedMatrix> requires
26 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<NestedMatrix, 0>) and
27 (not std::is_rvalue_reference_v<NestedMatrix>) and values::number<scalar_type_of_t<NestedMatrix>>
29 template<
typename StaticDescriptor,
typename NestedMatrix>
34 #ifndef __cpp_concepts 35 static_assert(fixed_pattern<StaticDescriptor>);
36 static_assert(covariance_nestable<NestedMatrix>);
37 static_assert(coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<NestedMatrix, 0>);
38 static_assert(not std::is_rvalue_reference_v<NestedMatrix>);
43 using Scalar = scalar_type_of_t<NestedMatrix>;
48 using typename Base::CholeskyNestedMatrix;
50 using Base::cholesky_nested_matrix;
51 using Base::synchronization_direction;
52 using Base::synchronize_forward;
53 using Base::synchronize_reverse;
54 using Base::mark_nested_matrix_changed;
55 using Base::mark_cholesky_nested_matrix_changed;
56 using Base::mark_synchronized;
60 static constexpr
auto dim = index_dimension_of_v<NestedMatrix, 0>;
64 triangle_type_of_v<typename MatrixTraits<std::decay_t<NestedMatrix>>::template TriangularAdapterFrom<>>;
67 using NestedTriangular = std::conditional_t<triangular_matrix<NestedMatrix>, NestedMatrix,
68 typename MatrixTraits<std::decay_t<NestedMatrix>>::template TriangularAdapterFrom<tri>>;
72 template<
typename C = StaticDescriptor,
typename Arg>
73 static auto make(Arg&& arg)
83 template<self_adjo
int_covariance M> requires (not diagonal_matrix<M> or identity_matrix<M> or zero<M>) and
86 template<
typename M, std::enable_if_t<self_adjo
int_covariance<M> and
87 (not diagonal_matrix<M> or
identity_matrix<M> or zero<M>) and
88 (hermitian_matrix<nested_
object_of_t<M>> == hermitian_matrix<NestedMatrix>),
int> = 0>
102 template<
bool Enable = true, std::enable_if_t<Enable and stdex::default_initializable<Base>,
int> = 0>
111 #ifdef __cpp_concepts 112 template<triangular_covariance M> requires (not std::derived_from<std::decay_t<M>, SquareRootCovariance>) and
113 (triangle_type_of_v<M> == triangle_type_of_v<SquareRootCovariance>) and requires(M&& m) {
Base {std::forward<M>(m)}; }
115 template<
typename M, std::enable_if_t<
116 triangular_covariance<M> and (not std::is_base_of_v<SquareRootCovariance, std::decay_t<M>>) and
118 stdex::constructible_from<Base, M&&>,
int> = 0>
126 #ifdef __cpp_concepts 127 template<covariance_nestable M> requires requires(M&& m) {
Base {std::forward<M>(m)}; }
129 template<
typename M, std::enable_if_t<covariance_nestable<M> and
130 stdex::constructible_from<Base, M&&>,
int> = 0>
141 #ifdef __cpp_concepts 142 template<typed_matrix M> requires (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
143 compares_with<vector_space_descriptor_of_t<M, 0>, StaticDescriptor> and
144 requires(M&& m) {
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))}; }
146 template<
typename M, std::enable_if_t<typed_matrix<M> and
147 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
148 compares_with<vector_space_descriptor_of_t<M, 0>, StaticDescriptor> and
149 stdex::constructible_from<Base,
150 decltype(oin::to_covariance_nestable<NestedTriangular>(std::declval<M&&>()))>,
int> = 0>
153 :
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))} {}
162 #ifdef __cpp_concepts 163 template<typed_matrix_nestable M> requires (not covariance_nestable<M>) and
164 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
165 requires(M&& m) {
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))}; }
167 template<
typename M, std::enable_if_t<typed_matrix_nestable<M> and (not covariance_nestable<M>) and
168 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
169 stdex::constructible_from<Base,
170 decltype(oin::to_covariance_nestable<NestedTriangular>(std::declval<M&&>()))>,
int> = 0>
173 :
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))} {}
177 #ifdef __cpp_concepts 178 template<std::convertible_to<const Scalar> ... Args> requires (
sizeof...(Args) > 0) and
179 requires(Args ... args) {
Base {make_dense_object_from<NestedTriangular>(
static_cast<const Scalar>(args)...)};
182 template<
typename ... Args, std::enable_if_t<(stdex::convertible_to<Args, const Scalar> and ...) and
183 ((diagonal_matrix<NestedMatrix> and
sizeof...(Args) == dim) or
184 (
sizeof...(Args) == dim * dim)) and stdex::constructible_from<Base, NestedTriangular&&>,
int> = 0>
187 :
Base {make_dense_object_from<NestedTriangular>(
static_cast<const Scalar>(args)...)} {}
198 #ifdef __cpp_concepts 199 template<triangular_covariance Arg> requires (not std::derived_from<std::decay_t<Arg>, SquareRootCovariance>) and
200 (triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) and
201 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
204 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg> and
205 (not std::is_base_of_v<SquareRootCovariance, std::decay_t<Arg>>) and
206 (triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) and
207 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
208 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, nested_
object_of_t<Arg&&>>,
int> = 0>
212 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
214 Base::operator=(std::forward<Arg>(other));
223 #ifdef __cpp_concepts 224 template<typed_matrix Arg> requires square_shaped<Arg> and
225 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
226 std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>
228 template<
typename Arg, std::enable_if_t<typed_matrix<Arg> and square_shaped<Arg> and
229 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
230 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>,
int> = 0>
234 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
236 Base::operator=(oin::to_covariance_nestable<NestedTriangular>(std::forward<Arg>(other)));
245 #ifdef __cpp_concepts 246 template<covariance_nestable Arg> requires std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, Arg&&>
248 template<
typename Arg, std::enable_if_t<covariance_nestable<Arg> and
249 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>,
int> = 0>
251 auto& operator=(Arg&& other)
253 if constexpr (not zero<NestedMatrix> and not
identity_matrix<NestedMatrix>)
255 Base::operator=(std::forward<Arg>(other));
264 #ifdef __cpp_concepts
265 template<typed_matrix_nestable Arg> requires (not covariance_nestable<Arg>) and square_shaped<Arg> and
266 std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>
268 template<
typename Arg, std::enable_if_t<typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
269 square_shaped<Arg> and std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>,
int> = 0>
273 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
275 Base::operator=(oin::to_covariance_nestable<NestedTriangular>(std::forward<Arg>(other)));
286 #ifdef __cpp_concepts 287 template<
typename Arg> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
288 ((triangular_covariance<Arg> and triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) or
289 (typed_matrix<Arg> and square_shaped<Arg>)) and
290 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>
292 template<
typename Arg, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
293 ((triangular_covariance<Arg> and triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) or
294 (typed_matrix<Arg> and square_shaped<Arg>)) and
295 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>,
int> = 0>
297 auto& operator+=(
const Arg& arg)
299 if constexpr(triangular_matrix<NestedMatrix>)
301 nested_object() += oin::to_covariance_nestable<NestedMatrix>(arg);
302 mark_nested_matrix_changed();
306 if (synchronization_direction() > 0) synchronize_forward();
307 cholesky_nested_matrix() += oin::to_covariance_nestable<NestedTriangular>(arg);
308 if (synchronization_direction() > 0)
310 Base::synchronize_reverse();
314 mark_cholesky_nested_matrix_changed();
325 #ifdef __cpp_concepts 326 auto& operator+=(
const SquareRootCovariance& arg)
327 requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
329 template<
typename T = NestedMatrix, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<T>>),
int> = 0>
330 auto& operator+=(
const SquareRootCovariance& arg)
333 return operator+=<
const SquareRootCovariance&>(arg);
342 #ifdef __cpp_concepts 343 template<
typename Arg> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
344 ((triangular_covariance<Arg> and triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) or
345 (typed_matrix<Arg> and square_shaped<Arg>)) and
346 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>
348 template<
typename Arg, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
349 ((triangular_covariance<Arg> and triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) or
350 (typed_matrix<Arg> and square_shaped<Arg>)) and
351 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>,
int> = 0>
353 auto& operator-=(
const Arg& arg)
355 if constexpr(triangular_matrix<NestedMatrix>)
357 nested_object() -= oin::to_covariance_nestable<NestedMatrix>(arg);
358 mark_nested_matrix_changed();
362 if (synchronization_direction() > 0) synchronize_forward();
363 cholesky_nested_matrix() -= oin::to_covariance_nestable<NestedTriangular>(arg);
364 if (synchronization_direction() > 0)
366 synchronize_reverse();
370 mark_cholesky_nested_matrix_changed();
381 #ifdef __cpp_concepts 382 auto& operator-=(
const SquareRootCovariance& arg)
383 requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
385 template<
typename T = NestedMatrix, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<T>>),
int> = 0>
386 auto& operator-=(
const SquareRootCovariance& arg)
389 return operator-=<
const SquareRootCovariance&>(arg);
393 #ifdef __cpp_concepts 394 template<std::convertible_to<Scalar> S> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
396 template<
typename S, std::enable_if_t<stdex::convertible_to<S, Scalar> and
397 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
399 auto& operator*=(
const S s)
401 if constexpr(triangular_matrix<NestedMatrix>)
404 mark_nested_matrix_changed();
409 if (synchronization_direction() <= 0) cholesky_nested_matrix() *=
static_cast<const Scalar>(s);
415 #ifdef __cpp_concepts 416 template<std::convertible_to<Scalar> S> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
418 template<
typename S, std::enable_if_t<stdex::convertible_to<S, Scalar> and
419 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
421 auto& operator/=(
const S s)
423 if constexpr(triangular_matrix<NestedMatrix>)
426 mark_nested_matrix_changed();
431 if (synchronization_direction() <= 0) cholesky_nested_matrix() /=
static_cast<const Scalar>(s);
443 #ifdef __cpp_concepts 444 template<triangular_covariance Arg> requires (triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) and
445 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
447 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg> and
448 (triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) and
449 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
451 auto& operator*=(
const Arg& arg)
453 if constexpr(triangular_matrix<NestedMatrix>)
455 nested_object() *= oin::to_covariance_nestable<NestedMatrix>(arg);
456 mark_nested_matrix_changed();
460 if (synchronization_direction() > 0) synchronize_forward();
461 cholesky_nested_matrix() *= oin::to_covariance_nestable<NestedTriangular>(arg);
462 if (synchronization_direction() > 0)
464 synchronize_reverse();
468 mark_cholesky_nested_matrix_changed();
487 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
500 auto square()
const &
502 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
517 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
530 auto square()
const &&
532 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
547 #ifdef __cpp_concepts 548 template<typed_matrix U> requires compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor> and
549 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
551 template<
typename U, std::enable_if_t<typed_matrix<U> and
552 compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor> and
553 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
555 auto& rank_update(
const U& u,
const Scalar alpha = 1) &
557 if (synchronization_direction() < 0) synchronize_reverse();
559 mark_nested_matrix_changed();
567 #ifdef __cpp_concepts 568 template<typed_matrix U> requires compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor>
570 template<
typename U, std::enable_if_t<typed_matrix<U> and
571 compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor>,
int> = 0>
573 auto rank_update(
const U& u,
const Scalar alpha = 1) &&
575 if (synchronization_direction() < 0) synchronize_reverse();
581 #ifdef __cpp_concepts 582 template<
typename,
typename>
584 template<
typename,
typename,
typename>
589 template<
typename,
typename>
593 template<
typename,
typename>
597 #ifdef __cpp_concepts 598 template<fixed_pattern C, covariance_nestable N> requires
599 (coordinates::dimension_of_v<C> == index_dimension_of_v<N, 0>) and (not std::is_rvalue_reference_v<N>)
601 template<
typename,
typename>
603 friend struct SquareRootCovariance;
606 #ifdef __cpp_concepts 607 template<fixed_pattern C, covariance_nestable N> requires
608 (coordinates::dimension_of_v<C> == index_dimension_of_v<N, 0>) and (not std::is_rvalue_reference_v<N>)
610 template<
typename,
typename>
624 #ifdef __cpp_concepts 625 template<covariance_nestable M>
627 template<
typename M, std::enable_if_t<covariance_nestable<M>,
int> = 0>
635 #ifdef __cpp_concepts 636 template<typed_matrix M> requires square_shaped<M>
638 template<
typename M, std::enable_if_t<typed_matrix<M> and square_shaped<M>,
int> = 0>
641 typename MatrixTraits<std::decay_t<nested_object_of_t<M>>>::template TriangularAdapterFrom<>>;
647 #ifdef __cpp_concepts 648 template<typed_matrix_nestable M> requires (not covariance_nestable<M>) and square_shaped<M>
650 template<
typename M, std::enable_if_t<
651 typed_matrix_nestable<M> and (not covariance_nestable<M>) and square_shaped<M>,
int> = 0>
654 typename MatrixTraits<std::decay_t<M>>::template TriangularAdapterFrom<>>;
666 #ifdef __cpp_concepts 667 template<fixed_pattern StaticDescriptor, covariance_nestable Arg> requires
668 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 0>)
670 template<
typename StaticDescriptor,
typename Arg, std::enable_if_t<fixed_pattern<StaticDescriptor> and
671 covariance_nestable<Arg> and (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of<Arg, 0>::value),
int> = 0>
686 #ifdef __cpp_concepts 687 template<covariance_nestable Arg>
689 template<
typename Arg, std::enable_if_t<covariance_nestable<Arg>,
int> = 0>
694 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
695 return make_square_root_covariance<C>(std::forward<Arg>(arg));
706 #ifdef __cpp_concepts 707 template<fixed_pattern StaticDescriptor, triangle_type tri = triangle_type::lower, typed_matrix_nestable Arg>
708 requires (not covariance_nestable<Arg>) and
710 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 0>) and (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 1>)
713 fixed_pattern<StaticDescriptor> and typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
721 using T =
typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<tri>;
732 #ifdef __cpp_concepts 733 template<triangle_type tri = triangle_type::lower, typed_matrix_nestable Arg> requires
734 (not covariance_nestable<Arg>) and
738 typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
744 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
745 return make_square_root_covariance<C, tri>(std::forward<Arg>(arg));
753 #ifdef __cpp_concepts 754 template<fixed_pattern StaticDescriptor, triangle_type tri, typed_matrix_nestable Arg> requires square_shaped<Arg>
756 template<
typename StaticDescriptor,
triangle_type tri,
typename Arg,
757 std::enable_if_t<fixed_pattern<StaticDescriptor> and typed_matrix_nestable<Arg> and square_shaped<Arg>,
int> = 0>
763 typename MatrixTraits<std::decay_t<Arg>>::template DiagonalMatrixFrom<>,
764 typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<tri>>;
773 #ifdef __cpp_concepts 774 template<fixed_pattern StaticDescriptor,
typename Arg> requires
775 (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>
777 template<
typename StaticDescriptor,
typename Arg, std::enable_if_t<
778 (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>,
int> = 0>
783 constexpr
triangle_type template_type = triangle_type_of_v<typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<>>;
784 using B = std::conditional_t<diagonal_matrix<Arg>,
785 typename MatrixTraits<std::decay_t<Arg>>::template DiagonalMatrixFrom<>,
786 std::conditional_t<hermitian_matrix<Arg>,
787 typename MatrixTraits<std::decay_t<Arg>>::template SelfAdjointMatrixFrom<template_type>,
788 typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<template_type>>>;
798 #ifdef __cpp_concepts 799 template<
typename Arg> requires (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>
801 template<
typename Arg, std::enable_if_t<(covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and
802 square_shaped<Arg>,
int> = 0>
807 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
808 return make_square_root_covariance<C, Arg>();
816 #ifdef __cpp_concepts 817 template<triangle_type tri, typed_matrix_nestable Arg> requires square_shaped<Arg>
820 typed_matrix_nestable<Arg> and square_shaped<Arg>,
int> = 0>
825 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
826 return make_square_root_covariance<C, tri, Arg>();
834 #ifdef __cpp_concepts 835 template<triangular_covariance Arg>
837 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg>,
int> = 0>
842 using C = vector_space_descriptor_of_t<Arg, 0>;
851 #ifdef __cpp_concepts 852 template<triangular_covariance Arg>
854 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg>,
int> = 0>
859 using C = vector_space_descriptor_of_t<Arg, 0>;
861 return make_square_root_covariance<C, B>();
869 #ifdef __cpp_concepts 870 template<triangle_type tri = triangle_type::lower, typed_matrix Arg> requires
873 template<triangle_type tri = triangle_type::lower,
typename Arg, std::enable_if_t<typed_matrix<Arg> and
874 (tri == triangle_type::lower or tri == triangle_type::upper) and square_shaped<Arg>,
int> = 0>
879 using C = vector_space_descriptor_of_t<Arg, 0>;
880 return make_square_root_covariance<C, tri>(
nested_object(std::forward<Arg>(arg)));
888 #ifdef __cpp_concepts 889 template<triangle_type tri, typed_matrix Arg> requires square_shaped<Arg>
892 typed_matrix<Arg> and square_shaped<Arg>,
int> = 0>
897 using C = vector_space_descriptor_of_t<Arg, 0>;
899 return make_square_root_covariance<C, tri, B>();
907 #ifdef __cpp_concepts 908 template<typed_matrix Arg> requires square_shaped<Arg>
910 template<
typename Arg, std::enable_if_t<typed_matrix<Arg> and square_shaped<Arg>,
int> = 0>
915 using C = vector_space_descriptor_of_t<Arg, 0>;
917 return make_square_root_covariance<C, B>();
927 template<
typename Coeffs,
typename NestedMatrix>
930 using scalar_type = scalar_type_of_t<NestedMatrix>;
932 template<
typename Arg>
933 static constexpr
auto count_indices(
const Arg& arg) {
return std::integral_constant<std::size_t, 2>{}; }
935 template<
typename Arg,
typename N>
938 return std::forward<Arg>(arg).my_dimension;
942 template<
typename Arg>
945 if constexpr (hermitian_matrix<NestedMatrix>)
952 template<
typename Arg>
953 static constexpr
auto get_constant(
const Arg& arg)
955 if constexpr (zero<NestedMatrix>)
958 return std::monostate {};
962 template<
typename Arg>
963 static constexpr
auto get_constant_diagonal(
const Arg& arg)
965 return constant_diagonal_value {arg.nestedExpression()};
969 template<applicability b>
970 static constexpr
bool one_dimensional = OpenKalman::one_dimensional<NestedMatrix, b>;
973 template<applicability b>
974 static constexpr
bool is_square =
true;
977 template<triangle_type t>
978 static constexpr
bool triangle_type_value = triangular_matrix<NestedMatrix, t> or
979 hermitian_adapter<NestedMatrix, t == triangle_type::upper ? HermitianAdapterType::upper : HermitianAdapterType::lower>;
982 static constexpr
bool is_triangular_adapter =
false;
985 static constexpr
bool is_hermitian =
false;
988 #ifdef __cpp_lib_concepts 989 template<
typename Arg,
typename...I> requires
992 template<
typename Arg,
typename...I, std::enable_if_t<
995 static constexpr
auto get(Arg&& arg, I...i)
997 return std::forward<Arg>(arg)(i...);
1001 #ifdef __cpp_lib_concepts 1002 template<
typename Arg,
typename...I> requires
1005 template<
typename Arg,
typename...I, std::enable_if_t<
1008 static constexpr
void set(Arg& arg,
const scalar_type_of_t<Arg>& s, I...i)
1010 arg.set_component(s, i...);
1016 #ifdef __cpp_lib_concepts 1017 template<
typename Arg> requires one_dimensional<NestedMatrix> and raw_data_defined_for<NestedMatrix>
1019 template<
typename Arg, std::enable_if_t<one_dimensional<NestedMatrix> and raw_data_defined_for<NestedMatrix>,
int> = 0>
1021 static constexpr
auto *
const 1022 raw_data(Arg& arg) {
return internal::raw_data(arg.nested_object()); }
1025 static constexpr data_layout layout = one_dimensional<NestedMatrix> ? layout_of_v<NestedMatrix> :
data_layout::none;
typename nested_object_of< T >::type nested_object_of_t
Helper type for nested_object_of.
Definition: nested_object_of.hpp:58
auto make_square_root_covariance(Arg &&arg)
Make a SquareRootCovariance from a covariance_nestable, specifying the coefficients.
Definition: SquareRootCovariance.hpp:674
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:56
triangle_type
The type of a triangular matrix.
Definition: enumerations.hpp:26
auto & operator=(Arg &&other)
Assign from a compatible triangular_covariance.
Definition: SquareRootCovariance.hpp:210
auto & operator=(Arg &&other)
Assign from a compatible typed_matrix (assumed, without checking, to be triangular).
Definition: SquareRootCovariance.hpp:232
Definition: CovarianceImpl.hpp:39
A lower-left triangular matrix.
constexpr auto count_indices(const T &)
Get the number of indices necessary to address all the components of an indexible object...
Definition: count_indices.hpp:51
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:59
constexpr bool number
T is a numerical field type.
Definition: number.hpp:41
A diagonal matrix (both a lower-left and an upper-right triangular matrix).
decltype(auto) constexpr cholesky_square(A &&a)
Take the Cholesky square of a triangular_matrix.
Definition: cholesky_square.hpp:33
SquareRootCovariance()
Default constructor.
Definition: SquareRootCovariance.hpp:103
Definition: CovarianceBase3Impl.hpp:35
constexpr bool hermitian_matrix
Specifies that a type is a hermitian matrix.
Definition: hermitian_matrix.hpp:59
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
SquareRootCovariance(Args ... args)
Construct from Scalar coefficients. Assumes matrix is triangular, and only reads lower left triangle...
Definition: SquareRootCovariance.hpp:186
Definition: object_traits.hpp:38
Definition: CovarianceBase1.hpp:34
SquareRootCovariance(M &&m)
Construct from a covariance_nestable.
Definition: SquareRootCovariance.hpp:132
SquareRootCovariance(M &&m)
Construct from another triangular_covariance.
Definition: SquareRootCovariance.hpp:120
decltype(auto) get_self_adjoint_nested_matrix() &
Definition: CovarianceImpl.hpp:236
An upper-right triangular matrix.
The triangle_type associated with an indexible object.
Definition: triangle_type_of.hpp:63
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
A self-adjoint Covariance matrix.
Definition: Covariance.hpp:30
The dimension of an index for a matrix, expression, or array.
Definition: index_dimension_of.hpp:35
scalar_type_of_t< NestedMatrix > Scalar
Scalar type for this matrix.
Definition: SquareRootCovariance.hpp:43
decltype(auto) get_triangular_nested_matrix() &
Definition: CovarianceImpl.hpp:266
Basic definitions for OpenKalman as a whole.
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:35
SquareRootCovariance(M &&) -> SquareRootCovariance< Dimensions< index_dimension_of_v< M, 0 >>, passable_t< M >>
Deduce SquareRootCovariance type from a covariance_nestable.
Definition: basics.hpp:48