<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
potrf_blocked_right_looking.hpp
Go to the documentation of this file.
1
5//
6// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
7//
8// This file is part of <T>LAPACK.
9// <T>LAPACK is free software: you can redistribute it and/or modify it under
10// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
11
12#ifndef TLAPACK_POTRF_BLOCKED_RL_HH
13#define TLAPACK_POTRF_BLOCKED_RL_HH
14
16#include "tlapack/blas/gemm.hpp"
17#include "tlapack/blas/herk.hpp"
18#include "tlapack/blas/trsm.hpp"
21
22namespace tlapack {
23
61template <TLAPACK_UPLO uplo_t, TLAPACK_SMATRIX matrix_t>
63{
64 using T = type_t<matrix_t>;
65 using real_t = real_type<T>;
66 using idx_t = size_type<matrix_t>;
67 using range = pair<idx_t, idx_t>;
68
69 // Constants
70 const real_t one(1);
71 const idx_t n = nrows(A);
72 const idx_t nb = opts.nb;
73
74 // check arguments
75 tlapack_check(uplo == Uplo::Lower || uplo == Uplo::Upper);
76 tlapack_check(nrows(A) == ncols(A));
77
78 // Quick return
79 if (n <= 0) return 0;
80
81 // Unblocked code
82 else if (nb >= n)
83 return potf2(uplo, A);
84
85 // Blocked code
86 else {
87 if (uplo == Uplo::Upper) {
88 for (idx_t j = 0; j < n; j += nb) {
89 idx_t jb = min(nb, n - j);
90
91 // Define AJJ
92 auto AJJ = slice(A, range{j, j + jb}, range{j, j + jb});
93
94 int info = potf2(UPPER_TRIANGLE, AJJ);
95 if (info != 0) {
97 info + j,
98 "The leading minor of the reported order is not "
99 "positive definite,"
100 " and the factorization could not be completed.");
101 return info + j;
102 }
103
104 if (j + jb < n) {
105 auto B = slice(A, range{j, j + jb}, range{j + jb, n});
106 auto C = slice(A, range{j + jb, n}, range{j + jb, n});
107
108 trsm(LEFT_SIDE, UPPER_TRIANGLE, CONJ_TRANS, NON_UNIT_DIAG,
109 one, AJJ, B);
110 herk(UPPER_TRIANGLE, CONJ_TRANS, -one, B, one, C);
111 }
112 }
113 }
114 else {
115 for (idx_t j = 0; j < n; j += nb) {
116 idx_t jb = min(nb, n - j);
117
118 // Define AJJ
119 auto AJJ = slice(A, range{j, j + jb}, range{j, j + jb});
120
121 int info = potf2(LOWER_TRIANGLE, AJJ);
122 if (info != 0) {
124 info + j,
125 "The leading minor of the reported order is not "
126 "positive definite,"
127 " and the factorization could not be completed.");
128 return info + j;
129 }
130
131 if (j + jb < n) {
132 auto B = slice(A, range{j + jb, n}, range{j, j + jb});
133 auto C = slice(A, range{j + jb, n}, range{j + jb, n});
134
135 trsm(RIGHT_SIDE, LOWER_TRIANGLE, CONJ_TRANS, NON_UNIT_DIAG,
136 one, AJJ, B);
137 herk(LOWER_TRIANGLE, NO_TRANS, -one, B, one, C);
138 }
139 }
140 }
141
142 return 0;
143 }
144}
145
146} // namespace tlapack
147
148#endif // TLAPACK_POTRF_BLOCKED_RL_HH
void herk(Uplo uplo, Op trans, const alpha_t &alpha, const matrixA_t &A, const beta_t &beta, matrixC_t &C)
Hermitian rank-k update:
Definition herk.hpp:68
void trsm(Side side, Uplo uplo, Op trans, Diag diag, const alpha_t &alpha, const matrixA_t &A, matrixB_t &B)
Solve the triangular matrix-vector equation.
Definition trsm.hpp:76
int potrf_rl(uplo_t uplo, matrix_t &A, const BlockedCholeskyOpts &opts={})
Computes the Cholesky factorization of a Hermitian positive definite matrix A using a blocked algorit...
Definition potrf_blocked_right_looking.hpp:62
int potf2(uplo_t uplo, matrix_t &A)
Computes the Cholesky factorization of a Hermitian positive definite matrix A using a level-2 algorit...
Definition potf2.hpp:58
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
#define tlapack_error(info, detailedInfo)
Error handler.
Definition exceptionHandling.hpp:142
Computes the Cholesky factorization of a Hermitian positive definite matrix A using a level-2 algorit...
Computes the Cholesky factorization of a Hermitian positive definite matrix A using a blocked algorit...
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
Definition potrf_blocked.hpp:22