batmat develop
Batched linear algebra routines
Loading...
Searching...
No Matches
small-potrf.hpp
Go to the documentation of this file.
1#pragma once
2
10#include <batmat/loop.hpp>
12#include <guanaqo/trace.hpp>
13
14namespace batmat::linalg {
15
16namespace detail {
17template <class T, class Abi, index_t R, StorageOrder OD>
18 requires(std::is_same_v<Abi, datapar::scalar_abi<T>> && OD == StorageOrder::ColMajor) // TODO
20 // Check dimensions
21 BATMAT_ASSERT(A.rows() == D.rows());
22 BATMAT_ASSERT(A.cols() == D.cols());
23 BATMAT_ASSERT(D.rows() >= D.cols());
24 const index_t M = D.rows(), N = D.cols();
25 GUANAQO_TRACE_LINALG("small_potrf", total(flops::potrf(M, N)) * A.depth());
26 // Degenerate case
27 if (M == 0 || N == 0) [[unlikely]]
28 return;
30}
31
32template <class T, class Abi, micro_kernels::small_potrf::KernelConfig Conf, index_t R, index_t S,
33 StorageOrder OD>
34 requires(std::is_same_v<Abi, datapar::scalar_abi<T>> && OD == StorageOrder::ColMajor) // TODO
36 // Check dimensions
37 BATMAT_ASSERT(A.rows() == 0 || A.rows() == D.rows());
38 BATMAT_ASSERT(C.rows() == D.rows());
39 BATMAT_ASSERT(C.cols() == D.cols());
40 BATMAT_ASSERT(D.rows() >= D.cols());
41 const index_t M = D.rows(), N = D.cols();
42 GUANAQO_TRACE_LINALG("small_potrf_left", total(flops::syrk_potrf(M, N, A.cols())) * C.depth());
43 // Degenerate case
44 if (M == 0 || N == 0) [[unlikely]]
45 return;
47}
48} // namespace detail
49
50/// @addtogroup topic-linalg
51/// @{
52
53/// @name Cholesky factorization of a single matrix
54/// @{
55
56/// D = chol(A) with A symmetric, D triangular
57template <index_t R = 4, MatrixStructure SD, simdifiable VA, simdifiable VD>
60 static_assert(std::is_same_v<simdified_abi_t<VD>, datapar::scalar_abi<simdified_value_t<VD>>>);
61 static_assert(SD == MatrixStructure::LowerTriangular);
62 static_assert(decltype(simdify(D.value))::storage_order == StorageOrder::ColMajor);
64 simdify(D.value));
65}
66
67/// D = chol(D) with D symmetric as input, triangular as output
68template <index_t R = 4, MatrixStructure SD, simdifiable VD>
72
73/// D = chol(C+AAᵀ) with C symmetric, D triangular
74template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VA, simdifiable VC,
75 simdifiable VD>
78 static_assert(std::is_same_v<simdified_abi_t<VD>, datapar::scalar_abi<simdified_value_t<VD>>>);
79 static_assert(SD == MatrixStructure::LowerTriangular);
80 static_assert(decltype(simdify(A))::storage_order == StorageOrder::ColMajor);
81 static_assert(decltype(simdify(C.value))::storage_order == StorageOrder::ColMajor);
82 static_assert(decltype(simdify(D.value))::storage_order == StorageOrder::ColMajor);
84 simdify(A).as_const(), simdify(C.value).as_const(), simdify(D.value));
85}
86
87/// D = chol(C-AAᵀ) with C symmetric, D triangular
88template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VA, simdifiable VC,
89 simdifiable VD>
92 static_assert(std::is_same_v<simdified_abi_t<VD>, datapar::scalar_abi<simdified_value_t<VD>>>);
93 static_assert(SD == MatrixStructure::LowerTriangular);
94 static_assert(decltype(simdify(A))::storage_order == StorageOrder::ColMajor);
95 static_assert(decltype(simdify(C.value))::storage_order == StorageOrder::ColMajor);
96 static_assert(decltype(simdify(D.value))::storage_order == StorageOrder::ColMajor);
98 simdify(A).as_const(), simdify(C.value).as_const(), simdify(D.value));
99}
100
101/// D = chol(D+AAᵀ) with D symmetric as input, triangular as output
102template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VA, simdifiable VD>
107
108/// D = chol(D-AAᵀ) with D symmetric as input, triangular as output
109template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VA, simdifiable VD>
114
115/// D = chol(C) with C symmetric, D triangular
116template <index_t R = 4, index_t S = 8, simdifiable VC, MatrixStructure SD, simdifiable VD>
119 decltype(simdify(D.value).as_const()) null{{.data = nullptr, .rows = 0, .cols = 0}};
121}
122
123/// D = chol(D) with D symmetric as input, triangular as output
124template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VD>
128
129/// @}
130
131/// @}
132
133} // namespace batmat::linalg
#define BATMAT_ASSERT(x)
Definition assume.hpp:14
constexpr FlopCount syrk_potrf(index_t m, index_t n, index_t k)
Fused symmetric rank-k update and Cholesky factorization of an m×n matrix with m≥n.
Definition flops.hpp:182
constexpr FlopCount potrf(index_t m, index_t n)
Cholesky factorization and triangular solve for an m×n matrix with m≥n.
Definition flops.hpp:131
void small_potrf(Structured< VA, SD > A, Structured< VD, SD > D)
D = chol(A) with A symmetric, D triangular.
void small_syrk_sub_potrf_left(VA &&A, Structured< VC, SD > C, Structured< VD, SD > D)
D = chol(C-AAᵀ) with C symmetric, D triangular.
void small_potrf_left(Structured< VC, SD > C, Structured< VD, SD > D)
D = chol(C) with C symmetric, D triangular.
void small_syrk_add_potrf_left(VA &&A, Structured< VC, SD > C, Structured< VD, SD > D)
D = chol(C+AAᵀ) with C symmetric, D triangular.
#define GUANAQO_TRACE_LINALG(name, gflops)
deduced_abi< Tp, 1 > scalar_abi
Definition simd.hpp:239
void small_potrf_left(view< const T, Abi, OD > A, view< const T, Abi, OD > C, view< T, Abi, OD > D)
void small_potrf(view< const T, Abi, OD > A, view< T, Abi, OD > D)
void small_potrf_left(view< const T, datapar::scalar_abi< T > > A, view< const T, datapar::scalar_abi< T > > C, view< T, datapar::scalar_abi< T > > D) noexcept
void small_potrf(view< const T, datapar::scalar_abi< T > > A, view< T, datapar::scalar_abi< T > > L, index_t n=-1) noexcept
typename detail::simdified_abi< V >::type simdified_abi_t
Definition simdify.hpp:216
constexpr bool simdify_compatible
Definition simdify.hpp:221
constexpr auto simdify(simdifiable auto &&a) -> simdified_view_t< decltype(a)>
Definition simdify.hpp:228
simd_view_types< std::remove_const_t< T >, Abi >::template view< T, Order > view
Definition uview.hpp:70
int index_t
Definition config.hpp:13
Aligned allocation for matrix storage.
Light-weight wrapper class used for overload resolution of triangular and symmetric matrices.