<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
hetrf_blocked.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_HETRF_BLOCKED_HH
13#define TLAPACK_HETRF_BLOCKED_HH
14
17
18namespace tlapack {
19
33template <class T, TLAPACK_SMATRIX matrix_t>
35 const BlockedLDLOpts& opts)
36{
37 if constexpr (is_same_v<T, type_t<matrix_t>>)
38 return WorkInfo(nrows(A) * opts.nb);
39 else
40 return WorkInfo(0);
41}
42
47template <TLAPACK_UPLO uplo_t,
48 TLAPACK_SMATRIX matrix_t,
49 TLAPACK_VECTOR ipiv_t,
50 TLAPACK_WORKSPACE work_t>
52 matrix_t& A,
53 ipiv_t& ipiv,
54 work_t& work,
55 const BlockedLDLOpts& opts)
56{
57 using T = type_t<matrix_t>;
58 using real_t = real_type<T>;
59 using idx_t = size_type<matrix_t>;
61
62 // Constants
63 const idx_t n = nrows(A);
64 const idx_t nb = opts.nb;
65
66 // check arguments
67 tlapack_check(uplo == Uplo::Lower || uplo == Uplo::Upper);
68 tlapack_check(nrows(A) == ncols(A));
69
70 // Quick return
71 if (n <= 0) return 0;
72 int info = 0;
73 if (uplo == Uplo::Upper) {
74 int j = (int)n;
75 while (j > 1) {
76 int jn = min((int)nb, j);
77 int step = jn;
78 auto Aj = slice(A, range{0, j}, range{0, j});
79 auto ipivj = slice(ipiv, range{0, j});
81 info = info == 0 ? infoj : info;
82 if (ipiv[j - jn] >= j) {
83 --step;
84 }
85 j -= step;
86 }
87 ipiv[0] = min(0, ipiv[0]);
88 }
89 else if (uplo == Uplo::Lower) {
90 int j = 0;
91 while (j < n - 1) {
92 int jn = min((int)(nb), (int)(n)-j);
93 int step = jn;
94 auto Aj = slice(A, range{j, n}, range{j, n});
95 auto ipivj = slice(ipiv, range{j, n});
97 if (infoj > 0) infoj += j;
98 info = info == 0 ? infoj : info;
99 if (ipivj[jn - 1] >= ((int)(n)-j)) {
100 --step;
101 }
102 for (int k = 0; k < step; ++k) {
103 if (ipivj[k] >= 0) {
104 ipivj[k] += j;
105 }
106 else {
107 ipivj[k] -= j;
108 ++k;
109 ipivj[k] -= j;
110 }
111 }
112 j += step;
113 }
114 if (ipiv[n - 1] >= 0) ipiv[n - 1] = n - 1;
115 }
116 return info;
117}
118
123template <TLAPACK_UPLO uplo_t, TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR ipiv_t>
125 matrix_t& A,
126 ipiv_t& ipiv,
127 const BlockedLDLOpts& opts)
128{
129 using T = type_t<matrix_t>;
130
131 // Functor
133
134 // Allocates workspace
136 std::vector<T> work_;
137 auto work = new_matrix(work_, workinfo.m, workinfo.n);
138
140}
141
142template <TLAPACK_UPLO uplo_t, TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR ipiv_t>
143int hetrf_blocked(uplo_t uplo, matrix_t& A, ipiv_t& ipiv)
144{
145 return hetrf_blocked(uplo, A, ipiv, {});
146}
147
148} // namespace tlapack
149
150#endif // TLAPACK_HETRF_BLOCKED_HH
#define TLAPACK_UPLO
Macro for tlapack::concepts::Uplo compatible with C++17.
Definition concepts.hpp:942
#define TLAPACK_SMATRIX
Macro for tlapack::concepts::SliceableMatrix compatible with C++17.
Definition concepts.hpp:899
#define TLAPACK_WORKSPACE
Macro for tlapack::concepts::Workspace compatible with C++17.
Definition concepts.hpp:912
#define TLAPACK_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
int hetrf_blocked(uplo_t uplo, matrix_t &A, ipiv_t &ipiv, const BlockedLDLOpts &opts)
Computes the Bunch-Kaufman factorization of a symmetric or Hermitian matrix A.
Definition hetrf_blocked.hpp:124
int hetf3(uplo_t uplo, matrix_t &A, ipiv_t &ipiv, work_t &work, const BlockedLDLOpts &opts)
Computes the partial factorization of a symmetric or Hermitian matrix A using the Bunch-Kaufman diago...
Definition hetf3.hpp:58
int hetrf_blocked_work(uplo_t uplo, matrix_t &A, ipiv_t &ipiv, work_t &work, const BlockedLDLOpts &opts)
Computes the Bunch-Kaufman factorization of a symmetric or Hermitian matrix A. Workspace is provide...
Definition hetrf_blocked.hpp:51
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
constexpr WorkInfo hetrf_blocked_worksize(const matrix_t &A, const BlockedLDLOpts &opts)
Worspace query of hetrf_blocked()
Definition hetrf_blocked.hpp:34
Computes a partial factorization of a symmetric or Hermitian matrix A using the Bunch-Kaufman diagona...
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
Options struct for hetrf_blocked()
Definition hetf3.hpp:27
Output information in the workspace query.
Definition workspace.hpp:16