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--present, The Simons Foundation
2// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3// SPDX-License-Identifier: Apache-2.0
4// See LICENSE in the root of this distribution for details.
5
10
11// Extracted from Reference Lapack (https://github.com/Reference-LAPACK):
12#include "./lapack.h"
13#include "./cxx_interface.hpp"
14
15#include <complex>
16
17namespace nda::lapack::f77 {
18
19 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,
20 [[maybe_unused]] double *rwork, int &info) {
21 LAPACK_dgelss(&m, &n, &nrhs, a, &lda, b, &ldb, s, &rcond, &rank, work, &lwork, &info);
22 }
23 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,
24 std::complex<double> *work, int lwork, double *rwork, int &info) {
25 LAPACK_zgelss(&m, &n, &nrhs, a, &lda, b, &ldb, s, &rcond, &rank, work, &lwork, rwork, &info);
26 }
27
28 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,
29 [[maybe_unused]] double *rwork, int &info) {
30 LAPACK_dgesvd(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, &info);
31 }
32 void gesvd(char jobu, char jobvt, int m, int n, std::complex<double> *a, int lda, double *s, std::complex<double> *u, int ldu,
33 std::complex<double> *vt, int ldvt, std::complex<double> *work, int lwork, double *rwork, int &info) {
34 LAPACK_zgesvd(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, rwork, &info);
35 }
36
37 void geqp3(int m, int n, double *a, int lda, int *jpvt, double *tau, double *work, int lwork, [[maybe_unused]] double *rwork, int &info) {
38 LAPACK_dgeqp3(&m, &n, a, &lda, jpvt, tau, work, &lwork, &info);
39 }
40 void geqp3(int m, int n, std::complex<double> *a, int lda, int *jpvt, std::complex<double> *tau, std::complex<double> *work, int lwork,
41 double *rwork, int &info) {
42 LAPACK_zgeqp3(&m, &n, a, &lda, jpvt, tau, work, &lwork, rwork, &info);
43 }
44
45 void orgqr(int m, int n, int k, double *a, int lda, double const *tau, double *work, int lwork, int &info) {
46 LAPACK_dorgqr(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
47 }
48
49 void ungqr(int m, int n, int k, std::complex<double> *a, int lda, std::complex<double> const *tau, std::complex<double> *work, int lwork,
50 int &info) {
51 LAPACK_zungqr(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
52 }
53
54 void getrf(int m, int n, double *a, int lda, int *ipiv, int &info) { LAPACK_dgetrf(&m, &n, a, &lda, ipiv, &info); }
55 void getrf(int m, int n, std::complex<double> *a, int lda, int *ipiv, int &info) { LAPACK_zgetrf(&m, &n, a, &lda, ipiv, &info); }
56
57 void getri(int n, double *a, int lda, int const *ipiv, double *work, int lwork, int &info) {
58 LAPACK_dgetri(&n, a, &lda, ipiv, work, &lwork, &info);
59 }
60 void getri(int n, std::complex<double> *a, int lda, int const *ipiv, std::complex<double> *work, int lwork, int &info) {
61 LAPACK_zgetri(&n, a, &lda, ipiv, work, &lwork, &info);
62 }
63
64 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); }
65 void gtsv(int n, int nrhs, std::complex<double> *dl, std::complex<double> *d, std::complex<double> *du, std::complex<double> *b, int ldb,
66 int &info) {
67 LAPACK_zgtsv(&n, &nrhs, dl, d, du, b, &ldb, &info);
68 }
69
70 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); }
71
72 void syev(char jobz, char uplo, int n, double *a, int lda, double *w, double *work, int lwork, int &info) {
73 LAPACK_dsyev(&jobz, &uplo, &n, a, &lda, w, work, &lwork, &info);
74 }
75
76 void heev(char jobz, char uplo, int n, std::complex<double> *a, int lda, double *w, std::complex<double> *work, int lwork, double *rwork,
77 int &info) {
78 LAPACK_zheev(&jobz, &uplo, &n, a, &lda, w, work, &lwork, rwork, &info);
79 }
80
81 void sygv(int itype, char jobz, char uplo, int n, double *a, int lda, double *b, int ldb, double *w, double *work, int lwork, int &info) {
82 LAPACK_dsygv(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, &info);
83 }
84
85 void hegv(int itype, char jobz, char uplo, int n, std::complex<double> *a, int lda, std::complex<double> *b, int ldb, double *w,
86 std::complex<double> *work, int lwork, double *rwork, int &info) {
87 LAPACK_zhegv(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, rwork, &info);
88 }
89
90 void getrs(char op, int n, int nrhs, double const *a, int lda, int const *ipiv, double *b, int ldb, int &info) {
91 LAPACK_dgetrs(&op, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
92 }
93 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) {
94 LAPACK_zgetrs(&op, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
95 }
96
97 void geev(char jobvl, char jobvr, int n, double *a, int lda, double *wr, double *wi, double *vl, int ldvl, double *vr, int ldvr, double *work,
98 int lwork, int &info) {
99 LAPACK_dgeev(&jobvl, &jobvr, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info);
100 }
101 void geev(char jobvl, char jobvr, int n, std::complex<double> *a, int lda, std::complex<double> *w, std::complex<double> *vl, int ldvl,
102 std::complex<double> *vr, int ldvr, std::complex<double> *work, int lwork, double *rwork, int &info) {
103 LAPACK_zgeev(&jobvl, &jobvr, &n, a, &lda, w, vl, &ldvl, vr, &ldvr, work, &lwork, rwork, &info);
104 }
105
106} // namespace nda::lapack::f77
Provides a C++ interface for various LAPACK routines.