From c18197d822f527616357d6c8df8cf97b3bd749c1 Mon Sep 17 00:00:00 2001 From: gitpeterwind Date: Wed, 19 Feb 2025 14:59:07 +0100 Subject: [PATCH 1/3] mpi reduce for no mpi --- src/utils/CompFunction.cpp | 1 + src/utils/parallel.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/CompFunction.cpp b/src/utils/CompFunction.cpp index a8ce7079..dac23a0a 100644 --- a/src/utils/CompFunction.cpp +++ b/src/utils/CompFunction.cpp @@ -2605,6 +2605,7 @@ DoubleMatrix calc_norm_overlap_matrix(CompFunctionVector &BraKet) { } } if (BraKet[j].hasImag()) { + NOT_IMPLEMENTED_ABORT; BraKet[j].imag().makeCoeffVector(coeffVec[j + N], indexVec, parindexVec, scalefac, max_ix, refTree); // make a map that gives j from indexVec int orb_node_ix = 0; diff --git a/src/utils/parallel.cpp b/src/utils/parallel.cpp index 332d0fb5..510e34a1 100644 --- a/src/utils/parallel.cpp +++ b/src/utils/parallel.cpp @@ -485,7 +485,6 @@ template void reduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tree, /** @brief make union tree without coeff and send to all */ template void allreduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tree, vector> &Phi, MPI_Comm comm) { -#ifdef MRCPP_HAS_MPI /* 1) make union grid of own orbitals 2) make union grid with others orbitals (sent to rank zero) 3) rank zero broadcast func to everybody @@ -496,6 +495,7 @@ template void allreduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tre if (not my_func(j)) continue; tree.appendTreeNoCoeff(Phi[j]); } +#ifdef MRCPP_HAS_MPI mrcpp::mpi::reduce_Tree_noCoeff(tree, comm_wrk); mrcpp::mpi::broadcast_Tree_noCoeff(tree, comm_wrk); #endif @@ -504,7 +504,6 @@ template void allreduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tre /** @brief make union tree without coeff and send to all */ template void allreduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tree, vector> &Phi, MPI_Comm comm) { -#ifdef MRCPP_HAS_MPI /* 1) make union grid of own orbitals 2) make union grid with others orbitals (sent to rank zero) 3) rank zero broadcast func to everybody @@ -516,6 +515,7 @@ template void allreduce_Tree_noCoeff(mrcpp::FunctionTree<3, T> &tre if (Phi[j].isreal()) tree.appendTreeNoCoeff(*Phi[j].CompD[0]); if (Phi[j].iscomplex()) tree.appendTreeNoCoeff(*Phi[j].CompC[0]); } +#ifdef MRCPP_HAS_MPI mrcpp::mpi::reduce_Tree_noCoeff(tree, comm_wrk); mrcpp::mpi::broadcast_Tree_noCoeff(tree, comm_wrk); #endif From 8e1f167b8f5c42513bffacb617f34f2b900b4b23 Mon Sep 17 00:00:00 2001 From: gitpeterwind Date: Thu, 20 Feb 2025 09:57:41 +0100 Subject: [PATCH 2/3] macos fix for metric. remove norm_overlap --- src/treebuilders/apply.cpp | 24 +++--- src/treebuilders/apply.h | 14 +-- src/treebuilders/project.cpp | 1 + src/utils/CompFunction.cpp | 162 +---------------------------------- src/utils/CompFunction.h | 3 - 5 files changed, 21 insertions(+), 183 deletions(-) diff --git a/src/treebuilders/apply.cpp b/src/treebuilders/apply.cpp index cfe17b86..77d8674b 100644 --- a/src/treebuilders/apply.cpp +++ b/src/treebuilders/apply.cpp @@ -116,7 +116,7 @@ template void apply(double prec, FunctionTree &out, Co * no coefs). * */ -template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, ComplexDouble metric[4][4], int maxIter, bool absPrec) { +template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, const ComplexDouble (*metric)[4], int maxIter, bool absPrec) { for (int icomp = 0; icomp < inp.Ncomp(); icomp++) { for (int ocomp = 0; ocomp < 4; ocomp++) { @@ -250,7 +250,7 @@ template void apply(double prec, FunctionTree &out, Co } template -void apply(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, FunctionTreeVector *precTrees, ComplexDouble metric[4][4], int maxIter, bool absPrec) { +void apply(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, FunctionTreeVector *precTrees, const ComplexDouble (*metric)[4], int maxIter, bool absPrec) { for (int icomp = 0; icomp < inp.Ncomp(); icomp++) { for (int ocomp = 0; ocomp < 4; ocomp++) { @@ -293,7 +293,7 @@ template void apply_far_field(double prec, FunctionTree(false, prec, out, oper, inp, maxIter, absPrec); } -template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, ComplexDouble metric[4][4], int maxIter, bool absPrec) { +template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble (*metric)[4], int maxIter, bool absPrec) { for (int icomp = 0; icomp < 4; icomp++) { if (inp.Comp[icomp] != nullptr) { @@ -338,7 +338,7 @@ template void apply_near_field(double prec, FunctionTree(true, prec, out, oper, inp, maxIter, absPrec); } -template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, ComplexDouble metric[4][4], int maxIter, bool absPrec) { +template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble (*metric)[4], int maxIter, bool absPrec) { for (int icomp = 0; icomp < 4; icomp++) { if (inp.Comp[icomp] != nullptr) { @@ -408,7 +408,7 @@ template void apply(FunctionTree &out, DerivativeOpera print::separator(10, ' '); } -template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir, ComplexDouble metric[4][4]) { +template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir, const ComplexDouble (*metric)[4]) { // TODO: sums and not only each components independently, when concrete examples with non diagonal metric are tested for (int icomp = 0; icomp < inp.Ncomp(); icomp++) { @@ -461,7 +461,7 @@ template FunctionTreeVector gradient(DerivativeOperato return out; } -std::vector *> gradient(DerivativeOperator<3> &oper, CompFunction<3> &inp, ComplexDouble metric[4][4]) { +std::vector *> gradient(DerivativeOperator<3> &oper, CompFunction<3> &inp, const ComplexDouble (*metric)[4]) { std::vector *> out; for (int d = 0; d < 3; d++) { @@ -525,7 +525,7 @@ template void divergence(FunctionTree &out, Derivative clear(tmp_vec, true); } -template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, ComplexDouble metric[4][4]) { +template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, const ComplexDouble (*metric)[4]) { MSG_ABORT("not implemented"); } @@ -534,16 +534,16 @@ template void divergence(FunctionTree &out, Derivative for (auto &t : inp) inp_vec.push_back({1.0, t}); divergence(out, oper, inp_vec); } -template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, ComplexDouble metric[4][4]) { +template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, const ComplexDouble (*metric)[4]) { MSG_ABORT("not implemented"); } template void apply<1, double>(double prec, FunctionTree<1, double> &out, ConvolutionOperator<1> &oper, FunctionTree<1, double> &inp, int maxIter, bool absPrec); template void apply<2, double>(double prec, FunctionTree<2, double> &out, ConvolutionOperator<2> &oper, FunctionTree<2, double> &inp, int maxIter, bool absPrec); template void apply<3, double>(double prec, FunctionTree<3, double> &out, ConvolutionOperator<3> &oper, FunctionTree<3, double> &inp, int maxIter, bool absPrec); -template void apply<1>(double prec, CompFunction<1> &out, ConvolutionOperator<1> &oper, const CompFunction<1> &inp, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); -template void apply<2>(double prec, CompFunction<2> &out, ConvolutionOperator<2> &oper, const CompFunction<2> &inp, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); -template void apply<3>(double prec, CompFunction<3> &out, ConvolutionOperator<3> &oper, const CompFunction<3> &inp, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); +template void apply<1>(double prec, CompFunction<1> &out, ConvolutionOperator<1> &oper, const CompFunction<1> &inp, const ComplexDouble (*metric)[4], int maxIter = -1, bool absPrec = false); +template void apply<2>(double prec, CompFunction<2> &out, ConvolutionOperator<2> &oper, const CompFunction<2> &inp, const ComplexDouble (*metric)[4], int maxIter = -1, bool absPrec = false); +template void apply<3>(double prec, CompFunction<3> &out, ConvolutionOperator<3> &oper, const CompFunction<3> &inp, const ComplexDouble (*metric)[4], int maxIter = -1, bool absPrec = false); template void apply<1, double>(double prec, FunctionTree<1, double> &out, ConvolutionOperator<1> &oper, FunctionTree<1, double> &inp, FunctionTreeVector<1, double> &precTrees, int maxIter, bool absPrec); template void @@ -613,6 +613,6 @@ template FunctionTreeVector<1, ComplexDouble> gradient<1>(DerivativeOperator<1> template FunctionTreeVector<2, ComplexDouble> gradient<2>(DerivativeOperator<2> &oper, FunctionTree<2, ComplexDouble> &inp); template FunctionTreeVector<3, ComplexDouble> gradient<3>(DerivativeOperator<3> &oper, FunctionTree<3, ComplexDouble> &inp); -template void apply(CompFunction<3> &out, DerivativeOperator<3> &oper, CompFunction<3> &inp, int dir = -1, ComplexDouble metric[4][4] = nullptr); +template void apply(CompFunction<3> &out, DerivativeOperator<3> &oper, CompFunction<3> &inp, int dir = -1, const ComplexDouble (*metric)[4]); } // namespace mrcpp diff --git a/src/treebuilders/apply.h b/src/treebuilders/apply.h index 3bc9c826..e81da10f 100644 --- a/src/treebuilders/apply.h +++ b/src/treebuilders/apply.h @@ -36,22 +36,22 @@ template class FunctionTree; template class DerivativeOperator; template class ConvolutionOperator; -const ComplexDouble defaultMetric [4][4] ={{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}; +constexpr ComplexDouble defaultMetric [4][4] ={{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}; template void apply(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); +template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, FunctionTreeVector &precTrees, int maxIter = -1, bool absPrec = false); template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, FunctionTreeVector *precTrees, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); template void apply_far_field(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); +template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply_near_field(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); +template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply(FunctionTree &out, DerivativeOperator &oper, FunctionTree &inp, int dir = -1); -template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir = -1, ComplexDouble metric[4][4] = nullptr); +template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir = -1, const ComplexDouble metric[4][4] = defaultMetric); template void divergence(FunctionTree &out, DerivativeOperator &oper, FunctionTreeVector &inp); -template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, ComplexDouble metric[4][4]); +template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, const ComplexDouble metric[4][4] = defaultMetric); template void divergence(FunctionTree &out, DerivativeOperator &oper, std::vector *> &inp); -template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, ComplexDouble metric[4][4] = nullptr); +template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, const ComplexDouble metric[4][4] = defaultMetric); template FunctionTreeVector gradient(DerivativeOperator &oper, FunctionTree &inp); // template std::vector*> gradient(DerivativeOperator<3> &oper, CompFunction<3> &inp, ComplexDouble metric[4][4] = nullptr); diff --git a/src/treebuilders/project.cpp b/src/treebuilders/project.cpp index 7eea8941..2d83cfad 100644 --- a/src/treebuilders/project.cpp +++ b/src/treebuilders/project.cpp @@ -96,6 +96,7 @@ template void project(double prec, FunctionTree &out, out.mwTransform(BottomUp); out.calcSquareNorm(); trans_t.stop(); + std::cout<<" project "< void project(CompFunction &out, RepresentableFunctioniscomplex = 0; if (out.Ncomp() < 1) out.alloc(1); if (need_to_project) mrcpp::project(prec, *out.CompD[0], f); + std::cout<<" comppproject "<<*out.CompD[0]< void project(CompFunction &out, RepresentableFunction &f, double prec) { @@ -2551,167 +2552,6 @@ ComplexMatrix calc_overlap_matrix(CompFunctionVector &Bra, CompFunctionVector &K return S; } -/** @brief Compute the overlap matrix of the absolute value of the functions S_ij = <|bra_i|||ket_j|> - * - */ -DoubleMatrix calc_norm_overlap_matrix(CompFunctionVector &BraKet) { - int N = BraKet.size(); - DoubleMatrix S = DoubleMatrix::Zero(N, N); - DoubleMatrix Sreal = DoubleMatrix::Zero(N, N); // same as S, but stored as 4 blocks, rr,ri,ir,ii - MultiResolutionAnalysis<3> *mra = BraKet.vecMRA; - - // 1) make union tree without coefficients - mrcpp::FunctionTree<3> refTree(*mra); - mrcpp::mpi::allreduce_Tree_noCoeff(refTree, BraKet, mpi::comm_wrk); - - int sizecoeff = (1 << refTree.getDim()) * refTree.getKp1_d(); - int sizecoeffW = ((1 << refTree.getDim()) - 1) * refTree.getKp1_d(); - - // get a list of all nodes in union grid, as defined by their indices - std::vector scalefac; - std::vector coeffVec_ref; - std::vector indexVec_ref; // serialIx of the nodes - std::vector parindexVec_ref; // serialIx of the parent nodes - int max_ix; // largest index value (not used here) - - refTree.makeCoeffVector(coeffVec_ref, indexVec_ref, parindexVec_ref, scalefac, max_ix, refTree); - int max_n = indexVec_ref.size(); - - // only used for serial case: - std::vector> coeffVec(N); - std::map> node2orbVec; // for each node index, gives a vector with the indices of the orbitals using this node - std::vector> orb2node(N); // for a given orbital and a given node, gives the node index in - // the orbital given the node index in the reference tree - - bool serial = mrcpp::mpi::wrk_size == 1; // flag for serial/MPI switch - mrcpp::BankAccount nodesBraKet; - - // In the serial case we store the coeff pointers in coeffVec. In the mpi case the coeff are stored in the bank - if (serial) { - // 2) make list of all coefficients, and their reference indices - // for different orbitals, indexVec will give the same index for the same node in space - std::vector parindexVec; // serialIx of the parent nodes - std::vector indexVec; // serialIx of the nodes - for (int j = 0; j < N; j++) { - // make vector with all coef pointers and their indices in the union grid - if (BraKet[j].hasReal()) { - BraKet[j].real().makeCoeffVector(coeffVec[j], indexVec, parindexVec, scalefac, max_ix, refTree); - // make a map that gives j from indexVec - int orb_node_ix = 0; - for (int ix : indexVec) { - orb2node[j][ix] = orb_node_ix++; - if (ix < 0) continue; - node2orbVec[ix].push_back(j); - } - } - if (BraKet[j].hasImag()) { - NOT_IMPLEMENTED_ABORT; - BraKet[j].imag().makeCoeffVector(coeffVec[j + N], indexVec, parindexVec, scalefac, max_ix, refTree); - // make a map that gives j from indexVec - int orb_node_ix = 0; - for (int ix : indexVec) { - orb2node[j + N][ix] = orb_node_ix++; - if (ix < 0) continue; - node2orbVec[ix].push_back(j + N); - } - } - } - } else { // MPI case - // 2) send own nodes to bank, identifying them through the serialIx of refTree - save_nodes(BraKet, refTree, nodesBraKet); - mrcpp::mpi::barrier(mrcpp::mpi::comm_wrk); // wait until everything is stored before fetching! - } - - // 3) make dot product for all the nodes and accumulate into S - - int ibank = 0; -#pragma omp parallel for schedule(dynamic) if (serial) - for (int n = 0; n < max_n; n++) { - if (n % mrcpp::mpi::wrk_size != mrcpp::mpi::wrk_rank) continue; - int csize; - int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree - std::vector orbVec; // identifies which orbitals use this node - if (serial and node2orbVec[node_ix].size() <= 0) continue; - if (parindexVec_ref[n] < 0) - csize = sizecoeff; - else - csize = sizecoeffW; - // In the serial case we copy the coeff coeffBlock. In the mpi case coeffBlock is provided by the bank - if (serial) { - int shift = sizecoeff - sizecoeffW; // to copy only wavelet part - if (parindexVec_ref[n] < 0) shift = 0; - DoubleMatrix coeffBlock(csize, node2orbVec[node_ix].size()); - for (int j : node2orbVec[node_ix]) { // loop over indices of the orbitals using this node - int orb_node_ix = orb2node[j][node_ix]; - for (int k = 0; k < csize; k++) coeffBlock(k, orbVec.size()) = coeffVec[j][orb_node_ix][k + shift]; - orbVec.push_back(j); - } - if (orbVec.size() > 0) { - DoubleMatrix S_temp(orbVec.size(), orbVec.size()); - coeffBlock = coeffBlock.cwiseAbs(); - S_temp.noalias() = coeffBlock.transpose() * coeffBlock; - for (int i = 0; i < orbVec.size(); i++) { - for (int j = 0; j < orbVec.size(); j++) { - if (BraKet[orbVec[i]].func_ptr->data.n1[0] != BraKet[orbVec[j]].func_ptr->data.n1[0] and BraKet[orbVec[i]].func_ptr->data.n1[0] != 0 and - BraKet[orbVec[j]].func_ptr->data.n1[0] != 0) - continue; - double &Srealij = Sreal(orbVec[i], orbVec[j]); - double &Stempij = S_temp(i, j); -#pragma omp atomic - Srealij += Stempij; - } - } - } - } else { // MPI case - DoubleMatrix coeffBlock(csize, N); - nodesBraKet.get_nodeblock(indexVec_ref[n], coeffBlock.data(), orbVec); - - if (orbVec.size() > 0) { - DoubleMatrix S_temp(orbVec.size(), orbVec.size()); - coeffBlock.conservativeResize(Eigen::NoChange, orbVec.size()); - coeffBlock = coeffBlock.cwiseAbs(); - S_temp.noalias() = coeffBlock.transpose() * coeffBlock; - for (int i = 0; i < orbVec.size(); i++) { - for (int j = 0; j < orbVec.size(); j++) { - if (BraKet[orbVec[i]].func_ptr->data.n1[0] != BraKet[orbVec[j]].func_ptr->data.n1[0] and BraKet[orbVec[i]].func_ptr->data.n1[0] != 0 and - BraKet[orbVec[j]].func_ptr->data.n1[0] != 0) - continue; - Sreal(orbVec[i], orbVec[j]) += S_temp(i, j); - } - } - } - } - } - - IntVector conjMat = IntVector::Zero(N); - for (int i = 0; i < N; i++) { - if (!mrcpp::mpi::my_func(i)) continue; - conjMat[i] = (BraKet[i].conjugate()) ? -1 : 1; - } - mrcpp::mpi::allreduce_vector(conjMat, mrcpp::mpi::comm_wrk); - - for (int i = 0; i < N; i++) { - for (int j = 0; j <= i; j++) { - S(i, j) = Sreal(i, j) + conjMat[i] * conjMat[j] * Sreal(i + N, j + N) + conjMat[j] * Sreal(i, j + N) - conjMat[i] * Sreal(i + N, j); - S(j, i) = S(i, j); - } - } - - // Assumes linearity: result is sum of all nodes contributions - mrcpp::mpi::allreduce_matrix(S, mrcpp::mpi::comm_wrk); - // multiply by CompFunction multiplicative factor - ComplexVector Fac = ComplexVector::Zero(N); - for (int i = 0; i < N; i++) { - if (!mrcpp::mpi::my_func(BraKet[i])) continue; - Fac[i] = BraKet[i].func_ptr->data.c1[0]; - } - mrcpp::mpi::allreduce_vector(Fac, mrcpp::mpi::comm_wrk); - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { S(i, j) *= std::norm(std::conj(Fac[i])) * std::norm(Fac[j]); } - } - return S; -} - /** @brief Orthogonalize the functions in Bra against all orbitals in Ket * */ diff --git a/src/utils/CompFunction.h b/src/utils/CompFunction.h index 96ac057c..82209819 100644 --- a/src/utils/CompFunction.h +++ b/src/utils/CompFunction.h @@ -187,7 +187,6 @@ class CompFunctionVector : public std::vector> { void rotate(CompFunctionVector &Phi, const ComplexMatrix &U, double prec = -1.0); void rotate(CompFunctionVector &Phi, const ComplexMatrix &U, CompFunctionVector &Psi, double prec = -1.0); -// void rotate_cplx(CompFunctionVector &Phi, const ComplexMatrix &U, CompFunctionVector &Psi, double prec = -1.0); void save_nodes(CompFunctionVector &Phi, mrcpp::FunctionTree<3, double> &refTree, BankAccount &account, int sizes = -1); CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f, double prec = -1.0, CompFunction<3> *Func = nullptr, int nrefine = 1, bool all = false); void SetdefaultMRA(MultiResolutionAnalysis<3> *MRA); @@ -195,8 +194,6 @@ ComplexVector dot(CompFunctionVector &Bra, CompFunctionVector &Ket); ComplexMatrix calc_lowdin_matrix(CompFunctionVector &Phi); ComplexMatrix calc_overlap_matrix(CompFunctionVector &BraKet); ComplexMatrix calc_overlap_matrix(CompFunctionVector &Bra, CompFunctionVector &Ket); -// ComplexMatrix calc_overlap_matrix_cplx(CompFunctionVector &Bra, CompFunctionVector &Ket); -DoubleMatrix calc_norm_overlap_matrix(CompFunctionVector &BraKet); void orthogonalize(double prec, CompFunctionVector &Bra, CompFunctionVector &Ket); } // namespace mrcpp From cba8256377a39fbe1bdd6cc3766308a242ff1ba1 Mon Sep 17 00:00:00 2001 From: gitpeterwind Date: Thu, 20 Feb 2025 10:17:52 +0100 Subject: [PATCH 3/3] cleanup --- src/treebuilders/apply.h | 16 ++++++++-------- src/treebuilders/project.cpp | 1 - src/utils/CompFunction.cpp | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/treebuilders/apply.h b/src/treebuilders/apply.h index e81da10f..e50b3b87 100644 --- a/src/treebuilders/apply.h +++ b/src/treebuilders/apply.h @@ -39,22 +39,22 @@ template class ConvolutionOperator; constexpr ComplexDouble defaultMetric [4][4] ={{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}; template void apply(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); +template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, const CompFunction &inp, const ComplexDouble (*metric)[4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, FunctionTreeVector &precTrees, int maxIter = -1, bool absPrec = false); -template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, FunctionTreeVector *precTrees, ComplexDouble metric[4][4] = nullptr, int maxIter = -1, bool absPrec = false); +template void apply(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, FunctionTreeVector *precTrees, ComplexDouble (*metric)[4] = nullptr, int maxIter = -1, bool absPrec = false); template void apply_far_field(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); +template void apply_far_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble (*metric)[4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply_near_field(double prec, FunctionTree &out, ConvolutionOperator &oper, FunctionTree &inp, int maxIter = -1, bool absPrec = false); -template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble metric[4][4] = defaultMetric, int maxIter = -1, bool absPrec = false); +template void apply_near_field(double prec, CompFunction &out, ConvolutionOperator &oper, CompFunction &inp, const ComplexDouble (*metric)[4] = defaultMetric, int maxIter = -1, bool absPrec = false); template void apply(FunctionTree &out, DerivativeOperator &oper, FunctionTree &inp, int dir = -1); -template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir = -1, const ComplexDouble metric[4][4] = defaultMetric); +template void apply(CompFunction &out, DerivativeOperator &oper, CompFunction &inp, int dir = -1, const ComplexDouble (*metric)[4] = defaultMetric); template void divergence(FunctionTree &out, DerivativeOperator &oper, FunctionTreeVector &inp); -template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, const ComplexDouble metric[4][4] = defaultMetric); +template void divergence(CompFunction &out, DerivativeOperator &oper, FunctionTreeVector *inp, const ComplexDouble (*metric)[4] = defaultMetric); template void divergence(FunctionTree &out, DerivativeOperator &oper, std::vector *> &inp); -template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, const ComplexDouble metric[4][4] = defaultMetric); +template void divergence(CompFunction &out, DerivativeOperator &oper, std::vector *> *inp, const ComplexDouble (*metric)[4] = defaultMetric); template FunctionTreeVector gradient(DerivativeOperator &oper, FunctionTree &inp); // template -std::vector*> gradient(DerivativeOperator<3> &oper, CompFunction<3> &inp, ComplexDouble metric[4][4] = nullptr); +std::vector*> gradient(DerivativeOperator<3> &oper, CompFunction<3> &inp, ComplexDouble (*metric)[4] = nullptr); // clang-format on } // namespace mrcpp diff --git a/src/treebuilders/project.cpp b/src/treebuilders/project.cpp index 2d83cfad..7eea8941 100644 --- a/src/treebuilders/project.cpp +++ b/src/treebuilders/project.cpp @@ -96,7 +96,6 @@ template void project(double prec, FunctionTree &out, out.mwTransform(BottomUp); out.calcSquareNorm(); trans_t.stop(); - std::cout<<" project "< void project(CompFunction &out, RepresentableFunctioniscomplex = 0; if (out.Ncomp() < 1) out.alloc(1); if (need_to_project) mrcpp::project(prec, *out.CompD[0], f); - std::cout<<" comppproject "<<*out.CompD[0]< void project(CompFunction &out, RepresentableFunction &f, double prec) {