File: lapack_dsteqr1.c

package info (click to toggle)
openmx 3.2.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 62,572 kB
  • ctags: 2,684
  • sloc: ansic: 130,666; python: 876; makefile: 560; xml: 63; perl: 18; sh: 4
file content (64 lines) | stat: -rw-r--r-- 1,322 bytes parent folder | download | duplicates (2)
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
/**********************************************************************
    lapack_dstegr1.c:

    lapack_dstegr1.c is a subroutine to find eigenvalues and eigenvectors
    of tridiagonlized real matrix using lapack's routine, dstegr.

    Log of lapack_dstevx1.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"

#ifdef nompi
#include "mimic_mpi.h"
#else
#include "mpi.h"
#endif

void lapack_dsteqr1(INTEGER N, double *D, double *E, double *W, double **ev)
{
  int i,j;
  char  *COMPZ="I";
  double *Z;
  INTEGER LDZ;
  double *WORK;
  INTEGER INFO;

  LDZ = N;
  Z = (double*)malloc(sizeof(double)*LDZ*N);
  WORK = (double*)malloc(sizeof(double)*2*N);

  F77_NAME(dsteqr,DSTEQR)( COMPZ, &N, D, E, Z, &LDZ, WORK, &INFO );

  /* store eigenvectors */

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

  /* shift ko by 1 */
  for (i=N; i>=1; i--){
    W[i]= D[i-1];
  }
  
  if (INFO>0) {
    printf("\n error in dstevx_, info=%d\n\n",INFO);fflush(stdout);
  }
  if (INFO<0) {
    printf("info=%d in dstevx_\n",INFO);fflush(stdout);
    MPI_Finalize();
    exit(0);
  }

  free(Z);
  free(WORK);
}