File: lapack_dstegr2.c

package info (click to toggle)
openmx 3.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 325,856 kB
  • ctags: 3,575
  • sloc: ansic: 152,655; f90: 2,080; python: 876; makefile: 675; sh: 25; perl: 18
file content (90 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**********************************************************************
    lapack_dstegr2.c:

    lapack_dstegr2.c is a subroutine to find eigenvalues and eigenvectors
    of tridiagonlized real matrix using lapack's routines dstegr.

    Log of lapack_dstegr2.c:

       Dec/24/2004  Released by T.Ozaki

***********************************************************************/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "openmx_common.h"
#include "lapack_prototypes.h"
#include "mpi.h"


void lapack_dstegr2(INTEGER N, INTEGER EVmax, double *D, double *E, double *W, dcomplex **ev)
{
  int i,j;

  char  *JOBZ="V";
  char  *RANGE="A";
    
  double VL,VU; /* dummy */
  INTEGER IL,IU; 
  double ABSTOL_GR=1.0e-13;
  INTEGER M;
  double *Z;
  INTEGER LDZ;
  INTEGER *ISUPPZ;
  INTEGER LWORK;
  double *WORK;
  INTEGER *IWORK;
  INTEGER LIWORK;
  INTEGER INFO;

  IL = 1;
  IU = N;

  M = IU - IL + 1;
  LDZ = N;

  Z = (double*)malloc(sizeof(double)*LDZ*N);
  ISUPPZ = (INTEGER*)malloc(sizeof(INTEGER)*2*M);

  LWORK = 18*N;
  LIWORK = 10*N;
  WORK = (double*)malloc(sizeof(double)*LWORK);
  IWORK = (INTEGER*)malloc(sizeof(INTEGER)*LIWORK);

  F77_NAME(dstegr,DSTEGR)( JOBZ, RANGE, &N,  D, E, &VL, &VU, &IL, &IU, &ABSTOL_GR,
           &M, W, Z, &LDZ, ISUPPZ, WORK, &LWORK, IWORK, &LIWORK, &INFO );

  /* store eigenvectors */

  for (i=0; i<N; i++) {
    for (j=0; j<N; j++) {
      ev[i+1][j+1].r = Z[i*N+j];
      ev[i+1][j+1].i = 0.0;
    }
  }

  /* shift ko by 1 */

  for (i=N; i>=1; i--){
    W[i]= W[i-1];
  }

  if (INFO>0) {
    /*
    printf("\n error in dstegr_, info=%d\n\n",INFO);
    */
  }
  if (INFO<0) {
    printf("info=%d in dstegr_\n",INFO);
    MPI_Finalize();
    exit(0);
  }


  free(Z);
  free(ISUPPZ);
  free(WORK);
  free(IWORK);

}