From 987f779d9a9e6878c99d6c4a00bd24ddc06af767 Mon Sep 17 00:00:00 2001 From: "Martin D. Weinberg" Date: Mon, 25 Sep 2023 13:20:15 -0400 Subject: [PATCH 1/3] Code to enforce sign convention on SL eigenfunctions and EOF eigenvectors --- exputil/EmpCylSL.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++ exputil/SLGridMP2.cc | 23 ++++++++++++++--- exputil/libvars.cc | 4 +++ include/SLGridMP2.H | 3 +++ include/libvars.H | 3 +++ 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/exputil/EmpCylSL.cc b/exputil/EmpCylSL.cc index 79f6970ad..2e0c9514b 100644 --- a/exputil/EmpCylSL.cc +++ b/exputil/EmpCylSL.cc @@ -3336,6 +3336,20 @@ void EmpCylSL::eigen_problem(int request_id, int M, Timer& timer) efE = esE.eigenvectors().real(); efO = esO.eigenvectors().real(); + // Choose sign conventions for the ef table + // + int nfid = std::min(4, efE.rows()) - 1; + + // Even case + for (int j=0; j(4, efE.rows()) - 1; + for (int j=0; j(4, efE.rows()) - 1; + + // Even case + // + for (int j=0; j(4, efE.rows()) - 1; + for (int j=0; jevalJK = es.eigenvalues().real(); (*pb)[mm]->evecJK = es.eigenvectors().real(); + + // Sign convention + // + int nfid = std::min(4, efE.rows()) - 1; + for (int j=0; j<(*pb)[mm]->evecJK.cols(); j++) { + if ((*pb)[mm]->evecJK(nfid, j) < 0.0) (*pb)[mm]->evecJK.col(j) *= -1; + } + } // Transformation output @@ -4479,6 +4532,14 @@ void EmpCylSL::pca_hall(bool compute, bool subsamp) evalVar = es.eigenvalues().real(); evecVar = es.eigenvectors().real(); + // Sign convention for eigenvectors + // + int nfid = std::min(4, evecVar.rows()) - 1; + for (int j=0; jef.resize(N, numr); + // Choose sign conventions for the ef table + // + int nfid = std::min(nevsign, N) - 1; + Eigen::VectorXi sgn = Eigen::VectorXi::Ones(N); + for (int j=0; jef(j, i) = ef[j*NUM+i]; + table->ef(j, i) = ef[j*NUM+i] * sgn(j); } table->l = l; @@ -2862,15 +2870,24 @@ void SLGridSph::compute_table_worker(void) } } } - // Load table + // Load table + // table.ev.resize(N); for (int i=0; i(nevsign, N) - 1; + Eigen::VectorXi sgn = Eigen::VectorXi::Ones(N); + for (int j=0; j #include +#include +using namespace __EXP__; + #if HAVE_LIBCUDA==1 #include #include diff --git a/include/libvars.H b/include/libvars.H index 3440e8324..ee9e4f2f3 100644 --- a/include/libvars.H +++ b/include/libvars.H @@ -36,6 +36,9 @@ namespace __EXP__ //! Control flag for source/line debug info extern bool sourceline; + //! Sign convention element rank for eigenfunctions and eigenvectors + extern int nevsign; + }; #endif // END _LIBVARS_H From 24c14dcbd7b98a94b0556288b50ac385bbc8525f Mon Sep 17 00:00:00 2001 From: mdw Date: Tue, 26 Sep 2023 09:15:43 -0400 Subject: [PATCH 2/3] Use new Slurm API calls 'slurm_init/fini' only for Slurm version 21.11 and above --- src/expand.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/expand.cc b/src/expand.cc index 6c506f94a..fb567af3c 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -636,12 +636,14 @@ main(int argc, char** argv) // Initialize slurm api //===================== #ifdef HAVE_LIBSLURM +#if SLURM_VERSION_NUMBER > SLURM_VERSION_NUM(21,10,0) { int rc = slurm_init(0); if (rc != SLURM_SUCCESS) std::cerr << "EXP [" << myid << "]: error initializing Slurm API: " << slurm_strerror(rc) << std::endl; } +#endif #endif //============================================== @@ -795,7 +797,9 @@ main(int argc, char** argv) //====================== #ifdef HAVE_LIBSLURM +#if SLURM_VERSION_NUMBER > SLURM_VERSION_NUM(21,10,0) slurm_fini(); +#endif #endif //================= From 83a4ed2f144134ea6f1028e1ea67d8545b3e1d3c Mon Sep 17 00:00:00 2001 From: mdw Date: Tue, 26 Sep 2023 11:44:14 -0400 Subject: [PATCH 3/3] Remove return code checking, following the Slurm API --- src/expand.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index fb567af3c..393426e8d 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -637,12 +637,7 @@ main(int argc, char** argv) //===================== #ifdef HAVE_LIBSLURM #if SLURM_VERSION_NUMBER > SLURM_VERSION_NUM(21,10,0) - { - int rc = slurm_init(0); - if (rc != SLURM_SUCCESS) - std::cerr << "EXP [" << myid << "]: error initializing Slurm API: " - << slurm_strerror(rc) << std::endl; - } + slurm_init(0); #endif #endif