11 #ifndef OPENKALMAN_SQUAREROOTCOVARIANCE_HPP 12 #define OPENKALMAN_SQUAREROOTCOVARIANCE_HPP 24 template<fixed_pattern StaticDescriptor, covariance_nestable NestedMatrix> requires
25 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<NestedMatrix, 0>) and
26 (not std::is_rvalue_reference_v<NestedMatrix>) and values::number<scalar_type_of_t<NestedMatrix>>
28 template<
typename StaticDescriptor,
typename NestedMatrix>
33 #ifndef __cpp_concepts 34 static_assert(fixed_pattern<StaticDescriptor>);
35 static_assert(covariance_nestable<NestedMatrix>);
36 static_assert(coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<NestedMatrix, 0>);
37 static_assert(not std::is_rvalue_reference_v<NestedMatrix>);
47 using typename Base::CholeskyNestedMatrix;
49 using Base::cholesky_nested_matrix;
50 using Base::synchronization_direction;
51 using Base::synchronize_forward;
52 using Base::synchronize_reverse;
53 using Base::mark_nested_matrix_changed;
54 using Base::mark_cholesky_nested_matrix_changed;
55 using Base::mark_synchronized;
59 static constexpr
auto dim = index_dimension_of_v<NestedMatrix, 0>;
63 triangle_type_of_v<typename MatrixTraits<std::decay_t<NestedMatrix>>::template TriangularAdapterFrom<>>;
66 using NestedTriangular = std::conditional_t<triangular_matrix<NestedMatrix>, NestedMatrix,
67 typename MatrixTraits<std::decay_t<NestedMatrix>>::template TriangularAdapterFrom<triangle_type>>;
71 template<
typename C = StaticDescriptor,
typename Arg>
72 static auto make(Arg&& arg)
82 template<self_adjo
int_covariance M> requires (not diagonal_matrix<M> or identity_matrix<M> or zero<M>) and
85 template<
typename M, std::enable_if_t<self_adjo
int_covariance<M> and
86 (not diagonal_matrix<M> or
identity_matrix<M> or zero<M>) and
87 (hermitian_matrix<nested_
object_of_t<M>> == hermitian_matrix<NestedMatrix>),
int> = 0>
101 template<
typename T = Base, std::enable_if_t<std::is_default_constructible_v<T>,
int> = 0>
110 #ifdef __cpp_concepts 111 template<triangular_covariance M> requires (not std::derived_from<std::decay_t<M>, SquareRootCovariance>) and
112 (triangle_type_of_v<M> == triangle_type_of_v<SquareRootCovariance>) and requires(M&& m) {
Base {std::forward<M>(m)}; }
114 template<
typename M, std::enable_if_t<
115 triangular_covariance<M> and (not std::is_base_of_v<SquareRootCovariance, std::decay_t<M>>) and
117 std::is_constructible_v<Base, M&&>,
int> = 0>
125 #ifdef __cpp_concepts 126 template<covariance_nestable M> requires requires(M&& m) {
Base {std::forward<M>(m)}; }
128 template<
typename M, std::enable_if_t<covariance_nestable<M> and
129 std::is_constructible_v<Base, M&&>,
int> = 0>
140 #ifdef __cpp_concepts 141 template<typed_matrix M> requires (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
142 compares_with<vector_space_descriptor_of_t<M, 0>, StaticDescriptor> and
143 requires(M&& m) {
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))}; }
145 template<
typename M, std::enable_if_t<typed_matrix<M> and
146 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
147 compares_with<vector_space_descriptor_of_t<M, 0>, StaticDescriptor> and
148 std::is_constructible_v<Base,
149 decltype(oin::to_covariance_nestable<NestedTriangular>(std::declval<M&&>()))>,
int> = 0>
152 :
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))} {}
161 #ifdef __cpp_concepts 162 template<typed_matrix_nestable M> requires (not covariance_nestable<M>) and
163 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
164 requires(M&& m) {
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))}; }
166 template<
typename M, std::enable_if_t<typed_matrix_nestable<M> and (not covariance_nestable<M>) and
167 (square_shaped<M> or (diagonal_matrix<NestedMatrix> and vector<M>)) and
168 std::is_constructible_v<Base,
169 decltype(oin::to_covariance_nestable<NestedTriangular>(std::declval<M&&>()))>,
int> = 0>
172 :
Base {oin::to_covariance_nestable<NestedTriangular>(std::forward<M>(m))} {}
176 #ifdef __cpp_concepts 177 template<std::convertible_to<const Scalar> ... Args> requires (
sizeof...(Args) > 0) and
178 requires(Args ... args) {
Base {make_dense_object_from<NestedTriangular>(
static_cast<const Scalar>(args)...)};
181 template<
typename ... Args, std::enable_if_t<(std::is_convertible_v<Args, const Scalar> and ...) and
182 ((diagonal_matrix<NestedMatrix> and
sizeof...(Args) == dim) or
183 (
sizeof...(Args) == dim * dim)) and std::is_constructible_v<Base, NestedTriangular&&>,
int> = 0>
186 :
Base {make_dense_object_from<NestedTriangular>(
static_cast<const Scalar>(args)...)} {}
197 #ifdef __cpp_concepts 198 template<triangular_covariance Arg> requires (not std::derived_from<std::decay_t<Arg>, SquareRootCovariance>) and
199 (triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) and
200 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
203 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg> and
204 (not std::is_base_of_v<SquareRootCovariance, std::decay_t<Arg>>) and
205 (triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) and
206 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
207 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, nested_
object_of_t<Arg&&>>,
int> = 0>
211 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
213 Base::operator=(std::forward<Arg>(other));
222 #ifdef __cpp_concepts 223 template<typed_matrix Arg> requires square_shaped<Arg> and
224 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
225 std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>
227 template<
typename Arg, std::enable_if_t<typed_matrix<Arg> and square_shaped<Arg> and
228 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor> and
229 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>,
int> = 0>
233 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
235 Base::operator=(oin::to_covariance_nestable<NestedTriangular>(std::forward<Arg>(other)));
244 #ifdef __cpp_concepts 245 template<covariance_nestable Arg> requires std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, Arg&&>
247 template<
typename Arg, std::enable_if_t<covariance_nestable<Arg> and
248 std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>,
int> = 0>
250 auto& operator=(Arg&& other)
252 if constexpr (not zero<NestedMatrix> and not
identity_matrix<NestedMatrix>)
254 Base::operator=(std::forward<Arg>(other));
263 #ifdef __cpp_concepts
264 template<typed_matrix_nestable Arg> requires (not covariance_nestable<Arg>) and square_shaped<Arg> and
265 std::assignable_from<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>
267 template<
typename Arg, std::enable_if_t<typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
268 square_shaped<Arg> and std::is_assignable_v<std::add_lvalue_reference_t<NestedMatrix>, NestedTriangular>,
int> = 0>
272 if constexpr (not zero<NestedMatrix> and not identity_matrix<NestedMatrix>)
274 Base::operator=(oin::to_covariance_nestable<NestedTriangular>(std::forward<Arg>(other)));
285 #ifdef __cpp_concepts 286 template<
typename Arg> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
287 ((triangular_covariance<Arg> and triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) or
288 (typed_matrix<Arg> and square_shaped<Arg>)) and
289 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>
291 template<
typename Arg, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
292 ((triangular_covariance<Arg> and triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) or
293 (typed_matrix<Arg> and square_shaped<Arg>)) and
294 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>,
int> = 0>
296 auto& operator+=(
const Arg& arg)
298 if constexpr(triangular_matrix<NestedMatrix>)
300 nested_object() += oin::to_covariance_nestable<NestedMatrix>(arg);
301 mark_nested_matrix_changed();
305 if (synchronization_direction() > 0) synchronize_forward();
306 cholesky_nested_matrix() += oin::to_covariance_nestable<NestedTriangular>(arg);
307 if (synchronization_direction() > 0)
309 Base::synchronize_reverse();
313 mark_cholesky_nested_matrix_changed();
324 #ifdef __cpp_concepts 325 auto& operator+=(
const SquareRootCovariance& arg)
326 requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
328 template<
typename T = NestedMatrix, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<T>>),
int> = 0>
329 auto& operator+=(
const SquareRootCovariance& arg)
332 return operator+=<
const SquareRootCovariance&>(arg);
341 #ifdef __cpp_concepts 342 template<
typename Arg> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
343 ((triangular_covariance<Arg> and triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) or
344 (typed_matrix<Arg> and square_shaped<Arg>)) and
345 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>
347 template<
typename Arg, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<NestedMatrix>>) and
348 ((triangular_covariance<Arg> and triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) or
349 (typed_matrix<Arg> and square_shaped<Arg>)) and
350 compares_with<vector_space_descriptor_of_t<Arg, 0>, StaticDescriptor>,
int> = 0>
352 auto& operator-=(
const Arg& arg)
354 if constexpr(triangular_matrix<NestedMatrix>)
356 nested_object() -= oin::to_covariance_nestable<NestedMatrix>(arg);
357 mark_nested_matrix_changed();
361 if (synchronization_direction() > 0) synchronize_forward();
362 cholesky_nested_matrix() -= oin::to_covariance_nestable<NestedTriangular>(arg);
363 if (synchronization_direction() > 0)
365 synchronize_reverse();
369 mark_cholesky_nested_matrix_changed();
380 #ifdef __cpp_concepts 381 auto& operator-=(
const SquareRootCovariance& arg)
382 requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
384 template<
typename T = NestedMatrix, std::enable_if_t<(not std::is_const_v<std::remove_reference_t<T>>),
int> = 0>
385 auto& operator-=(
const SquareRootCovariance& arg)
388 return operator-=<
const SquareRootCovariance&>(arg);
392 #ifdef __cpp_concepts 393 template<std::convertible_to<Scalar> S> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
395 template<
typename S, std::enable_if_t<std::is_convertible_v<S, Scalar> and
396 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
398 auto& operator*=(
const S s)
400 if constexpr(triangular_matrix<NestedMatrix>)
403 mark_nested_matrix_changed();
408 if (synchronization_direction() <= 0) cholesky_nested_matrix() *=
static_cast<const Scalar>(s);
414 #ifdef __cpp_concepts 415 template<std::convertible_to<Scalar> S> requires (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
417 template<
typename S, std::enable_if_t<std::is_convertible_v<S, Scalar> and
418 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
420 auto& operator/=(
const S s)
422 if constexpr(triangular_matrix<NestedMatrix>)
425 mark_nested_matrix_changed();
430 if (synchronization_direction() <= 0) cholesky_nested_matrix() /=
static_cast<const Scalar>(s);
442 #ifdef __cpp_concepts 443 template<triangular_covariance Arg> requires (triangle_type_of_v<Arg> == triangle_type_of_v<SquareRootCovariance>) and
444 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
446 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg> and
447 (triangle_type_of<Arg>::value == triangle_type_of<SquareRootCovariance>::value) and
448 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
450 auto& operator*=(
const Arg& arg)
452 if constexpr(triangular_matrix<NestedMatrix>)
454 nested_object() *= oin::to_covariance_nestable<NestedMatrix>(arg);
455 mark_nested_matrix_changed();
459 if (synchronization_direction() > 0) synchronize_forward();
460 cholesky_nested_matrix() *= oin::to_covariance_nestable<NestedTriangular>(arg);
461 if (synchronization_direction() > 0)
463 synchronize_reverse();
467 mark_cholesky_nested_matrix_changed();
486 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
499 auto square()
const &
501 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
516 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
529 auto square()
const &&
531 if constexpr ((not diagonal_matrix<NestedMatrix>) or identity_matrix<NestedMatrix> or zero<NestedMatrix>)
546 #ifdef __cpp_concepts 547 template<typed_matrix U> requires compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor> and
548 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>)
550 template<
typename U, std::enable_if_t<typed_matrix<U> and
551 compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor> and
552 (not std::is_const_v<std::remove_reference_t<NestedMatrix>>),
int> = 0>
554 auto& rank_update(
const U& u,
const Scalar alpha = 1) &
556 if (synchronization_direction() < 0) synchronize_reverse();
558 mark_nested_matrix_changed();
566 #ifdef __cpp_concepts 567 template<typed_matrix U> requires compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor>
569 template<
typename U, std::enable_if_t<typed_matrix<U> and
570 compares_with<vector_space_descriptor_of_t<U, 0>, StaticDescriptor>,
int> = 0>
572 auto rank_update(
const U& u,
const Scalar alpha = 1) &&
574 if (synchronization_direction() < 0) synchronize_reverse();
580 #ifdef __cpp_concepts 581 template<
typename,
typename>
583 template<
typename,
typename,
typename>
588 template<
typename,
typename>
592 template<
typename,
typename>
596 #ifdef __cpp_concepts 597 template<fixed_pattern C, covariance_nestable N> requires
598 (coordinates::dimension_of_v<C> == index_dimension_of_v<N, 0>) and (not std::is_rvalue_reference_v<N>)
600 template<
typename,
typename>
602 friend struct SquareRootCovariance;
605 #ifdef __cpp_concepts 606 template<fixed_pattern C, covariance_nestable N> requires
607 (coordinates::dimension_of_v<C> == index_dimension_of_v<N, 0>) and (not std::is_rvalue_reference_v<N>)
609 template<
typename,
typename>
623 #ifdef __cpp_concepts 624 template<covariance_nestable M>
626 template<
typename M, std::enable_if_t<covariance_nestable<M>,
int> = 0>
634 #ifdef __cpp_concepts 635 template<typed_matrix M> requires square_shaped<M>
637 template<
typename M, std::enable_if_t<typed_matrix<M> and square_shaped<M>,
int> = 0>
640 typename MatrixTraits<std::decay_t<nested_object_of_t<M>>>::template TriangularAdapterFrom<>>;
646 #ifdef __cpp_concepts 647 template<typed_matrix_nestable M> requires (not covariance_nestable<M>) and square_shaped<M>
649 template<
typename M, std::enable_if_t<
650 typed_matrix_nestable<M> and (not covariance_nestable<M>) and square_shaped<M>,
int> = 0>
653 typename MatrixTraits<std::decay_t<M>>::template TriangularAdapterFrom<>>;
665 #ifdef __cpp_concepts 666 template<fixed_pattern StaticDescriptor, covariance_nestable Arg> requires
667 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 0>)
669 template<
typename StaticDescriptor,
typename Arg, std::enable_if_t<fixed_pattern<StaticDescriptor> and
670 covariance_nestable<Arg> and (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of<Arg, 0>::value),
int> = 0>
685 #ifdef __cpp_concepts 686 template<covariance_nestable Arg>
688 template<
typename Arg, std::enable_if_t<covariance_nestable<Arg>,
int> = 0>
693 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
694 return make_square_root_covariance<C>(std::forward<Arg>(arg));
705 #ifdef __cpp_concepts 706 template<fixed_pattern StaticDescriptor, TriangleType triangle_type = TriangleType::lower, typed_matrix_nestable Arg>
707 requires (not covariance_nestable<Arg>) and
709 (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 0>) and (coordinates::dimension_of_v<StaticDescriptor> == index_dimension_of_v<Arg, 1>)
712 fixed_pattern<StaticDescriptor> and typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
720 using T =
typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<triangle_type>;
731 #ifdef __cpp_concepts 732 template<TriangleType triangle_type = TriangleType::lower, typed_matrix_nestable Arg> requires
733 (not covariance_nestable<Arg>) and
737 typed_matrix_nestable<Arg> and (not covariance_nestable<Arg>) and
743 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
744 return make_square_root_covariance<C, triangle_type>(std::forward<Arg>(arg));
752 #ifdef __cpp_concepts 753 template<fixed_pattern StaticDescriptor, TriangleType triangle_type, typed_matrix_nestable Arg> requires square_shaped<Arg>
755 template<
typename StaticDescriptor,
TriangleType triangle_type,
typename Arg,
756 std::enable_if_t<fixed_pattern<StaticDescriptor> and typed_matrix_nestable<Arg> and square_shaped<Arg>,
int> = 0>
762 typename MatrixTraits<std::decay_t<Arg>>::template DiagonalMatrixFrom<>,
763 typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<triangle_type>>;
772 #ifdef __cpp_concepts 773 template<fixed_pattern StaticDescriptor,
typename Arg> requires
774 (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>
776 template<
typename StaticDescriptor,
typename Arg, std::enable_if_t<
777 (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>,
int> = 0>
782 constexpr
TriangleType template_type = triangle_type_of_v<typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<>>;
783 using B = std::conditional_t<diagonal_matrix<Arg>,
784 typename MatrixTraits<std::decay_t<Arg>>::template DiagonalMatrixFrom<>,
785 std::conditional_t<hermitian_matrix<Arg>,
786 typename MatrixTraits<std::decay_t<Arg>>::template SelfAdjointMatrixFrom<template_type>,
787 typename MatrixTraits<std::decay_t<Arg>>::template TriangularAdapterFrom<template_type>>>;
797 #ifdef __cpp_concepts 798 template<
typename Arg> requires (covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and square_shaped<Arg>
800 template<
typename Arg, std::enable_if_t<(covariance_nestable<Arg> or typed_matrix_nestable<Arg>) and
801 square_shaped<Arg>,
int> = 0>
806 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
807 return make_square_root_covariance<C, Arg>();
815 #ifdef __cpp_concepts 816 template<TriangleType triangle_type, typed_matrix_nestable Arg> requires square_shaped<Arg>
818 template<
TriangleType triangle_type,
typename Arg, std::enable_if_t<
819 typed_matrix_nestable<Arg> and square_shaped<Arg>,
int> = 0>
824 using C = Dimensions<index_dimension_of_v<Arg, 0>>;
825 return make_square_root_covariance<C, triangle_type, Arg>();
833 #ifdef __cpp_concepts 834 template<triangular_covariance Arg>
836 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg>,
int> = 0>
850 #ifdef __cpp_concepts 851 template<triangular_covariance Arg>
853 template<
typename Arg, std::enable_if_t<triangular_covariance<Arg>,
int> = 0>
860 return make_square_root_covariance<C, B>();
868 #ifdef __cpp_concepts 869 template<TriangleType triangle_type = TriangleType::lower, typed_matrix Arg> requires
872 template<TriangleType triangle_type = TriangleType::lower,
typename Arg, std::enable_if_t<typed_matrix<Arg> and
873 (triangle_type == TriangleType::lower or triangle_type == TriangleType::upper) and square_shaped<Arg>,
int> = 0>
879 return make_square_root_covariance<C, triangle_type>(
nested_object(std::forward<Arg>(arg)));
887 #ifdef __cpp_concepts 888 template<TriangleType triangle_type, typed_matrix Arg> requires square_shaped<Arg>
890 template<
TriangleType triangle_type,
typename Arg, std::enable_if_t<
891 typed_matrix<Arg> and square_shaped<Arg>,
int> = 0>
898 return make_square_root_covariance<C, triangle_type, B>();
906 #ifdef __cpp_concepts 907 template<typed_matrix Arg> requires square_shaped<Arg>
909 template<
typename Arg, std::enable_if_t<typed_matrix<Arg> and square_shaped<Arg>,
int> = 0>
916 return make_square_root_covariance<C, B>();
926 template<
typename Coeffs,
typename NestedMatrix>
931 template<
typename Arg>
932 static constexpr
auto count_indices(
const Arg& arg) {
return std::integral_constant<std::size_t, 2>{}; }
934 template<
typename Arg,
typename N>
937 return std::forward<Arg>(arg).my_dimension;
941 template<
typename Arg>
944 if constexpr (hermitian_matrix<NestedMatrix>)
951 template<
typename Arg>
952 static constexpr
auto get_constant(
const Arg& arg)
954 if constexpr (zero<NestedMatrix>)
957 return std::monostate {};
961 template<
typename Arg>
962 static constexpr
auto get_constant_diagonal(
const Arg& arg)
968 template<Applicability b>
969 static constexpr
bool one_dimensional = OpenKalman::one_dimensional<NestedMatrix, b>;
972 template<Applicability b>
973 static constexpr
bool is_square =
true;
976 template<TriangleType t>
977 static constexpr
bool is_triangular = triangular_matrix<NestedMatrix, t> or
978 hermitian_adapter<NestedMatrix, t == TriangleType::upper ? HermitianAdapterType::upper : HermitianAdapterType::lower>;
981 static constexpr
bool is_triangular_adapter =
false;
984 static constexpr
bool is_hermitian =
false;
987 #ifdef __cpp_lib_concepts 988 template<
typename Arg,
typename...I> requires
991 template<
typename Arg,
typename...I, std::enable_if_t<
994 static constexpr
auto get(Arg&& arg, I...i)
996 return std::forward<Arg>(arg)(i...);
1000 #ifdef __cpp_lib_concepts 1001 template<
typename Arg,
typename...I> requires
1004 template<
typename Arg,
typename...I, std::enable_if_t<
1009 arg.set_component(s, i...);
1015 #ifdef __cpp_lib_concepts 1016 template<
typename Arg> requires one_dimensional<NestedMatrix> and raw_data_defined_for<NestedMatrix>
1018 template<
typename Arg, std::enable_if_t<one_dimensional<NestedMatrix> and raw_data_defined_for<NestedMatrix>,
int> = 0>
1020 static constexpr
auto *
const 1021 raw_data(Arg& arg) {
return internal::raw_data(arg.nested_object()); }
1024 static constexpr
Layout layout = one_dimensional<NestedMatrix> ? layout_of_v<NestedMatrix> :
Layout::none;
1034 #endif //OPENKALMAN_SQUAREROOTCOVARIANCE_HPP constexpr auto count_indices(const T &t)
Get the number of indices available to address the components of an indexible object.
Definition: count_indices.hpp:33
typename nested_object_of< T >::type nested_object_of_t
Helper type for nested_object_of.
Definition: nested_object_of.hpp:66
auto make_square_root_covariance(Arg &&arg)
Make a SquareRootCovariance from a covariance_nestable, specifying the coefficients.
Definition: SquareRootCovariance.hpp:673
constexpr bool one_dimensional
Specifies that a type is one-dimensional in every index.
Definition: one_dimensional.hpp:83
TriangleType
The type of a triangular matrix.
Definition: global-definitions.hpp:60
Definition: indexible_object_traits.hpp:36
auto & operator=(Arg &&other)
Assign from a compatible triangular_covariance.
Definition: SquareRootCovariance.hpp:209
auto & operator=(Arg &&other)
Assign from a compatible typed_matrix (assumed, without checking, to be triangular).
Definition: SquareRootCovariance.hpp:231
Definition: CovarianceImpl.hpp:39
No storage layout (e.g., if the elements are calculated rather than stored).
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
constexpr bool number
T is a numerical type.
Definition: number.hpp:33
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:102
Definition: CovarianceBase3Impl.hpp:35
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
The upper or lower triangle Cholesky factor (square root) of a covariance matrix. ...
Definition: forward-class-declarations.hpp:559
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:37
SquareRootCovariance(Args ... args)
Construct from Scalar coefficients. Assumes matrix is triangular, and only reads lower left triangle...
Definition: SquareRootCovariance.hpp:185
The constant associated with T, assuming T is a constant_diagonal_matrix.
Definition: constant_diagonal_coefficient.hpp:32
Definition: CovarianceBase1.hpp:34
SquareRootCovariance(M &&m)
Construct from a covariance_nestable.
Definition: SquareRootCovariance.hpp:131
SquareRootCovariance(M &&m)
Construct from another triangular_covariance.
Definition: SquareRootCovariance.hpp:119
typename vector_space_descriptor_of< T, N >::type vector_space_descriptor_of_t
helper template for vector_space_descriptor_of.
Definition: vector_space_descriptor_of.hpp:56
decltype(auto) get_self_adjoint_nested_matrix() &
Definition: CovarianceImpl.hpp:236
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47
The common TriangleType associated with a set of triangular matrices.
Definition: triangle_type_of.hpp:29
A self-adjoint Covariance matrix.
Definition: Covariance.hpp:30
A diagonal matrix (both a lower-left and an upper-right triangular matrix).
The dimension of an index for a matrix, expression, or array.
Definition: index_dimension_of.hpp:34
scalar_type_of_t< NestedMatrix > Scalar
Scalar type for this matrix.
Definition: SquareRootCovariance.hpp:42
decltype(auto) get_triangular_nested_matrix() &
Definition: CovarianceImpl.hpp:266
decltype(auto) constexpr nested_object(Arg &&arg)
Retrieve a nested object of Arg, if it exists.
Definition: nested_object.hpp:34
SquareRootCovariance(M &&) -> SquareRootCovariance< Dimensions< index_dimension_of_v< M, 0 >>, passable_t< M >>
Deduce SquareRootCovariance type from a covariance_nestable.
A lower-left triangular matrix.
Definition: basics.hpp:48
constexpr bool hermitian_matrix
Specifies that a type is a hermitian matrix (assuming it is square_shaped).
Definition: hermitian_matrix.hpp:50
constexpr auto get_vector_space_descriptor(const T &t, const N &n)
Get the coordinates::pattern object for index N of indexible object T.
Definition: get_vector_space_descriptor.hpp:56