Skip to content

Commit

Permalink
rotation: threshold for zero set to 10*MachineZero
Browse files Browse the repository at this point in the history
  • Loading branch information
gitpeterwind authored and ilfreddy committed Feb 15, 2024
1 parent cbbd7a5 commit 7201333
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utils/ComplexFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ void rotate(MPI_FuncVector &Phi, const ComplexMatrix &U, MPI_FuncVector &Psi, do
bool UhasImag = false;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (std::abs(U(i, j).real()) > MachineZero) UhasReal = true;
if (std::abs(U(i, j).imag()) > MachineZero) UhasImag = true;
if (std::abs(U(i, j).real()) > 10*MachineZero) UhasReal = true;
if (std::abs(U(i, j).imag()) > 10*MachineZero) UhasImag = true;
}
}

Expand Down Expand Up @@ -804,19 +804,19 @@ void rotate(MPI_FuncVector &Phi, const ComplexMatrix &U, MPI_FuncVector &Psi, do
}

// 4) rotate all the nodes
IntMatrix split_serial; // in the serial case all split are store in one array
std::vector<std::vector<double *>> coeffpVec(Neff); // to put pointers to the rotated coefficient for each orbital in serial case
std::vector<std::map<int, int>> ix2coef(Neff); // to find the index in for example rotCoeffVec[] corresponding to a serialIx
IntMatrix split_serial; // in the serial case all split are stored in one array
std::vector<std::vector<double *>> coeffpVec(Meff); // to put pointers to the rotated coefficient for each orbital in serial case
std::vector<std::map<int, int>> ix2coef(Meff); // to find the index in for example rotCoeffVec[] corresponding to a serialIx
int csize; // size of the current coefficients (different for roots and branches)
std::vector<DoubleMatrix> rotatedCoeffVec; // just to ensure that the data from rotatedCoeff is not deleted, since we point to it.
// j indices are for unrotated orbitals, i indices are for rotated orbitals
if (serial) {
std::map<int, int> ix2coef_ref; // to find the index n corresponding to a serialIx
split_serial.resize(Neff, max_n); // not use in the MPI case
split_serial.resize(Meff, max_n); // not use in the MPI case
for (int n = 0; n < max_n; n++) {
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
ix2coef_ref[node_ix] = n;
for (int i = 0; i < Neff; i++) split_serial(i, n) = 1;
for (int i = 0; i < Meff; i++) split_serial(i, n) = 1;
}

std::vector<int> nodeReady(max_n, 0); // To indicate to OMP threads that the parent is ready (for splits)
Expand Down Expand Up @@ -987,6 +987,7 @@ void rotate(MPI_FuncVector &Phi, const ComplexMatrix &U, MPI_FuncVector &Psi, do

#pragma omp parallel for schedule(static)
for (int j = 0; j < Meff; j++) {
if (coeffpVec[j].size()==0) continue;
if (j < M) {
if (!Psi[j].hasReal()) Psi[j].alloc(NUMBER::Real);
Psi[j].real().clear();
Expand Down

0 comments on commit 7201333

Please sign in to comment.