25 #include "matrixlapack.h" 38 int dgetrf_(
int *m,
int *n,
double *a,
int *lda,
int *ipiv,
int *info);
39 int dgetri_(
int *n,
double *a,
int *lda,
int *ipiv,
double *work,
int *lwork,
int *info);
42 int dsyevd_(
char *jobz,
char *uplo,
int *n,
double *a,
int *lda,
double *w,
double *work,
int *lwork,
int *iwork,
int *liwork,
int *info);
43 int M_DSYEV(
char *jobz,
char *uplo,
int *n,
double *a,
int *lda,
double *w,
double *work,
int *lwork,
int *iwork,
int *liwork,
int *info);
44 int zheevd_(
char *jobz,
char *uplo,
int *n,
double complex *a,
int *lda,
double *w,
double complex *work,
int *lwork,
double *rwork,
int *iwork,
int *liwork,
int *info);
46 int dsyev_(
char *jobz,
char *uplo,
int *n,
double *a,
int *lda,
double *w,
double *work,
int *lwork,
int *info);
47 int M_DSYEV(
char *jobz,
char *uplo,
int *n,
double *a,
int *lda,
double *w,
double *work,
int *lwork,
int *info);
49 int zheev_(
char *jobz,
char *uplo,
int *n,
double complex *a,
int *lda,
double *w,
double complex *work,
int *lwork,
double *rwork,
int *info);
52 int dsyevx_(
char *jobz,
char *range,
char *uplo,
int *n,
double *a,
int *lda,
double *vl,
double *vu,
53 int *il,
int *iu,
double *abstol,
int *m,
double *w,
double *z__,
int *ldz,
54 double *work,
int *lwork,
int *iwork,
int *ifail,
int *info);
97 int n, lda, lwork, info;
101 liwork = 5 * xNsize + 3;
102 iwork = (
int*)malloc(liwork *
sizeof(
double));
108 a = (
double*)malloc(xNsize*xNsize*
sizeof(
double));
109 w = (
double*)malloc(xNsize*
sizeof(
double));
110 work = (
double*)malloc(lwork*
sizeof(
double));
112 to_f(xNsize, xNsize, A, a);
118 M_DSYEV(&jobz, &uplo, &n, a, &lda, w, work, &lwork, &iwork, &liwork, &info);
121 M_DSYEV(&jobz, &uplo, &n, a, &lda, w, work, &lwork, &info);
131 for(k=0;k<xNsize;k++){
153 int DInv(
int xNsize,
double **xM,
double **xIM){
156 int m,n,lda,info,*piv,lwork;
160 m=n=lda=lwork=xNsize;
162 a = (
double*)malloc(xNsize*xNsize*
sizeof(
double));
163 work = (
double*)malloc(xNsize*
sizeof(
double));
164 piv = (
int*)malloc(xNsize*
sizeof(
int));
167 for(j=0;j<xNsize;j++){
168 for(i=0;i<xNsize;i++){
174 dgetrf_(&m, &n, a, &lda, piv, &info);
175 dgetri_(&n, a, &lda, piv, work, &lwork, &info);
184 for(k=0;k<xNsize*xNsize;k++){
185 xIM[k%xNsize][k/xNsize] = a[k];
213 int n, lda, lwork, info;
214 double *a, *w, *work;
217 liwork = 5 * xNsize + 3;
218 iwork = (
int*)malloc(liwork *
sizeof(
double));
219 lwork = 2 * xNsize * xNsize + 6 * xNsize + 1;
226 a = (
double*)malloc(xNsize*xNsize*
sizeof(
double));
227 w = (
double*)malloc(xNsize*
sizeof(
double));
228 work = (
double*)malloc(lwork*
sizeof(
double));
231 for(j=0;j<xNsize;j++){
232 for(i=0;i<xNsize;i++){
242 M_DSYEV(&jobz, &uplo, &n, a, &lda, w, work, &lwork, iwork, &liwork, &info);
245 dsyev_(&jobz, &uplo, &n, a, &lda, w, work, &lwork, &info);
249 for(i=0;i<xNsize;i++){
250 for(j=0;j<xNsize;j++){
263 for(k=0;k<xNsize;k++){
290 int DSEVXU(
int xNsize,
double **A,
double *r,
double **
X,
int xNev){
293 char jobz, range, uplo;
294 int n, lda, il, iu, m, ldz, lwork, *iwork, *ifail, info;
295 double *a, *w, *work, vl, vu, abstol, *z;
297 n = lda = ldz = xNsize;
300 a = (
double*)malloc(xNsize*xNsize*
sizeof(
double));
301 w = (
double*)malloc(xNsize*
sizeof(
double));
302 z = (
double*)malloc(xNsize*xNsize*
sizeof(
double));
303 work = (
double*)malloc(lwork*
sizeof(
double));
304 iwork = (
int*)malloc(5*xNsize*
sizeof(
int));
305 ifail = (
int*)malloc(xNsize*
sizeof(
int));
315 for(j=0;j<xNsize;j++){
316 for(i=0;i<xNsize;i++){
330 dsyevx_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol,
331 &m, w, z, &ldz, work, &lwork, iwork, ifail, &info);
344 r[k+xNsize-xNev] = w[k];
347 for(k=0;k<xNsize*xNev;k++){
348 X[k%xNsize][k/xNsize+xNsize-xNev] = z[k];
374 int ZHEEVall(
int xNsize,
double complex **A,
double complex *r,
double complex **
vec){
378 int n, lda, lwork, info, lrwork;
381 double complex *a, *work;
384 liwork = 5 * xNsize + 3;
385 iwork = (
int*)malloc(liwork *
sizeof(
double));
390 lwork = xNsize*xNsize + 2 * xNsize;
391 lrwork = 2 * xNsize*xNsize + 5*xNsize + 1;
397 a = (
double complex*)malloc(xNsize*xNsize*
sizeof(
double complex));
398 w = (
double*)malloc(xNsize*
sizeof(
double));
399 work = (
double complex*)malloc(lwork*
sizeof(
double complex));
400 rwork = (
double*)malloc(lrwork*
sizeof(
double));
403 for(j=0;j<xNsize;j++){
404 for(i=0;i<xNsize;i++){
414 int zheevd_(
char *jobz,
char *uplo,
int *n,
double complex *a,
int *lda,
double *w,
double complex *work,
int *lwork,
double *rwork,
int *iwork,
int *liwork,
int *info);
417 zheev_(&jobz, &uplo, &n, a, &lda, w, work, &lwork, rwork, &info);
429 for(i=0;i<xNsize;i++){
430 for(j=0;j<xNsize;j++){
437 for(k=0;k<xNsize;k++){
int dgetri_(int *n, double *a, int *lda, int *ipiv, double *work, int *lwork, int *info)
int M_DSYEV(char *jobz, char *uplo, int *n, double *a, int *lda, double *w, double *work, int *lwork, int *info)
int ZHEEVall(int xNsize, double complex **A, double complex *r, double complex **vec)
obtain eigenvalues and eigenvectors of Hermite matrix A
int DSEVvalue(int xNsize, double **A, double *r)
obtain eigenvalues of real symmetric A
double dlamch_(char *cmach)
void zheevd_(char *jobz, char *uplo, int *n, double complex *a, int *lda, double *w, double complex *work, int *lwork, double *rwork, int *lrwork, int *iwork, int *liwork, int *info)
int dsyevx_(char *jobz, char *range, char *uplo, int *n, double *a, int *lda, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z__, int *ldz, double *work, int *lwork, int *iwork, int *ifail, int *info)
int DSEVXU(int xNsize, double **A, double *r, double **X, int xNev)
obtain eigenvalues A
int DInv(int xNsize, double **xM, double **xIM)
obtain eigenvalues of inverse of real matrix xM
int zheev_(char *jobz, char *uplo, int *n, double complex *a, int *lda, double *w, double complex *work, int *lwork, double *rwork, int *info)
int DSEVvector(int xNsize, double **A, double *r, double **vec)
obtain eigenvalues and eigenvectors of real symmetric A
void to_f(int N, int M, double **A, double *a)
function for transforming Row-major matrix (C) to Column-major matrix (Fortran)
int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info)
int dsyev_(char *jobz, char *uplo, int *n, double *a, int *lda, double *w, double *work, int *lwork, int *info)