File lapack_routines.cxx

Serial code to invert a complex tridiagonal system

Complex banded matrix solver

Solves a banded matrix given the matrix in compact form a[0…(n-1)][0…(m1+m2)] and the rhs vector b[0…(n-1)]

a is overwritten, and b is replaced by the solution

Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu

Contact: Ben Dudson, bd512@york.ac.uk

This file is part of BOUT++.

BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.

Functions

void zgtsv_(int *n, int *nrhs, fcmplx *dl, fcmplx *d, fcmplx *du, fcmplx *b, int *ldb, int *info)

Complex tridiagonal inversion.

void dgtsv_(int *n, int *nrhs, BoutReal *dl, BoutReal *d, BoutReal *du, BoutReal *b, int *ldb, int *info)

BoutReal (double) tridiagonal inversion.

void zgbsv_(int *n, int *kl, int *ku, int *nrhs, fcmplx *ab, int *ldab, int *ipiv, fcmplx *b, int *ldb, int *info)

Complex band solver.

int tridag(const dcomplex *a, const dcomplex *b, const dcomplex *c, const dcomplex *r, dcomplex *u, int n)

Use LAPACK routine ZGTSV.

bool tridag(const BoutReal *a, const BoutReal *b, const BoutReal *c, const BoutReal *r, BoutReal *u, int n)
void cyclic_tridag(BoutReal *a, BoutReal *b, BoutReal *c, BoutReal *r, BoutReal *x, int n)
void cband_solve(Matrix<dcomplex> &a, int n, int m1, int m2, Array<dcomplex> &b)

Complex band matrix solver.

Complex band solver using ZGBSV

n Size of the matrix (number of equations) kl Number of subdiagonals ku Number of superdiagonals nrhs Number of RHS vectors to solve ab Array values (2D array) ldab Leading dim. size of ab = 2*KL+KU+1 ipiv output integer array containing pivot permutation b RHS vectors, and solution ldb length of b (= n) info output status

void cyclic_tridag(dcomplex *a, dcomplex *b, dcomplex *c, dcomplex *r, dcomplex *x, int n)

Solve a cyclic tridiagonal matrix.