mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-15 02:05:37 +00:00
changed allocation for LAPACK temporaries, to avoid crashing with some compilers (reported by Christoph)
This commit is contained in:
parent
05d04ceff8
commit
927c7ae3ed
@ -281,12 +281,14 @@ public:
|
|||||||
// tevals.resize(size);
|
// tevals.resize(size);
|
||||||
// tevecs.resize(size);
|
// tevecs.resize(size);
|
||||||
LAPACK_INT NN = N1;
|
LAPACK_INT NN = N1;
|
||||||
double evals_tmp[NN];
|
// double evals_tmp[NN];
|
||||||
double evec_tmp[NN][NN];
|
// double evec_tmp[NN][NN];
|
||||||
memset(evec_tmp[0],0,sizeof(double)*NN*NN);
|
std::vector<double> evals_tmp(NN);
|
||||||
// double AA[NN][NN];
|
std::vector<double> evec_tmp(NN*NN);
|
||||||
double DD[NN];
|
memset(evec_tmp.data(),0,sizeof(double)*NN*NN);
|
||||||
double EE[NN];
|
|
||||||
|
std::vector<double> DD(NN);
|
||||||
|
std::vector<double> EE(NN);
|
||||||
for (int i = 0; i< NN; i++)
|
for (int i = 0; i< NN; i++)
|
||||||
for (int j = i - 1; j <= i + 1; j++)
|
for (int j = i - 1; j <= i + 1; j++)
|
||||||
if ( j < NN && j >= 0 ) {
|
if ( j < NN && j >= 0 ) {
|
||||||
@ -318,7 +320,7 @@ public:
|
|||||||
if (iu > NN) iu=NN;
|
if (iu > NN) iu=NN;
|
||||||
double tol = 0.0;
|
double tol = 0.0;
|
||||||
if (1) {
|
if (1) {
|
||||||
memset(evals_tmp,0,sizeof(double)*NN);
|
memset(evals_tmp.data(),0,sizeof(double)*NN);
|
||||||
if ( il <= NN){
|
if ( il <= NN){
|
||||||
printf("total=%d node=%d il=%d iu=%d\n",total,node,il,iu);
|
printf("total=%d node=%d il=%d iu=%d\n",total,node,il,iu);
|
||||||
#ifdef USE_MKL
|
#ifdef USE_MKL
|
||||||
@ -326,10 +328,10 @@ public:
|
|||||||
#else
|
#else
|
||||||
LAPACK_dstegr(&jobz, &range, &NN,
|
LAPACK_dstegr(&jobz, &range, &NN,
|
||||||
#endif
|
#endif
|
||||||
(double*)DD, (double*)EE,
|
DD.data(), EE.data(),
|
||||||
&vl, &vu, &il, &iu, // these four are ignored if second parameteris 'A'
|
&vl, &vu, &il, &iu, // these four are ignored if second parameteris 'A'
|
||||||
&tol, // tolerance
|
&tol, // tolerance
|
||||||
&evals_found, evals_tmp, (double*)evec_tmp, &NN,
|
&evals_found, evals_tmp.data(), evec_tmp.data(), &NN,
|
||||||
isuppz,
|
isuppz,
|
||||||
work, &lwork, iwork, &liwork,
|
work, &lwork, iwork, &liwork,
|
||||||
&info);
|
&info);
|
||||||
@ -338,22 +340,20 @@ public:
|
|||||||
evals_tmp[i] = evals_tmp[i - (il-1)];
|
evals_tmp[i] = evals_tmp[i - (il-1)];
|
||||||
if (il>1) evals_tmp[i-(il-1)]=0.;
|
if (il>1) evals_tmp[i-(il-1)]=0.;
|
||||||
for (int j = 0; j< NN; j++){
|
for (int j = 0; j< NN; j++){
|
||||||
evec_tmp[i][j] = evec_tmp[i - (il-1)][j];
|
evec_tmp[i*NN+j] = evec_tmp[(i - (il-1))*NN+j];
|
||||||
if (il>1) evec_tmp[i-(il-1)][j]=0.;
|
if (il>1) evec_tmp[(i-(il-1))*NN+j]=0.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// QMP_sum_double_array(evals_tmp,NN);
|
grid->GlobalSumVector(evals_tmp.data(),NN);
|
||||||
// QMP_sum_double_array((double *)evec_tmp,NN*NN);
|
grid->GlobalSumVector(evec_tmp.data(),NN*NN);
|
||||||
grid->GlobalSumVector(evals_tmp,NN);
|
|
||||||
grid->GlobalSumVector((double*)evec_tmp,NN*NN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cheating a bit. It is better to sort instead of just reversing it, but the document of the routine says evals are sorted in increasing order. qr gives evals in decreasing order.
|
// cheating a bit. It is better to sort instead of just reversing it, but the document of the routine says evals are sorted in increasing order. qr gives evals in decreasing order.
|
||||||
for(int i=0;i<NN;i++){
|
for(int i=0;i<NN;i++){
|
||||||
for(int j=0;j<NN;j++)
|
for(int j=0;j<NN;j++)
|
||||||
Qt[(NN-1-i)*N2+j]=evec_tmp[i][j];
|
Qt[(NN-1-i)*N2+j]=evec_tmp[i*NN+j];
|
||||||
lmd [NN-1-i]=evals_tmp[i];
|
lmd [NN-1-i]=evals_tmp[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user