20 #include "Lanczos_EigenVector.h"    21 #include "wrapperMPI.h"    51   long int i,j,i_max,iv;
    53   double beta1,alpha1,dnorm, dnorm_inv;
    54   double complex temp1,temp2,cdnorm;
    58   long unsigned int u_long_i, sum_i_max, i_max_tmp;
    61   k_exct = 
X->Def.k_exct;
    64   i_max=
X->Check.idim_max;
    69     X->Large.iv = (sum_i_max / 2 + 
X->Def.initial_iv) % sum_i_max + 1;
    71 #pragma omp parallel for default(none) private(i) shared(v0, v1,vg) firstprivate(i_max)    72     for(i = 1; i <= i_max; i++){
    79     for (iproc = 0; iproc < 
nproc; iproc++) {
    82       if (sum_i_max <= iv && iv < sum_i_max + i_max_tmp) {
    85           v1[iv - sum_i_max+1] = 1.0;
    86           if (
X->Def.iInitialVecType == 0) {
    87             v1[iv - sum_i_max+1] += 1.0*I;
    88             v1[iv - sum_i_max+1] /= sqrt(2.0);
    90           vg[iv - sum_i_max+1]=conj(
vec[k_exct][1])*
v1[iv - sum_i_max+1];
    95       sum_i_max += i_max_tmp;
   101     iv = 
X->Def.initial_iv;
   103     #pragma omp parallel default(none) private(i, u_long_i, mythread, dsfmt) \   104             shared(v0, v1, iv, X, nthreads, myrank) firstprivate(i_max)   108       for (i = 1; i <= i_max; i++) {
   115       mythread = omp_get_thread_num();
   120       dsfmt_init_gen_rand(&dsfmt, u_long_i);
   122       if (
X->Def.iInitialVecType == 0) {
   124         for (i = 1; i <= i_max; i++)
   125           v1[i] = 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5) + 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5)*I;
   129         for (i = 1; i <= i_max; i++)
   130           v1[i] = 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5);
   137 #pragma omp parallel for default(none) private(i) shared(v1, i_max) reduction(+: cdnorm)    138     for(i=1;i<=i_max;i++){
   139      cdnorm += conj(
v1[i])*
v1[i];
   144 #pragma omp parallel for default(none) private(i) shared(v1, vec, vg) firstprivate(i_max, dnorm, k_exct)   145     for(i=1;i<=i_max;i++){
   147       vg[i] = 
v1[i]*conj(
vec[k_exct][1]);
   157 #pragma omp parallel for default(none) private(j) shared(vec, v0, v1, vg) firstprivate(alpha1, beta1, i_max, k_exct)   158   for(j=1;j<=i_max;j++){
   159     vg[j]+=conj(
vec[k_exct][2])*(
v0[j]-alpha1*
v1[j])/beta1;
   163   for(i=2;i<=
X->Large.itr-1;i++) {
   169 #pragma omp parallel for default(none) private(j, temp1, temp2) shared(v0, v1) firstprivate(i_max, alpha1, beta1)   170     for (j = 1; j <= i_max; j++) {
   172       temp2 = (
v0[j] - alpha1 * 
v1[j]) / beta1;
   173       v0[j] = -beta1 * temp1;
   181 #pragma omp parallel for default(none) private(j) shared(vec, v0, v1, vg) firstprivate(alpha1, beta1, i_max, k_exct, i)   182     for (j = 1; j <= i_max; j++) {
   183       vg[j] += conj(
vec[k_exct][i + 1]) * (
v0[j] - alpha1 * 
v1[j]) / beta1;
   187 #pragma omp parallel for default(none) private(j) shared(v0, vg) firstprivate(i_max)   188     for(j=1;j<=i_max;j++){
   194 #pragma omp parallel for default(none) reduction(+:dnorm) private(j) shared(v0) firstprivate(i_max)   195   for(j=1;j<=i_max;j++){
   196     dnorm += conj(
v0[j])*
v0[j];
   201 #pragma omp parallel for default(none) private(j) shared(v0) firstprivate(i_max, dnorm_inv)   202   for(j=1;j<=i_max;j++){
   203     v0[j] = 
v0[j]*dnorm_inv;
 int mltply(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Parent function of multiplying the wavefunction by the Hamiltonian. . First, the calculation of diago...
void StartTimer(int n)
function for initializing elapse time [start] 
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes. 
unsigned long int BcastMPI_li(int root, unsigned long int idim)
MPI wrapper function to broadcast unsigned long integer across processes. 
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer] 
double SumMPI_d(double norm)
MPI wrapper function to obtain sum of Double across processes. 
int nthreads
Number of Threads, defined in InitializeMPI() 
const char * cLogLanczos_EigenVectorStart
int nproc
Number of processors, defined in InitializeMPI() 
const char * cLanczos_EigenVectorFinish
void Lanczos_EigenVector(struct BindStruct *X)
Calculate eigenvectors by the Lanczos method.  The calculated tridiagonal matrix components  are stor...
const char * cLanczos_EigenVectorStart
const char * cFileNameTimeKeep
int myrank
Process ID, defined in InitializeMPI() 
unsigned long int SumMPI_li(unsigned long int idim)
MPI wrapper function to obtain sum of unsigned long integer across processes. 
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log. 
const char * cLogLanczos_EigenVectorEnd
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()