10 #define LAPACK_INLINE inline
12 #include "tbci/cplx.h"
13 #include "tbci/f_matrix.h"
14 #include "tbci/f_bandmatrix.h"
15 #include "tbci/lapack/lapack_lib.h"
35 double* afb=
new double[n*(2*kl+ku+1)];
39 double* r=
new double[n];
40 double*
c=
new double[n];
45 double* work=
new double[3*n];
50 afb, &ldafb, ipiv, &equed,
52 x.get_fortran_vector(), &n,
53 &rcond, &ferr, &berr, work, iwork, &info);
64 STD__ cerr <<
"Error inverting Matrix A! (" << info <<
")" <<
STD__ endl;
65 STD__ cerr <<
"\n Equalized= " << equed <<
STD__ endl;
66 STD__ cerr <<
" 1/Cond= " << rcond <<
" epsilon= " <<
dlamch_ (
"Epsilon")
68 <<
" b_err= " << berr <<
STD__ endl;
89 for(
int i=0;
i<n;
i++)
92 for(
int j=1; j<=kl; j++) {
if(
i-j>=0) temp(
i,
i-j)=A(
i,
i-j);}
93 for(
int k=1; k<=ku; k++) {
if(
i+k<n) temp(
i,
i+k)=A(
i,
i+k);}
101 STD__ cerr <<
"Error inverting Matrix A! (" << info <<
")" <<
STD__ endl;
117 STD__ cerr <<
"Matrix too small to store fill_in" <<
STD__ endl;
125 STD__ cerr <<
"Error inverting Matrix A! (" << info <<
")" <<
STD__ endl;
151 STD__ cerr <<
"Error inverting Matrix A!" <<
STD__ endl;
176 STD__ cerr <<
"Error inverting Matrix A!" <<
STD__ endl;
187 for (
int i=0;
i<n;
i++)
204 STD__ cerr <<
"Error inverting Matrix A!" <<
STD__ endl;
221 for (
int i=0;
i<n;
i++)
231 STD__ cerr <<
"Error inverting Matrix A!" <<
STD__ endl;
255 STD__ cerr <<
"Error inverting Matrix A!" <<
STD__ endl;
321 double ew_min,
double ew_max)
349 dsbevx_(&jobz, &range, &uplo, &N,
352 &ew_min, &ew_max, &dummy, &dummy,
360 for(
int i=0;
i<m;
i++)
385 zgeev_(&jobvl, &jobvr, &N,
388 &N, vr, &N, work, &lwork, rwork, &info);
407 &N, (
doublecomplex*) EV.get_fortran_matrix(), &N, work, &lwork, rwork, &info);
420 double EW_min,
double EW_max,
428 long ldab=A.numSuper()+1;
429 long ldbb=B.numSuper()+1;
431 long Anzahl_Eigenwerte;
450 for (j=i; j<i+ldab && j<n; j++)
460 for (j=i; j<i+ldbb && j<n; j++)
473 double* ew =
new double[n];
474 long *iwork =
new long[5*n];
475 double *rwork =
new double[7*n];
481 long info=
own_ew_(&BerechneEV, &uplo, &n, &Anzahl_Eigenwerte, ab, &ldab, bb, &ldbb,
482 &EW_min, &EW_max, ew, q, &n, work, rwork, iwork);
485 STD__ cerr <<
" Error calculating eigenvalues: (status " << info <<
")" <<
STD__ endl;
491 if (BerechneEV==1 && Anzahl_Eigenwerte>0)
495 long *ifail =
new long[Anzahl_Eigenwerte];
497 for (i=0;i<n*Anzahl_Eigenwerte;i++)
502 info=
own_ev_(&n, &Anzahl_Eigenwerte, ew, EV, &n, q, &n, work, rwork, iwork, ifail);
505 STD__ cerr <<
" Error calculating eigenvectors" <<
STD__ endl;
510 Eigenvectoren.resize(n,Anzahl_Eigenwerte);
511 for (j=0;j<Anzahl_Eigenwerte;j++)
513 for (
int i=0; i<n; i++)
515 Eigenvectoren(i,j).set(EV[i+n*j].r, EV[i+n*j].i);
523 Eigenwerte.
resize(Anzahl_Eigenwerte);
524 for(i=0; i<Anzahl_Eigenwerte; i++) Eigenwerte(i) = ew[
i];
547 double *rwork =
new double[3*n-2];
556 STD__ cerr <<
" Error calculating eigenvalues: (status " << info <<
")" <<
STD__ endl;
575 double *rwork =
new double[3*n-2];
583 STD__ cerr <<
" Error calculating eigenvalues: (status " << info <<
")" <<
STD__ endl;
int zgeev_(const char *jobvl, const char *jobvr, int *n, __complex__ double *a, int *lda, __complex__ double *w, __complex__ double *vl, int *ldvl, __complex__ double *vr, int *ldvr, __complex__ double *work, int *lwork, double *rwork, int *info)
const Vector< T > const Vector< T > & x
int dsbevx_(const char *jobz, const char *range, const char *uplo, int *n, int *kd, double *ab, int *ldab, double *q, int *ldq, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, double *work, int *iwork, int *ifail, int *info)
double dlamch_(const char *)
provides basic Vector functionality but arithmetic operators (+=, - , *, /...).
TVector< T > get_col(const unsigned int) const
long int own_ew_(long int *job, long int *up, long int *n, long int *m, __complex__ double *ab, long int *ldab, __complex__ double *bb, long int *ldbb, double *vl, double *vu, double *w, __complex__ double *q, long int *ldq, __complex__ double *work, double *rwork, long int *iwork)
– AHLAND driver routine (version 2.0) – Modified LAPACK-ROUTINE for the calculation of selected Eigen...
unsigned int ldab() const
unsigned int columns() const
long double fact(const double x)
F_TMatrix< double > inv(const F_Matrix< double > &A, int overwriteA=0)
F_TMatrix< double > lu_solve(const F_Matrix< double > &A, const F_Matrix< double > &B, int overwriteA=0)
F_Matrix< T > & resize(const unsigned r, const unsigned c)
int dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info)
T * get_fortran_matrix() const
long int own_ev_(long int *n, long int *m, double *w, __complex__ double *z, long int *ldz, __complex__ double *q, long int *ldq, __complex__ double *work, double *rwork, long int *iwork, long int *ifail)
– AHLAND driver routine (version 2.0) –
int dsbev_(const char *jobz, const char *uplo, int *n, int *kd, double *ab, int *ldab, double *w, double *z, int *ldz, double *work, int *info)
T * get_fortran_matrix() const
void setval(const T val, const unsigned int r, const unsigned int c)
TVector< double > lu_solve_expert(const F_BandMatrix< double > &A, const Vector< double > &B, int equilibrate=1)
Solution of linear eqution systems, partial pivoting.
unsigned int numSub() const
For specializations of the memory allocator:
int dgbsvx_(const char *fact, const char *trans, int *n, int *kl, int *ku, int *nrhs, double *ab, int *ldab, double *afb, int *ldafb, int *ipiv, char *equed, double *r, double *c, double *b, int *ldb, double *x, int *ldx, double *rcond, double *ferr, double *berr, double *work, int *iwork, int *info)
unsigned int numSuper() const
int integer
barf [ba:rf] 2.
unsigned long size() const
int dsyev_(const char *jobz, const char *uplo, int *n, double *a, int *lda, double *w, double *work, int *lwork, int *info)
T *const & get_fortran_vector() const
C++ class for banded matrices using band storage in a one-dimensional array.
int zheev_(const char *jobz, const char *uplo, int *n, __complex__ double *a, int *lda, double *w, __complex__ double *work, int *lwork, double *rwork, int *info)
Temporary Base Class (non referable!) (acc.
BVector< T > & resize(const BVector< T > &)
Actually it's a resize and copy (some people would expect the assignment op to do this) ...
int zgesv_(int *n, int *nrhs, __complex__ double *a, int *lda, int *ipiv, __complex__ double *b, int *ldb, int *info)
#define TBCIDELETE(t, v, sz)
Temporary Base Class Idiom: Class TVector is used for temporary variables.
void set_col(const Vector< T > &, const unsigned int)
const Vector< T > Vector< T > Vector< T > Vector< T > & y
unsigned int columns() const
T *const & get_fortran_matrix() const
int dgbsv_(int *n, int *kl, int *ku, int *nrhs, double *ab, int *ldab, int *ipiv, double *b, int *ldb, int *info)
int eig(const F_Matrix< double > &A, Vector< double > &EW)
eigenvalues (and eigenvectors) A*EV=EW*EV of symmetric double Matrix A