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::syrk_potrf(M, N, A.cols())) * C.depth());
26 // Degenerate case
27 if (M == 0 || N == 0) [[unlikely]]
28 return;
30}
31
32template <class T, class Abi, index_t R, index_t S, StorageOrder OD>
33 requires(std::is_same_v<Abi, datapar::scalar_abi<T>> && OD == StorageOrder::ColMajor) // TODO
35 // Check dimensions
36 BATMAT_ASSERT(A.rows() == D.rows());
37 BATMAT_ASSERT(A.cols() == D.cols());
38 BATMAT_ASSERT(D.rows() >= D.cols());
39 const index_t M = D.rows(), N = D.cols();
40 GUANAQO_TRACE_LINALG("small_potrf_left", total(flops::syrk_potrf(M, N, A.cols())) * C.depth());
41 // Degenerate case
42 if (M == 0 || N == 0) [[unlikely]]
43 return;
45}
46} // namespace detail
47
48/// @addtogroup topic-linalg
49/// @{
50
51/// @name Cholesky factorization of a single matrix
52/// @{
53
54/// D = chol(A) with A symmetric, D triangular
55template <index_t R = 4, MatrixStructure SD, simdifiable VA, simdifiable VD>
58 static_assert(std::is_same_v<simdified_abi_t<VD>, datapar::scalar_abi<simdified_value_t<VD>>>);
59 static_assert(SD == MatrixStructure::LowerTriangular);
60 static_assert(D.value.storage_order == StorageOrder::ColMajor);
62 simdify(D.value));
63}
64
65/// D = chol(D) with D symmetric as input, triangular as output
66template <index_t R = 4, MatrixStructure SD, simdifiable VD>
70
71/// D = chol(A) with A symmetric, D triangular
72template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VA, simdifiable VD>
75 static_assert(std::is_same_v<simdified_abi_t<VD>, datapar::scalar_abi<simdified_value_t<VD>>>);
76 static_assert(SD == MatrixStructure::LowerTriangular);
77 static_assert(D.value.storage_order == StorageOrder::ColMajor);
79 simdify(A.value).as_const(), simdify(D.value));
80}
81
82/// D = chol(D) with D symmetric as input, triangular as output
83template <index_t R = 4, index_t S = 8, MatrixStructure SD, simdifiable VD>
87
88/// @}
89
90/// @}
91
92} // 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
void small_potrf(Structured< VA, SD > A, Structured< VD, SD > D)
D = chol(A) with A symmetric, D triangular.
void small_potrf_left(Structured< VA, SD > A, Structured< VD, SD > D)
D = chol(A) with A 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< T, Abi, OD > D)
void small_potrf(view< const T, Abi, OD > A, view< T, Abi, OD > D)
void small_potrf(view< const T, datapar::scalar_abi< T > > A, view< T, datapar::scalar_abi< T > > L, index_t n=-1) noexcept
void small_potrf_left(view< const T, datapar::scalar_abi< T > > A, view< T, datapar::scalar_abi< T > > L) 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.