HΦ  3.2.0
vec12.c File Reference

Functions to Diagonalize a tri-diagonal matrix and store eigenvectors into vec. More...

#include "matrixlapack.h"
#include "Common.h"
#include "wrapperMPI.h"
#include "common/setmemory.h"
#include "xsetmem.h"
+ Include dependency graph for vec12.c:

Go to the source code of this file.

Functions

void vec12 (double alpha[], double beta[], unsigned int ndim, double tmp_E[], struct BindStruct *X)
 Diagonalize a tri-diagonal matrix and store eigenvectors into vec. More...
 

Detailed Description

Functions to Diagonalize a tri-diagonal matrix and store eigenvectors into vec.

Definition in file vec12.c.

Function Documentation

◆ vec12()

void vec12 ( double  alpha[],
double  beta[],
unsigned int  ndim,
double  tmp_E[],
struct BindStruct X 
)

Diagonalize a tri-diagonal matrix and store eigenvectors into vec.

Author
Takahiro Misawa (The University of Tokyo)
Youhei Yamaji (The University of Tokyo)

Definition at line 31 of file vec12.c.

References BindStruct::Def, DSEVvector(), DefineList::iCalcType, DefineList::iFlgCalcSpec, DefineList::LanczosTarget, DefineList::nvec, stdoutMPI, and vec.

Referenced by CalcSpectrumByTPQ(), and Lanczos_EigenValue().

37  {
38  unsigned int j,k,nvec;
39 
40  double **tmpA, **tmpvec;
41  double *tmpr;
42 
43  nvec = X->Def.nvec;
44  tmpA = d_2d_allocate(ndim, ndim);
45  tmpvec = d_2d_allocate(ndim, ndim);
46  tmpr = d_1d_allocate(ndim);
47 
48 #pragma omp parallel for default(none) firstprivate(ndim) private(j,k) shared(tmpA)
49  for(k=0;k<=ndim-1;k++)
50  for(j=0;j<=ndim-1;j++) tmpA[k][j]=0.0;
51 #pragma omp parallel for default(none) firstprivate(ndim, nvec) private(j,k) shared(vec)
52  for(k=1;k<=nvec;k++)
53  for(j=1;j<=ndim;j++) vec[k][j]=0.0;
54 
55 #pragma omp parallel for default(none) firstprivate(ndim, alpha, beta) private(j) shared(tmpA)
56  for(j=0;j<=ndim-2;j++){
57  tmpA[j][j]=alpha[j+1];
58  tmpA[j][j+1]=beta[j+1];
59  tmpA[j+1][j]=beta[j+1];
60  }/*for(j=0;j<=ndim-2;j++)*/
61  tmpA[ndim-1][ndim-1]=alpha[ndim];
62 
63  DSEVvector( ndim, tmpA, tmpr, tmpvec );
64  if(X->Def.iCalcType==Lanczos && X->Def.iFlgCalcSpec == 0)
65  fprintf(stdoutMPI, " Lanczos EigenValue in vec12 = %.10lf \n ",tmpr[0]);
66 
67  if (nvec <= ndim) {
68  if (nvec < X->Def.LanczosTarget) nvec = X->Def.LanczosTarget;
69 
70 #pragma omp parallel for default(none) firstprivate(ndim, nvec) private(j,k) shared(tmpvec, vec, tmp_E, tmpr)
71  for(k=1;k<=nvec;k++){
72  tmp_E[k]=tmpr[k-1];
73  for (j = 1; j <= ndim; j++) vec[k][j] = tmpvec[k - 1][j - 1];
74  }/*for(k=1;k<=nvec;k++)*/
75  }/*if(nvec<=ndim)*/
76  else{
77 #pragma omp parallel for default(none) firstprivate(ndim, nvec) private(j,k) shared(tmpvec, vec, tmp_E, tmpr)
78  for(k=1;k<=ndim;k++){
79  tmp_E[k]=tmpr[k-1];
80  for (j = 1; j <= ndim; j++) vec[k][j] = tmpvec[k - 1][j - 1];
81  }/*for(k=1;k<=ndim;k++)*/
82  }/*if(nvec>ndim)*/
83  free_d_2d_allocate(tmpA);
84  free_d_1d_allocate(tmpr);
85  free_d_2d_allocate(tmpvec);
86 }/*void vec12*/
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
double complex ** vec
Definition: global.h:45
unsigned int nvec
Read from Calcmod in readdef.h.
Definition: struct.h:46
double * alpha
Definition: global.h:44
int DSEVvector(int xNsize, double **A, double *r, double **vec)
obtain eigenvalues and eigenvectors of real symmetric A
Definition: matrixlapack.c:209
double * beta
Definition: global.h:44
int LanczosTarget
Which eigenstate is used to check convergence. Read from Calcmod in readdef.h.
Definition: struct.h:50
int iFlgCalcSpec
Input parameter CalcSpec in teh CalcMod file.
Definition: struct.h:216
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
Definition: struct.h:192
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.h:165
+ Here is the call graph for this function:
+ Here is the caller graph for this function: