Skip to content

Commit 06df0ee

Browse files
authored
Add genelpa warning if matrix is not positive definite (#6022)
* Remove my_math.hpp * Add warning quit for failed decomposeRightMatrix in genelpa * Remove blas.h in genelpa
1 parent 0c9b227 commit 06df0ee

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

source/module_hsolver/genelpa/blas.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

source/module_hsolver/genelpa/elpa_new_complex.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "module_base/scalapack_connector.h"
1313
#include "utils.h"
1414

15+
#include "module_base/tool_quit.h"
16+
17+
1518
extern std::map<int, elpa_t> NEW_ELPA_HANDLE_POOL;
1619

1720
int ELPA_Solver::eigenvector(std::complex<double>* A, double* EigenValue, std::complex<double>* EigenVector)
@@ -55,8 +58,12 @@ int ELPA_Solver::generalized_eigenvector(std::complex<double>* A, std::complex<d
5558
{
5659
timer(myid, "decomposeRightMatrix", "1", t);
5760
}
58-
if(allinfo != 0)
59-
return allinfo;
61+
if(allinfo != 0){
62+
// if allinfo is still not 0 anyway, report error and quit
63+
if(myid == 0){
64+
ModuleBase::WARNING_QUIT("ELPA_Solver::generalized_eigenvector", "decomposeRightMatrix failed to decompose right matrix!\n info = " + std::to_string(allinfo));
65+
}
66+
}
6067

6168
// transform A to A~
6269
if((loglevel>0 && myid==0) || loglevel>1)
@@ -296,6 +303,14 @@ int ELPA_Solver::decomposeRightMatrix(std::complex<double>* B, double* EigenValu
296303
timer(myid, "qevq=qev*q^T", "2", t);
297304
}
298305
}
306+
// if allinfo is still not 0 anyway, report error and quit
307+
if(allinfo != 0)
308+
{
309+
if(myid == 0){
310+
ModuleBase::WARNING_QUIT("decomposeRightMatrix",
311+
"Failed to decompose right matrix!\n info = " + std::to_string(allinfo));
312+
}
313+
}
299314
return allinfo;
300315
}
301316

source/module_hsolver/genelpa/elpa_new_real.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "elpa_new.h"
22
#include "elpa_solver.h"
3-
//#include "my_math.hpp"
3+
44
#include "module_base/scalapack_connector.h"
55
#include "utils.h"
66

7+
#include "module_base/tool_quit.h"
8+
79
#include <cfloat>
810
#include <complex>
911
#include <cstring>
@@ -54,8 +56,12 @@ int ELPA_Solver::generalized_eigenvector(double* A,
5456
{
5557
timer(myid, "decomposeRightMatrix", "1", t);
5658
}
57-
if (allinfo != 0)
58-
return allinfo;
59+
if (allinfo != 0){
60+
// if allinfo is still not 0 anyway, report error and quit
61+
if(myid == 0){
62+
ModuleBase::WARNING_QUIT("ELPA_Solver::generalized_eigenvector", "decomposeRightMatrix failed to decompose right matrix!\n info = " + std::to_string(allinfo));
63+
}
64+
}
5965

6066
// transform A to A~
6167
if ((loglevel > 0 && myid == 0) || loglevel > 1)
@@ -313,6 +319,15 @@ int ELPA_Solver::decomposeRightMatrix(double* B, double* EigenValue, double* Eig
313319
timer(myid, "qevq=qev*q^T", "2", t);
314320
}
315321
}
322+
323+
// if allinfo is still not 0 anyway, report error and quit
324+
if(allinfo != 0)
325+
{
326+
if(myid == 0){
327+
ModuleBase::WARNING_QUIT("decomposeRightMatrix",
328+
"Failed to decompose right matrix!\n info = " + std::to_string(allinfo));
329+
}
330+
}
316331
return allinfo;
317332
}
318333

0 commit comments

Comments
 (0)