TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
cxx_interface.cpp
Go to the documentation of this file.
1// Copyright (c) 2019-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Jason Kaye, Olivier Parcollet, Nils Wentzell
16
17/**
18 * @file
19 * @brief Implementation details for lapack/interface/cxx_interface.hpp.
20 */
21
22// Extracted from Reference Lapack (https://github.com/Reference-LAPACK):
23#include "./lapack.h"
24#include "./cxx_interface.hpp"
25
26#include <complex>
27
28namespace nda::lapack::f77 {
29
30 void gelss(int M, int N, int NRHS, double *A, int LDA, double *B, int LDB, double *S, double RCOND, int &RANK, double *WORK, int LWORK,
31 [[maybe_unused]] double *RWORK, int &INFO) {
32 LAPACK_dgelss(&M, &N, &NRHS, A, &LDA, B, &LDB, S, &RCOND, &RANK, WORK, &LWORK, &INFO);
33 }
34 void gelss(int M, int N, int NRHS, std::complex<double> *A, int LDA, std::complex<double> *B, int LDB, double *S, double RCOND, int &RANK,
35 std::complex<double> *WORK, int LWORK, double *RWORK, int &INFO) {
36 LAPACK_zgelss(&M, &N, &NRHS, A, &LDA, B, &LDB, S, &RCOND, &RANK, WORK, &LWORK, RWORK, &INFO);
37 }
38
39 void gesvd(char JOBU, char JOBVT, int M, int N, double *A, int LDA, double *S, double *U, int LDU, double *VT, int LDVT, double *WORK, int LWORK,
40 [[maybe_unused]] double *RWORK, int &INFO) {
41 LAPACK_dgesvd(&JOBU, &JOBVT, &M, &N, A, &LDA, S, U, &LDU, VT, &LDVT, WORK, &LWORK, &INFO);
42 }
43 void gesvd(char JOBU, char JOBVT, int M, int N, std::complex<double> *A, int LDA, double *S, std::complex<double> *U, int LDU,
44 std::complex<double> *VT, int LDVT, std::complex<double> *WORK, int LWORK, double *RWORK, int &INFO) {
45 LAPACK_zgesvd(&JOBU, &JOBVT, &M, &N, A, &LDA, S, U, &LDU, VT, &LDVT, WORK, &LWORK, RWORK, &INFO);
46 }
47
48 void geqp3(int M, int N, double *A, int LDA, int *JPVT, double *TAU, double *WORK, int LWORK, [[maybe_unused]] double *RWORK, int &INFO) {
49 LAPACK_dgeqp3(&M, &N, A, &LDA, JPVT, TAU, WORK, &LWORK, &INFO);
50 }
51 void geqp3(int M, int N, std::complex<double> *A, int LDA, int *JPVT, std::complex<double> *TAU, std::complex<double> *WORK, int LWORK,
52 double *RWORK, int &INFO) {
53 LAPACK_zgeqp3(&M, &N, A, &LDA, JPVT, TAU, WORK, &LWORK, RWORK, &INFO);
54 }
55
56 void orgqr(int M, int N, int K, double *A, int LDA, double *TAU, double *WORK, int LWORK, int &INFO) {
57 LAPACK_dorgqr(&M, &N, &K, A, &LDA, TAU, WORK, &LWORK, &INFO);
58 }
59
60 void ungqr(int M, int N, int K, std::complex<double> *A, int LDA, std::complex<double> *TAU, std::complex<double> *WORK, int LWORK, int &INFO) {
61 LAPACK_zungqr(&M, &N, &K, A, &LDA, TAU, WORK, &LWORK, &INFO);
62 }
63
64 void getrf(int M, int N, double *A, int LDA, int *ipiv, int &info) { LAPACK_dgetrf(&M, &N, A, &LDA, ipiv, &info); }
65 void getrf(int M, int N, std::complex<double> *A, int LDA, int *ipiv, int &info) { LAPACK_zgetrf(&M, &N, A, &LDA, ipiv, &info); }
66
67 void getri(int N, double *A, int LDA, int const *ipiv, double *work, int lwork, int &info) {
68 LAPACK_dgetri(&N, A, &LDA, ipiv, work, &lwork, &info);
69 }
70 void getri(int N, std::complex<double> *A, int LDA, int const *ipiv, std::complex<double> *work, int lwork, int &info) {
71 LAPACK_zgetri(&N, A, &LDA, ipiv, work, &lwork, &info);
72 }
73
74 void gtsv(int N, int NRHS, double *DL, double *D, double *DU, double *B, int LDB, int &info) { LAPACK_dgtsv(&N, &NRHS, DL, D, DU, B, &LDB, &info); }
75 void gtsv(int N, int NRHS, std::complex<double> *DL, std::complex<double> *D, std::complex<double> *DU, std::complex<double> *B, int LDB,
76 int &info) {
77 LAPACK_zgtsv(&N, &NRHS, DL, D, DU, B, &LDB, &info);
78 }
79
80 void stev(char J, int N, double *D, double *E, double *Z, int ldz, double *work, int &info) { LAPACK_dstev(&J, &N, D, E, Z, &ldz, work, &info); }
81
82 void syev(char JOBZ, char UPLO, int N, double *A, int LDA, double *W, double *work, int &lwork, int &info) {
83 LAPACK_dsyev(&JOBZ, &UPLO, &N, A, &LDA, W, work, &lwork, &info);
84 }
85
86 void heev(char JOBZ, char UPLO, int N, std::complex<double> *A, int LDA, double *W, std::complex<double> *work, int &lwork, double *work2,
87 int &info) {
88 LAPACK_zheev(&JOBZ, &UPLO, &N, A, &LDA, W, work, &lwork, work2, &info);
89 }
90
91 void getrs(char op, int N, int NRHS, double const *A, int LDA, int const *ipiv, double *B, int LDB, int &info) {
92 LAPACK_dgetrs(&op, &N, &NRHS, A, &LDA, ipiv, B, &LDB, &info);
93 }
94 void getrs(char op, int N, int NRHS, std::complex<double> const *A, int LDA, int const *ipiv, std::complex<double> *B, int LDB, int &info) {
95 LAPACK_zgetrs(&op, &N, &NRHS, A, &LDA, ipiv, B, &LDB, &info);
96 }
97
98} // namespace nda::lapack::f77
#define LAPACK_dstev
Definition lapack.h:4287
#define LAPACK_dgeqp3
Definition lapack.h:863
#define LAPACK_dgelss
Definition lapack.h:737
#define LAPACK_zgetrs
Definition lapack.h:1302
#define LAPACK_zheev
Definition lapack.h:1927
#define LAPACK_dgtsv
Definition lapack.h:1713
#define LAPACK_dgesvd
Definition lapack.h:1111
#define LAPACK_dgetrs
Definition lapack.h:1294
#define LAPACK_dgetrf
Definition lapack.h:1253
#define LAPACK_zgtsv
Definition lapack.h:1719
#define LAPACK_zgesvd
Definition lapack.h:1119
#define LAPACK_dsyev
Definition lapack.h:4385
#define LAPACK_zgetrf
Definition lapack.h:1259
#define LAPACK_zgetri
Definition lapack.h:1286
#define LAPACK_zgelss
Definition lapack.h:745
#define LAPACK_zgeqp3
Definition lapack.h:871
#define LAPACK_dorgqr
Definition lapack.h:3139
#define LAPACK_dgetri
Definition lapack.h:1278
#define LAPACK_zungqr
Definition lapack.h:5765