PLaSK library

Loading...
Searching...
No Matches
fortran.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
17#ifndef PLASK__SOLVER_VSLAB_FORTRAN_H
18#define PLASK__SOLVER_VSLAB_FORTRAN_H
19
20#include <plask/plask.hpp>
21 using plask::dcomplex;
22
23// BLAS subroutines and functions
24
25// perform one of the matrix-matrix operations B := alpha*op(A)*B, or B := alpha*B*op(A)
26// where alpha is a scalar, B is an m by n matrix, A is a unit, or non-unit, upper or
27// lower triangular matrix and op(A) is one of op(A) = A or A' or conjg(A')
28#define ztrmm F77_GLOBAL(ztrmm,ZTRMM)
29F77SUB ztrmm(const char& side, const char& uplo, const char& transa, const char& diag,
30 const int& m, const int& n, const dcomplex& alpha, dcomplex* a, const int& lda,
31 dcomplex* b, const int& ldb);
32
33// solve one of the matrix equations op(A)*X = alpha*B, or X*op(A) = alpha*B,
34// where alpha is a scalar, X and B are m by n matrix, A is a unit, or non-unit, upper or
35// lower triangular matrix and op(A) is one of op(A) = A or A' or conjg(A')
36// the matrix X is overwritten on
37#define ztrsm F77_GLOBAL(ztrsm,ZTRSM)
38F77SUB ztrsm(const char& side, const char& uplo, const char& transa, const char& diag,
39 const int& m, const int& n, const dcomplex& alpha, dcomplex* a, const int& lda,
40 dcomplex* b, const int& ldb);
41
42// perform one of the matrix-vector operations y := alpha*A*x + beta*y,
43// or y := alpha*A'*x + beta*y, or y := alpha*conjg(A')*x + beta*y,
44#define zgemv F77_GLOBAL(zgemv,ZGEMV)
45F77SUB zgemv(const char& trans, const int& m, const int& n, const dcomplex& alpha,
46 const dcomplex* a, const int& lda, const dcomplex* x, const int& incx,
47 const dcomplex& beta, dcomplex* y, const int& incy);
48
49// perform one of the matrix-matrix operations C := alpha*op(A)*op(B) + beta*C
50#define zgemm F77_GLOBAL(zgemm,ZGEMM)
51F77SUB zgemm(const char& transa, const char& transb, const int& m, const int& n,
52 const int& k, const dcomplex& alpha, const dcomplex *a, const int& lda,
53 const dcomplex *b, const int& ldb, const dcomplex& beta, dcomplex* c,
54 const int& ldc);
55
56
57// LAPACK subroutines
58
59// compute for an N-by-N complex nonsymmetric matrix A, the eigenvalues and, optionally,
60// the left and/or right eigenvectors
61#define zgeev F77_GLOBAL(zgeev,ZGEEV)
62F77SUB zgeev(const char& jobvl, const char& jobvr, const int& n, dcomplex* a,
63 const int& lda, dcomplex* w, dcomplex* vl, const int& ldvl,
64 dcomplex* vr, const int& ldvr, dcomplex* work, const int& lwork,
65 double* rwork, int& info);
66
67// compute the solution to a complex system of linear equations A * X = B
68#define zgesv F77_GLOBAL(zgesv,ZGESV)
69F77SUB zgesv(const int& n, const int& nrsh, dcomplex* a, const int& lda,
70 int* ipiv, dcomplex* b, const int& ldb, int& info);
71
72// compute an LU factorization of a general M-by-N matrix A using partial pivoting
73// with row interchanges
74#define zgetrf F77_GLOBAL(zgetrf,ZGETRF)
75F77SUB zgetrf(const int& m, const int& n, dcomplex* a, const int& lda,
76 int* ipiv, int& info);
77
78// solve a system of linear equations A * X = B, A**T * X = B, or A**H * X = B
79// with a general N-by-N matrix A using the LU factorization computed by ZGETRF
80#define zgetrs F77_GLOBAL(zgetrs,ZGETRS)
81F77SUB zgetrs(const char& trans, const int& n, const int& nrhs, const dcomplex* a,
82 const int& lda, const int* ipiv, dcomplex* b, const int& ldb, int& info);
83
84// compute some or all of the right and/or left eigenvectors of a complex upper triangular matrix T
85#define ztrevc F77_GLOBAL(ztrevc,ZTREVC)
86F77SUB ztrevc(const char& side, const char& howmny, const int* select, const int& n,
87 dcomplex* t, const int& ldt, dcomplex* vl, const int& ldvl, dcomplex* vr,
88 const int& ldvr, const int& mm, int& m, dcomplex* work, double* rwork, int& info);
89
90// reduce a general complex M-by-N matrix A to upper or lower bidiagonal form B by a unitary transformation
91#define zgebrd F77_GLOBAL(zgebrd,ZGEBRD)
92F77SUB zgebrd(const int& m, const int& n, dcomplex* a, const int& lda, double* d, double* e,
93 dcomplex* tauq, dcomplex* taup, dcomplex* work, const int& lwork, int& info);
94
95// compute the singular value decomposition (SVD) of a real N-by-N (upper or lower) bidiagonal matrix B
96#define zbdsqr F77_GLOBAL(zbdsqr,ZBDSQR)
97F77SUB zbdsqr(const char &uplo, const int& n, const int& ncvt, const int& nru, const int& ncc,
98 double* d, double* e, dcomplex* vt, const int& ldvt, dcomplex* u, const int& ldu,
99 dcomplex* c, const int& ldc, double* rwork, int& info);
100
101// compute the singular value decomposition (SVD) of a real N-by-N (upper or lower) bidiagonal matrix B
102// using Divide and Conquer algorithm
103#define dbdsdc F77_GLOBAL(dbdsdc,DBDSDC)
104F77SUB dbdsdc(const char& uplo, const char& compq, const int& n, double* d, double* e,
105 double* u, const int& ldu, double* vt, const int& ldvt, double* q, int* iq,
106 double* work, int* iwork, int& info);
107
108// compute the Cholesky factorization of a complex Hermitian positive definite matrix A stored in packed format
109#define zpptrf F77_GLOBAL(zpptrf,ZPPTRF)
110F77SUB zpptrf(const char& uplo, const int& n, dcomplex* ap, int& info);
111
112// solve a system of linear equations A*X = B with a Hermitian positive definite matrix A in packed storage
113// using the Cholesky factorization A = U**H*U or A = L*L**H computed by zpptrf
114#define zpptrs F77_GLOBAL(zpptrs,ZPPTRS)
115F77SUB zpptrs(const char& uplo, const int& n, const int& nrhs, dcomplex* ap,
116 dcomplex* b, const int& ldb, int& info);
117
118// perform a series of row interchanges on the matrix A.
119#define zlaswp F77_GLOBAL(zlaswp,ZLASWP)
120F77SUB zlaswp(const int& n, dcomplex* a, const int& lda, const int& k1, const int& k2,
121 const int* ipiv, const int& incx);
122
123// compute row and column scalings intended to equilibrate a M-by-N matrix A and reduce its condition number
124#define zgeequ F77_GLOBAL(zgeequ,ZGEEQU)
125F77SUB zgeequ(const int& m, const int& n, const dcomplex* a, const int& lda, double* r, double* c,
126 double& rowcnd, double& colcnd, double& amax, int& info);
127
128// equilibrate a general M by N matrix A using the row and column scaling factors in the vectors R and C
129#define zlaqge F77_GLOBAL(zlaqge,ZLAQGE)
130F77SUB zlaqge(const int& m, const int& n, dcomplex* a, const int& lda, const double* r, const double* c,
131 const double& rowcnd, const double& colcnd, const double& amax, char& equed);
132
133
134// ARPACK subroutines
135
136// reverse communication interface for the Implicitly Restarted Arnoldi iteration
137#define znaupd F77_GLOBAL(znaupd,ZNAUPD)
138F77SUB znaupd(int& ido, const char& bmat, const int& n, const char* which,
139 const int& nev, const double& tol, dcomplex* resid, const int& ncv,
140 dcomplex* v, const int& ldv, int* iparam, int* ipntr,
141 dcomplex* workd, dcomplex* workl, const int& lworkl,
142 double* rwork, int& info);
143
144// this subroutine returns the converged approximations to eigenvalues
145// of A*z = lambda*B*z and eigenvectors and/or an orthonormal basis
146// for the associated approximate invariant subspace
147#define zneupd F77_GLOBAL(zneupd,ZNEUPD)
148F77SUB zneupd(const int& rvec, const char& howmny, const int* select, dcomplex* d,
149 dcomplex* z, const int& ldz, const double& sigma, dcomplex* workev,
150 const char& bmat, const int& n, const char* which, const int& nev,
151 const double& tol, dcomplex* resid, const int& ncv, dcomplex* v,
152 const int& ldv, int* iparam, int* ipntr, dcomplex* workd,
153 dcomplex* workl, const int& lworkl, double* rwork, int& info);
154
155// DSTERF computes all eigenvalues of a symmetric tridiagonal matrix
156// using the Pal-Walker-Kahan variant of the QL or QR algorithm.
157#define dsterf F77_GLOBAL(dsterf,DSTERF)
158F77SUB dsterf(const int& n, double* d, double* e, int& info);
159
160// DSTEGR computes selected eigenvalues and, optionally, eigenvectors
161// of a real symmetric tridiagonal matrix T.
162#define dstegr F77_GLOBAL(dstegr,DSTEGR)
163F77SUB dstegr(const char& jobz, const char& range, const int& n, double* d, double* e,
164 const double& vl, const double& vu, const int& il, const int& iu, const double& abstol,
165 int& m, double* w, double* z, const int& ldz, int* isuppz, double* work, const int& lwork,
166 int& iwork, const int& liwork, int& info);
167
168// DSTEDC computes all eigenvalues and, optionally, eigenvectors of a
169// symmetric tridiagonal matrix using the divide and conquer method.
170#define dstedc F77_GLOBAL(dstedc,DSTEDC)
171F77SUB dstedc(const char& compz, const int& n, double* d, double* e, double* z, const int& ldz,
172 double* work, const int& lwork, int* iwork, const int& liwork, int& info);
173
174#endif // PLASK__SOLVER_VSLAB_FORTRAN_H