1 /**********************************************************************
2 lapack_dstegr1.c:
3
4 lapack_dstegr1.c is a subroutine to find eigenvalues and eigenvectors
5 of tridiagonlized real matrix using lapack's routine, dstegr.
6
7 Log of lapack_dstevx1.c:
8
9 Dec/24/2004 Released by T.Ozaki
10
11 ***********************************************************************/
12
13 #include <stdio.h>
14 #include <math.h>
15 #include <stdlib.h>
16 #include "openmx_common.h"
17 #include "lapack_prototypes.h"
18 #include "mpi.h"
19
20
lapack_dsteqr1(INTEGER N,double * D,double * E,double * W,double ** ev)21 void lapack_dsteqr1(INTEGER N, double *D, double *E, double *W, double **ev)
22 {
23 int i,j;
24 char *COMPZ="I";
25 double *Z;
26 INTEGER LDZ;
27 double *WORK;
28 INTEGER INFO;
29
30 LDZ = N;
31 Z = (double*)malloc(sizeof(double)*LDZ*N);
32 WORK = (double*)malloc(sizeof(double)*2*N);
33
34 F77_NAME(dsteqr,DSTEQR)( COMPZ, &N, D, E, Z, &LDZ, WORK, &INFO );
35
36 /* store eigenvectors */
37
38 for (i=0; i<N; i++) {
39 for (j=0; j<N; j++) {
40 ev[i+1][j+1]= Z[i*N+j];
41 }
42 }
43
44 /* shift ko by 1 */
45 for (i=N; i>=1; i--){
46 W[i]= D[i-1];
47 }
48
49 if (INFO>0) {
50 printf("\n error in dstevx_, info=%d\n\n",INFO);fflush(stdout);
51 }
52 if (INFO<0) {
53 printf("info=%d in dstevx_\n",INFO);fflush(stdout);
54 MPI_Finalize();
55 exit(0);
56 }
57
58 free(Z);
59 free(WORK);
60 }
61