ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
lapack.h
Go to the documentation of this file.
1#ifndef ATEN_KERNELS_LAPACK_H_
2#define ATEN_KERNELS_LAPACK_H_
3
5#include <ATen/core/tensor.h>
7
9
10namespace container {
11namespace kernels {
12
13
14template <typename T, typename Device>
15struct set_matrix {
17 const char& uplo,
18 T* A,
19 const int& dim);
20};
21
22
23// --- 1. Matrix Decomposition ---
24template <typename T, typename Device>
27 const char& uplo,
28 const char& diag,
29 const int& dim,
30 T* Mat,
31 const int& lda);
32};
33
34
35template <typename T, typename Device>
38 const char& uplo,
39 const int& dim,
40 T* Mat,
41 const int& lda);
42};
43
44template <typename T, typename Device>
47 const int& m,
48 const int& n,
49 T* Mat,
50 const int& lda,
51 int* ipiv);
52};
53
54
55template <typename T, typename Device>
58 const int& n,
59 T* Mat,
60 const int& lda,
61 const int* ipiv,
62 T* work,
63 const int& lwork);
64};
65
66// This is QR factorization in-place
67// that will change input Mat A to orthogonal/unitary matrix Q
68template <typename T, typename Device>
88 const int m,
89 const int n,
90 T *A,
91 const int lda,
92 T* rdiag);
93};
94
95// This is QR factorization
96// where [in]Mat will be kept and the results are stored in separate matrix Q
97// template <typename T, typename Device>
98// struct lapack_geqrf{
99// /**
100// * Perform QR factorization of a matrix using LAPACK's geqrf function.
101// *
102// * @param m The number of rows in the matrix.
103// * @param n The number of columns in the matrix.
104// * @param Mat The matrix to be factorized.
105// * On exit, the upper triangle contains the upper triangular matrix R,
106// * and the elements below the diagonal, with the array TAU, represent
107// * the unitary matrix Q as a product of min(m,n) elementary reflectors.
108// * @param lda The leading dimension of the matrix.
109// * @param tau Array of size min(m,n) containing the Householder reflectors.
110// */
111// void operator()(
112// const int m,
113// const int n,
114// T *Mat,
115// const int lda,
116// T *tau);
117// };
118
119
120// --- 2. Linear System Solvers ---
121template <typename T, typename Device>
124 const char& trans,
125 const int& n,
126 const int& nrhs,
127 T* A,
128 const int& lda,
129 const int* ipiv,
130 T* B,
131 const int& ldb);
132};
133
134
135
136// --- 3. Standard & Generalized Eigenvalue ---
137
138// ============================================================================
139// Standard Hermitian Eigenvalue Problem Solvers
140// ============================================================================
141// The following structures (lapack_heevd and lapack_heevx) implement solvers
142// for standard Hermitian eigenvalue problems of the form:
143// A * x = lambda * x
144// where:
145// - A is a Hermitian matrix
146// - lambda are the eigenvalues to be computed
147// - x are the corresponding eigenvectors
148//
149// ============================================================================
150template <typename T, typename Device>
152 // !> ZHEEVD computes all eigenvalues and, optionally, eigenvectors of a
153 // !> complex Hermitian matrix A. If eigenvectors are desired, it uses a
154 // !> divide and conquer algorithm.
155 // !> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
156 // !> orthonormal eigenvectors of the matrix A.
178 using Real = typename GetTypeReal<T>::type;
180 const int dim,
181 T* Mat,
182 const int lda,
183 Real* eigen_val);
184};
185
186template <typename T, typename Device>
188 using Real = typename GetTypeReal<T>::type;
211 const int dim,
212 const int lda,
213 const T *Mat,
214 const int neig,
215 Real *eigen_val,
216 T *eigen_vec);
217};
218
219
220// ============================================================================
221// Generalized Hermitian-definite Eigenvalue Problem Solvers
222// ============================================================================
223// The following structures (lapack_hegvd and lapack_hegvx) implement solvers
224// for generalized Hermitian-definite eigenvalue problems of the form:
225// A * x = lambda * B * x
226// where:
227// - A is a Hermitian matrix
228// - B is a Hermitian positive definite matrix
229// - lambda are the eigenvalues to be computed
230// - x are the corresponding eigenvectors
231//
232// ============================================================================
233
234template <typename T, typename Device>
236 using Real = typename GetTypeReal<T>::type;
255 const int n,
256 const int lda,
257 T *Mat_A,
258 T *Mat_B,
259 Real *eigen_val,
260 T *eigen_vec);
261};
262
263template <typename T, typename Device>
265 using Real = typename GetTypeReal<T>::type;
288 const int n,
289 const int lda,
290 T *Mat_A,
291 T *Mat_B,
292 const int m,
293 Real *eigen_val,
294 T *eigen_vec);
295};
296
297
298#if defined(__CUDA) || defined(__ROCM)
299// TODO: Use C++ singleton to manage the GPU handles
300void createGpuSolverHandle(); // create cusolver handle
301void destroyGpuSolverHandle(); // destroy cusolver handle
302#endif
303
304} // namespace container
305} // namespace kernels
306
307#endif // ATEN_KERNELS_LAPACK_H_
This is a direct wrapper of some LAPACK routines. Column-Major version. Direct wrapping of standard L...
#define T
Definition exp.cpp:237
Definition blas.cpp:4
Definition tensor.cpp:8
T type
Definition tensor_types.h:51
void operator()(const int m, const int n, T *A, const int lda, T *rdiag)
Perform in-place QR factorization of a matrix using LAPACK's geqrf function.
Definition lapack.h:45
void operator()(const int &m, const int &n, T *Mat, const int &lda, int *ipiv)
Definition lapack.h:56
void operator()(const int &n, T *Mat, const int &lda, const int *ipiv, T *work, const int &lwork)
Definition lapack.h:122
void operator()(const char &trans, const int &n, const int &nrhs, T *A, const int &lda, const int *ipiv, T *B, const int &ldb)
Definition lapack.h:151
void operator()(const int dim, T *Mat, const int lda, Real *eigen_val)
typename GetTypeReal< T >::type Real
Computes all eigenvalues and, optionally, eigenvectors of a complex Hermitian matrix.
Definition lapack.h:178
Definition lapack.h:187
typename GetTypeReal< T >::type Real
Definition lapack.h:188
void operator()(const int dim, const int lda, const T *Mat, const int neig, Real *eigen_val, T *eigen_vec)
Computes selected eigenvalues and, optionally, eigenvectors of a complex Hermitian matrix.
Definition lapack.h:235
void operator()(const int n, const int lda, T *Mat_A, T *Mat_B, Real *eigen_val, T *eigen_vec)
Computes all the eigenvalues and, optionally, the eigenvectors of a complex generalized Hermitian-def...
typename GetTypeReal< T >::type Real
Definition lapack.h:236
Definition lapack.h:264
void operator()(const int n, const int lda, T *Mat_A, T *Mat_B, const int m, Real *eigen_val, T *eigen_vec)
typename GetTypeReal< T >::type Real
Definition lapack.h:265
Definition lapack.h:36
void operator()(const char &uplo, const int &dim, T *Mat, const int &lda)
Definition lapack.h:25
void operator()(const char &uplo, const char &diag, const int &dim, T *Mat, const int &lda)
Definition lapack.h:15
void operator()(const char &uplo, T *A, const int &dim)
This file contains the definition of the DataType enum class.