Skip to content

Commit

Permalink
Allocate memory in ERIscreen if none was given
Browse files Browse the repository at this point in the history
  • Loading branch information
susilehtola committed Jan 21, 2024
1 parent c6b3cab commit cb5bb90
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/eriscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ void ERIscreen::calcJK(const arma::mat & P, arma::mat & J, arma::mat & K, double
oss << "Error in ERIscreen: Nbf = " << Nbf << ", P.n_rows = " << P.n_rows << ", P.n_cols = " << P.n_cols << "!\n";
throw std::logic_error(oss.str());
}
if(J.n_rows != Nbf || J.n_cols != Nbf) {
J.zeros(Nbf,Nbf);
}
if(K.n_rows != Nbf || K.n_cols != Nbf) {
K.zeros(Nbf,Nbf);
}

#ifdef _OPENMP
int nth=omp_get_max_threads();
Expand Down Expand Up @@ -515,6 +521,13 @@ void ERIscreen::calcJK(const arma::cx_mat & P, arma::mat & J, arma::cx_mat & K,
oss << "Error in ERIscreen: Nbf = " << Nbf << ", P.n_rows = " << P.n_rows << ", P.n_cols = " << P.n_cols << "!\n";
throw std::logic_error(oss.str());
}
if(J.n_rows != Nbf || J.n_cols != Nbf) {
J.zeros(Nbf,Nbf);
}
if(K.n_rows != Nbf || K.n_cols != Nbf) {
K.zeros(Nbf,Nbf);
}


#ifdef _OPENMP
int nth=omp_get_max_threads();
Expand Down Expand Up @@ -561,6 +574,16 @@ void ERIscreen::calcJK(const arma::mat & Pa, const arma::mat & Pb, arma::mat & J
oss << "Error in ERIscreen: Nbf = " << Nbf << ", Pb.n_rows = " << Pb.n_rows << ", Pb.n_cols = " << Pb.n_cols << "!\n";
throw std::logic_error(oss.str());
}
if(J.n_rows != Nbf || J.n_cols != Nbf) {
J.zeros(Nbf,Nbf);
}
if(Ka.n_rows != Nbf || Ka.n_cols != Nbf) {
Ka.zeros(Nbf,Nbf);
}
if(Kb.n_rows != Nbf || Kb.n_cols != Nbf) {
Kb.zeros(Nbf,Nbf);
}


#ifdef _OPENMP
int nth=omp_get_max_threads();
Expand Down Expand Up @@ -610,6 +633,15 @@ void ERIscreen::calcJK(const arma::cx_mat & Pa, const arma::cx_mat & Pb, arma::m
oss << "Error in ERIscreen: Nbf = " << Nbf << ", Pb.n_rows = " << Pb.n_rows << ", Pb.n_cols = " << Pb.n_cols << "!\n";
throw std::logic_error(oss.str());
}
if(J.n_rows != Nbf || J.n_cols != Nbf) {
J.zeros(Nbf,Nbf);
}
if(Ka.n_rows != Nbf || Ka.n_cols != Nbf) {
Ka.zeros(Nbf,Nbf);
}
if(Kb.n_rows != Nbf || Kb.n_cols != Nbf) {
Kb.zeros(Nbf,Nbf);
}

#ifdef _OPENMP
int nth=omp_get_max_threads();
Expand Down

0 comments on commit cb5bb90

Please sign in to comment.