From b7151e60c3b4f3ee4a7b890d28f8a374155eccd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=B6llmann?= Date: Mon, 5 Jan 2026 14:28:17 +0100 Subject: [PATCH 1/3] removed all warnings; tested with clang21 on macOS 26 on M4 processor --- src/core/CrossCorrelation.cpp | 8 ++++---- src/core/MWFilter.cpp | 8 ++++---- src/functions/Gaussian.cpp | 1 - src/treebuilders/ABGVCalculator.cpp | 5 ++--- src/treebuilders/ConvolutionCalculator.cpp | 3 +-- src/treebuilders/DerivativeCalculator.cpp | 10 ++------- src/treebuilders/grid.cpp | 1 - src/treebuilders/multiply.cpp | 8 ++++---- src/trees/FunctionNode.cpp | 4 ++-- src/trees/FunctionTree.cpp | 24 ++++------------------ src/trees/HilbertPath.cpp | 15 ++++++++++++++ src/trees/HilbertPath.h | 8 ++++---- src/trees/MWNode.cpp | 14 ++++--------- src/trees/OperatorNode.cpp | 4 ---- src/utils/Bank.cpp | 6 +++++- src/utils/Bank.h | 4 +++- src/utils/CompFunction.cpp | 20 +++++------------- src/utils/tree_utils.cpp | 22 ++++++++++---------- tests/factory_functions.h | 1 - tests/functions/polynomial.cpp | 1 - tests/operators/helmholtz_operator.cpp | 1 - tests/operators/poisson_operator.cpp | 2 -- tests/treebuilders/map.cpp | 1 - tests/trees/function_tree.cpp | 4 ---- tests/trees/node_index.cpp | 1 - 25 files changed, 70 insertions(+), 106 deletions(-) diff --git a/src/core/CrossCorrelation.cpp b/src/core/CrossCorrelation.cpp index 8b04cf18d..788491efd 100644 --- a/src/core/CrossCorrelation.cpp +++ b/src/core/CrossCorrelation.cpp @@ -106,11 +106,11 @@ void CrossCorrelation::readCCCBin() { int K = this->order + 1; this->Left = MatrixXd::Zero(K * K, 2 * K); this->Right = MatrixXd::Zero(K * K, 2 * K); - double dL[2 * K]; - double dR[2 * K]; + std::vector dL(2 * K); + std::vector dR(2 * K); for (int i = 0; i < K * K; i++) { - L_fis.read((char *)dL, sizeof(double) * 2 * K); - R_fis.read((char *)dR, sizeof(double) * 2 * K); + L_fis.read(reinterpret_cast(dL.data()), sizeof(double) * 2 * K); + R_fis.read(reinterpret_cast(dR.data()), sizeof(double) * 2 * K); for (int j = 0; j < 2 * K; j++) { if (std::abs(dL[j]) < MachinePrec) dL[j] = 0.0; if (std::abs(dR[j]) < MachinePrec) dR[j] = 0.0; diff --git a/src/core/MWFilter.cpp b/src/core/MWFilter.cpp index 8ada4f2ca..19ed535cd 100644 --- a/src/core/MWFilter.cpp +++ b/src/core/MWFilter.cpp @@ -206,14 +206,14 @@ void MWFilter::generateBlocks() { int K = this->order + 1; - double dH[K]; - double dG[K]; + std::vector dH(K); + std::vector dG(K); /* read H0 and G0 from disk */ this->G0 = Eigen::MatrixXd::Zero(K, K); this->H0 = Eigen::MatrixXd::Zero(K, K); for (int i = 0; i < K; i++) { - H_fis.read((char *)dH, sizeof(double) * K); - G_fis.read((char *)dG, sizeof(double) * K); + H_fis.read(reinterpret_cast(dH.data()), sizeof(double) * K); + G_fis.read(reinterpret_cast(dG.data()), sizeof(double) * K); for (int j = 0; j < K; j++) { this->G0(i, j) = dG[j]; // G0 this->H0(i, j) = dH[j]; // H0 diff --git a/src/functions/Gaussian.cpp b/src/functions/Gaussian.cpp index 6dbfa7c5b..0b8e3214b 100644 --- a/src/functions/Gaussian.cpp +++ b/src/functions/Gaussian.cpp @@ -194,7 +194,6 @@ template GaussExp Gaussian::periodify(const std::array auto needed_cells_vec = std::vector(); for (auto i = 0; i < D; i++) { auto upper_bound = pos[i] + x_std; - auto lower_bound = pos[i] - x_std; // number of cells upp and down relative to the center of the Gaussian needed_cells_vec.push_back(std::ceil(upper_bound / period[i])); } diff --git a/src/treebuilders/ABGVCalculator.cpp b/src/treebuilders/ABGVCalculator.cpp index 10252f46a..376068b5d 100644 --- a/src/treebuilders/ABGVCalculator.cpp +++ b/src/treebuilders/ABGVCalculator.cpp @@ -48,7 +48,7 @@ ABGVCalculator::ABGVCalculator(const ScalingBasis &basis, double a, double b) void ABGVCalculator::calcValueVectors(const ScalingBasis &basis) { int kp1 = basis.getQuadratureOrder(); - double sqrtCoef[kp1]; + std::vector sqrtCoef(kp1); for (int i = 0; i < kp1; i++) { sqrtCoef[i] = std::sqrt(2.0 * i + 1.0); } switch (basis.getScalingType()) { @@ -74,7 +74,7 @@ void ABGVCalculator::calcValueVectors(const ScalingBasis &basis) { void ABGVCalculator::calcKMatrix(const ScalingBasis &basis) { int kp1 = basis.getQuadratureOrder(); - double sqrtCoef[kp1]; + std::vector sqrtCoef(kp1); for (int i = 0; i < kp1; i++) { sqrtCoef[i] = std::sqrt(2.0 * i + 1.0); } getQuadratureCache(qCache); const VectorXd &roots = qCache.getRoots(kp1); @@ -105,7 +105,6 @@ void ABGVCalculator::calcNode(MWNode<2> &node) { node.zeroCoefs(); const auto &idx = node.getNodeIndex(); - int l = idx[1] - idx[0]; int np1 = idx.getScale() + 1; int kp1 = node.getKp1(); int kp1_d = node.getKp1_d(); diff --git a/src/treebuilders/ConvolutionCalculator.cpp b/src/treebuilders/ConvolutionCalculator.cpp index 497fe0dd8..c9e7c5964 100644 --- a/src/treebuilders/ConvolutionCalculator.cpp +++ b/src/treebuilders/ConvolutionCalculator.cpp @@ -143,7 +143,6 @@ template MWNodeVector *ConvolutionCalculator::ma auto *band = new MWNodeVector; int o_depth = gNode.getScale() - this->oper->getOperatorRoot(); - int g_depth = gNode.getDepth(); int width = this->oper->getMaxBandWidth(o_depth); bool periodic = gNode.getMWTree().isPeriodic(); @@ -228,7 +227,7 @@ template void ConvolutionCalculator::calcNode(MWNodeoper->getOperatorRoot(); if (manipulateOperator and this->oper->getOperatorRoot() < 0) o_depth = gNode.getDepth(); - T tmpCoefs[gNode.getNCoefs()]; + std::vector tmpCoefs(gNode.getNCoefs()); OperatorState os(gNode, tmpCoefs); this->operStat.incrementGNodeCounters(gNode); diff --git a/src/treebuilders/DerivativeCalculator.cpp b/src/treebuilders/DerivativeCalculator.cpp index b298d1b6e..c59755c89 100644 --- a/src/treebuilders/DerivativeCalculator.cpp +++ b/src/treebuilders/DerivativeCalculator.cpp @@ -90,7 +90,7 @@ template void DerivativeCalculator::calcNode(MWNodeoper->getMaxBandWidth() > 1) MSG_ABORT("Only implemented for zero bw"); outNode.zeroCoefs(); int nComp = (1 << D); - T tmpCoefs[outNode.getNCoefs()]; + std::vector tmpCoefs(outNode.getNCoefs()); OperatorState os(outNode, tmpCoefs); os.setFNode(inpNode); @@ -116,7 +116,7 @@ template void DerivativeCalculator::calcNode(MWNode tmpCoefs(gNode.getNCoefs()); OperatorState os(gNode, tmpCoefs); this->operStat.incrementGNodeCounters(gNode); @@ -182,11 +182,8 @@ template void DerivativeCalculator::applyOperator_bw0( // cout<<" applyOperator "< &gNode = *os.gNode; MWNode &fNode = *os.fNode; - const NodeIndex &fIdx = *os.fIdx; - const NodeIndex &gIdx = gNode.getNodeIndex(); int depth = gNode.getDepth(); - double oNorm = 1.0; double **oData = os.getOperData(); for (int d = 0; d < D; d++) { @@ -218,7 +215,6 @@ template void DerivativeCalculator::applyOperator(Oper const NodeIndex &gIdx = gNode.getNodeIndex(); int depth = gNode.getDepth(); - double oNorm = 1.0; double **oData = os.getOperData(); for (int d = 0; d < D; d++) { @@ -236,8 +232,6 @@ template void DerivativeCalculator::applyOperator(Oper const OperatorNode &oNode = oTree.getNode(depth, oTransl); int oIdx = os.getOperIndex(d); - double ocn = oNode.getComponentNorm(oIdx); - oNorm *= ocn; if (this->applyDir == d) { oData[d] = const_cast(oNode.getCoefs()) + oIdx * os.kp1_2; } else { diff --git a/src/treebuilders/grid.cpp b/src/treebuilders/grid.cpp index 0e7fb968b..eaaf3696b 100644 --- a/src/treebuilders/grid.cpp +++ b/src/treebuilders/grid.cpp @@ -113,7 +113,6 @@ template void build_grid(FunctionTree &out, const GaussExp &inp, i builder.build(out, calculator, adaptor, maxIter); } } else { - auto period = out.getMRA().getWorldBox().getScalingFactors(); for (auto i = 0; i < inp.size(); i++) { auto *gauss = inp.getFunc(i).copy(); build_grid(out, *gauss, maxIter); diff --git a/src/treebuilders/multiply.cpp b/src/treebuilders/multiply.cpp index 4e046126e..46587ffaa 100644 --- a/src/treebuilders/multiply.cpp +++ b/src/treebuilders/multiply.cpp @@ -334,8 +334,8 @@ template double node_norm_dot(FunctionTree &bra, Funct double result = 0.0; int ncoef = bra.getKp1_d() * bra.getTDim(); - T valA[ncoef]; - T valB[ncoef]; + std::vector valA(ncoef); + std::vector valB(ncoef); int nNodes = bra.getNEndNodes(); for (int n = 0; n < nNodes; n++) { @@ -345,8 +345,8 @@ template double node_norm_dot(FunctionTree &bra, Funct // convert to interpolating coef, take abs, convert back FunctionNode *mwNode = static_cast *>(ket.findNode(idx)); if (mwNode == nullptr) MSG_ABORT("Trees must have same grid"); - node.getAbsCoefs(valA); - mwNode->getAbsCoefs(valB); + node.getAbsCoefs(valA.data()); + mwNode->getAbsCoefs(valB.data()); for (int i = 0; i < ncoef; i++) result += std::norm(valA[i] * valB[i]); } else { // approximate by product of node norms diff --git a/src/trees/FunctionNode.cpp b/src/trees/FunctionNode.cpp index ff23fb394..102e5bd26 100644 --- a/src/trees/FunctionNode.cpp +++ b/src/trees/FunctionNode.cpp @@ -130,7 +130,7 @@ template T FunctionNode::integrateInterpolating() cons int qOrder = this->getKp1(); getQuadratureCache(qc); const VectorXd &weights = qc.getWeights(qOrder); - double sqWeights[qOrder]; + std::vector sqWeights(qOrder); for (int i = 0; i < qOrder; i++) sqWeights[i] = std::sqrt(weights[i]); int kp1_p[D]; @@ -170,7 +170,7 @@ template T FunctionNode::integrateValues() const { this->getCoefs(coefs); int ncoefs = coefs.size(); int ncoefChild = ncoefs / (1 << D); - T cc[ncoefChild]; + std::vector cc(ncoefChild); // factorize out the children for (int i = 0; i < ncoefChild; i++) cc[i] = coefs[i]; for (int j = 1; j < (1 << D); j++) diff --git a/src/trees/FunctionTree.cpp b/src/trees/FunctionTree.cpp index 72ca68e39..995578436 100644 --- a/src/trees/FunctionTree.cpp +++ b/src/trees/FunctionTree.cpp @@ -290,9 +290,6 @@ template void FunctionTree::loadTreeTXT(const std::str * @param[in] file: File name */ template void FunctionTree::saveTreeTXT(const std::string &fname) { - int nRoots = this->getRootBox().size(); - MWNode **roots = this->getRootBox().getNodes(); - std::ofstream out(fname); out << std::setprecision(14); out << D << std::endl; @@ -306,7 +303,7 @@ template void FunctionTree::saveTreeTXT(const std::str int ncoefs = 1; for (int d = 0; d < D; d++) ncoefs *= kp1; int Tdim = std::pow(2, D); - T values[ncoefs * Tdim]; + std::vector values(ncoefs * Tdim); int nout = this->endNodeTable.size(); out << Tdim * nout << std::endl; // could output only scaling coeff? @@ -334,7 +331,7 @@ template void FunctionTree::saveTreeTXT(const std::str MWNode *node = &(this->getNode(idx, false)); T *coefs = node->getCoefs(); for (int i = 0; i < ncoefs * Tdim; i++) values[i] = coefs[i]; - node->attachCoefs(values); + node->attachCoefs(values.data()); int n = idx.getScale(); node->mwTransform(Reconstruction); node->cvTransform(Forward); @@ -443,7 +440,6 @@ template <> double FunctionTree<3, double>::integrateEndNodes(RepresentableFunct // traverse tree, and treat end nodes only std::vector *> stack; // node from this for (int i = 0; i < this->getRootBox().size(); i++) stack.push_back(&(this->getRootFuncNode(i))); - int basis = getMRA().getScalingBasis().getScalingType(); double result = 0.0; while (stack.size() > 0) { FunctionNode<3> *Node = stack.back(); @@ -456,9 +452,9 @@ template <> double FunctionTree<3, double>::integrateEndNodes(RepresentableFunct double *coefs = Node->getCoefs(); // save position of coeff, but do not use them! // The data in fmat is not organized so that two consecutive points are stored after each other in memory, so needs to copy before mwtransform, cannot use memory adress directly. int nc = fmat.cols(); - double cc[nc]; + std::vector cc(nc); for (int i = 0; i < nc; i++) cc[i] = fmat(0, i); - Node->attachCoefs(cc); + Node->attachCoefs(cc.data()); result += Node->integrateValues(); Node->attachCoefs(coefs); // put back original coeff } @@ -880,8 +876,6 @@ void FunctionTree::makeCoeffVector(std::vector &coefs, indices.clear(); parent_indices.clear(); max_index = 0; - int sizecoeff = (1 << refTree.getDim()) * refTree.getKp1_d(); - int sizecoeffW = ((1 << refTree.getDim()) - 1) * refTree.getKp1_d(); std::vector *> refstack; // nodes from refTree std::vector *> thisstack; // nodes from this Tree for (int rIdx = 0; rIdx < this->getRootBox().size(); rIdx++) { @@ -1096,7 +1090,6 @@ template <> int FunctionTree<3, double>::saveNodesAndRmCoeff() { for (int rIdx = 0; rIdx < this->getRootBox().size(); rIdx++) { stack.push_back(this->getRootBox().getNodes()[rIdx]); } while (stack.size() > stack_p) { MWNode<3, double> *Node = stack[stack_p++]; - int id = 0; NodesCoeff->put_data(Node->getNodeIndex(), sizecoeff, Node->getCoefs()); for (int i = 0; i < Node->getNChildren(); i++) { stack.push_back(Node->children[i]); } } @@ -1119,7 +1112,6 @@ template <> int FunctionTree<3, ComplexDouble>::saveNodesAndRmCoeff() { for (int rIdx = 0; rIdx < this->getRootBox().size(); rIdx++) { stack.push_back(this->getRootBox().getNodes()[rIdx]); } while (stack.size() > stack_p) { MWNode<3, ComplexDouble> *Node = stack[stack_p++]; - int id = 0; NodesCoeff->put_data(Node->getNodeIndex(), sizecoeff, Node->getCoefs()); for (int i = 0; i < Node->getNChildren(); i++) { stack.push_back(Node->children[i]); } } @@ -1195,7 +1187,6 @@ template FunctionTree *FunctionTree::Imag() template <> void FunctionTree<3, double>::CopyTreeToComplex(FunctionTree<3, ComplexDouble> *&outTree) { delete outTree; - double ref = 0.0; outTree = new FunctionTree<3, ComplexDouble>(this->getMRA()); std::vector *> instack; // node from this std::vector *> outstack; // node from outTree @@ -1204,7 +1195,6 @@ template <> void FunctionTree<3, double>::CopyTreeToComplex(FunctionTree<3, Comp instack.push_back(this->getRootBox().getNodes()[rIdx]); outstack.push_back(outTree->getRootBox().getNodes()[rIdx]); } - int nNodes = std::min(this->getNNodes(), this->getNodeAllocator().getMaxNodesPerChunk()); int ncoefs = this->getNodeAllocator().getNCoefs(); while (instack.size() > 0) { // inNode and outNode are the same node in space, but on different trees @@ -1235,7 +1225,6 @@ template <> void FunctionTree<3, double>::CopyTreeToComplex(FunctionTree<3, Comp template <> void FunctionTree<2, double>::CopyTreeToComplex(FunctionTree<2, ComplexDouble> *&outTree) { delete outTree; - double ref = 0.0; outTree = new FunctionTree<2, ComplexDouble>(this->getMRA()); std::vector *> instack; // node from this std::vector *> outstack; // node from outTree @@ -1244,7 +1233,6 @@ template <> void FunctionTree<2, double>::CopyTreeToComplex(FunctionTree<2, Comp instack.push_back(this->getRootBox().getNodes()[rIdx]); outstack.push_back(outTree->getRootBox().getNodes()[rIdx]); } - int nNodes = std::min(this->getNNodes(), this->getNodeAllocator().getMaxNodesPerChunk()); int ncoefs = this->getNodeAllocator().getNCoefs(); while (instack.size() > 0) { // inNode and outNode are the same node in space, but on different trees @@ -1275,7 +1263,6 @@ template <> void FunctionTree<2, double>::CopyTreeToComplex(FunctionTree<2, Comp template <> void FunctionTree<1, double>::CopyTreeToComplex(FunctionTree<1, ComplexDouble> *&outTree) { delete outTree; - double ref = 0.0; outTree = new FunctionTree<1, ComplexDouble>(this->getMRA()); std::vector *> instack; // node from this std::vector *> outstack; // node from outTree @@ -1284,7 +1271,6 @@ template <> void FunctionTree<1, double>::CopyTreeToComplex(FunctionTree<1, Comp instack.push_back(this->getRootBox().getNodes()[rIdx]); outstack.push_back(outTree->getRootBox().getNodes()[rIdx]); } - int nNodes = std::min(this->getNNodes(), this->getNodeAllocator().getMaxNodesPerChunk()); int ncoefs = this->getNodeAllocator().getNCoefs(); while (instack.size() > 0) { // inNode and outNode are the same node in space, but on different trees @@ -1316,7 +1302,6 @@ template <> void FunctionTree<1, double>::CopyTreeToComplex(FunctionTree<1, Comp // for testing template <> void FunctionTree<3, double>::CopyTreeToReal(FunctionTree<3, double> *&outTree) { delete outTree; - double ref = 0.0; // FunctionTree<3, double>* inTree = this; outTree = new FunctionTree<3, double>(this->getMRA()); std::vector *> instack; // node from this @@ -1326,7 +1311,6 @@ template <> void FunctionTree<3, double>::CopyTreeToReal(FunctionTree<3, double> instack.push_back(this->getRootBox().getNodes()[rIdx]); outstack.push_back(outTree->getRootBox().getNodes()[rIdx]); } - int nNodes = std::min(this->getNNodes(), this->getNodeAllocator().getMaxNodesPerChunk()); int ncoefs = this->getNodeAllocator().getNCoefs(); while (instack.size() > 0) { // inNode and outNode are the same node in space, but on different trees diff --git a/src/trees/HilbertPath.cpp b/src/trees/HilbertPath.cpp index b052064a8..ac2529852 100644 --- a/src/trees/HilbertPath.cpp +++ b/src/trees/HilbertPath.cpp @@ -114,6 +114,21 @@ const int HilbertPath<3>::hTable[12][8] = { {4,5,7,6,3,2,0,1} }; +template +short int HilbertPath::getChildPath(int hIdx) const { + return pTable[this->path][hIdx]; +} + +template +int HilbertPath::getZIndex(int hIdx) const { + return zTable[this->path][hIdx]; +} + +template +int HilbertPath::getHIndex(int zIdx) const { + return hTable[this->path][zIdx]; +} + // clang-format on template class HilbertPath<1>; diff --git a/src/trees/HilbertPath.h b/src/trees/HilbertPath.h index 519e7ac73..981c5354f 100644 --- a/src/trees/HilbertPath.h +++ b/src/trees/HilbertPath.h @@ -42,10 +42,10 @@ template class HilbertPath final { } short int getPath() const { return this->path; } - short int getChildPath(int hIdx) const { return this->pTable[this->path][hIdx]; } + short int getChildPath(int hIdx) const; - int getZIndex(int hIdx) const { return this->zTable[this->path][hIdx]; } - int getHIndex(int zIdx) const { return this->hTable[this->path][zIdx]; } + int getZIndex(int hIdx) const; + int getHIndex(int zIdx) const; private: short int path{0}; @@ -54,4 +54,4 @@ template class HilbertPath final { static const int hTable[][8]; }; -} // namespace mrcpp +} // namespace mrcpp \ No newline at end of file diff --git a/src/trees/MWNode.cpp b/src/trees/MWNode.cpp index 2d521b468..9f40bed23 100644 --- a/src/trees/MWNode.cpp +++ b/src/trees/MWNode.cpp @@ -346,13 +346,9 @@ template void MWNode::giveChildrenCoefs(bool overwrite * copied/summed in the correct child node. */ template void MWNode::giveChildCoefs(int cIdx, bool overwrite) { - MWNode node_i = *this; - node_i.mwTransform(Reconstruction); - int kp1_d = this->getKp1_d(); - int nChildren = this->getTDim(); if (this->children[cIdx] == nullptr) MSG_ABORT("Child does not exist!"); MWNode &child = getMWChild(cIdx); @@ -457,8 +453,8 @@ template void MWNode::cvTransform(int operation, bool auto sb = this->getMWTree().getMRA().getScalingBasis(); const MatrixXd &S = sb.getCVMap(operation); - T o_vec[nCoefs]; - T *out_vec = o_vec; + std::vector o_vec(nCoefs); + T *out_vec = o_vec.data(); T *in_vec = this->coefs; int nChildren = this->getTDim(); @@ -566,8 +562,8 @@ template void MWNode::mwTransform(int operation) { const MWFilter &filter = getMWTree().getMRA().getFilter(); double overwrite = 0.0; - T o_vec[nCoefs]; - T *out_vec = o_vec; + std::vector o_vec(nCoefs); + T *out_vec = o_vec.data(); T *in_vec = this->coefs; for (int i = 0; i < D; i++) { @@ -1259,7 +1255,6 @@ template std::ostream &MWNode::print(std::ostream &o) * i.e. *not* same normalization as a squareNorm */ template void MWNode::setMaxSquareNorm() { - auto n = this->getScale(); this->maxWSquareNorm = calcScaledWSquareNorm(); this->maxSquareNorm = calcScaledSquareNorm(); @@ -1275,7 +1270,6 @@ template void MWNode::setMaxSquareNorm() { /** @brief recursively reset maxSquaredNorm and maxWSquareNorm of parent and descendants to value -1 */ template void MWNode::resetMaxSquareNorm() { - auto n = this->getScale(); this->maxSquareNorm = -1.0; this->maxWSquareNorm = -1.0; if (not this->isEndNode()) { diff --git a/src/trees/OperatorNode.cpp b/src/trees/OperatorNode.cpp index 37f576eac..6253ba51b 100644 --- a/src/trees/OperatorNode.cpp +++ b/src/trees/OperatorNode.cpp @@ -94,10 +94,6 @@ double OperatorNode::calcComponentNorm(int i) const { * */ MatrixXd OperatorNode::getComponent(int i) { - int depth = getDepth(); - double prec = getOperTree().getNormPrecision(); - double thrs = std::max(MachinePrec, prec / (8.0 * (1 << depth))); - VectorXd coef_vec; this->getCoefs(coef_vec); diff --git a/src/utils/Bank.cpp b/src/utils/Bank.cpp index f8c111a53..31fc1f869 100644 --- a/src/utils/Bank.cpp +++ b/src/utils/Bank.cpp @@ -9,7 +9,9 @@ using namespace Eigen; using namespace std; int metadata_block[3]; // can add more metadata in future -int const size_metadata = 3; +#ifdef MRCPP_HAS_MPI + int const size_metadata = 3; +#endif Bank::~Bank() { // delete all data and accounts @@ -57,7 +59,9 @@ std::map *> get_orbid2block; // to get blo std::map mem; +#ifdef MRCPP_HAS_MPI int const MIN_SCALE = -999; // Smaller than smallest scale +#endif int naccounts = 0; void Bank::open() { diff --git a/src/utils/Bank.h b/src/utils/Bank.h index 69719c530..d0e032c3f 100644 --- a/src/utils/Bank.h +++ b/src/utils/Bank.h @@ -77,7 +77,10 @@ class Bank { void clear_bank(); void remove_account(int account); // remove the content and the account + #ifdef MRCPP_HAS_MPI long long totcurrentsize = 0ll; // number of kB used by all accounts + long long maxsize = 0; // max total deposited data size (without containers) + #endif std::vector accounts; // open bank accounts std::map *> get_deposits; // gives deposits of an account std::map *> get_id2ix; @@ -85,7 +88,6 @@ class Bank { std::map *> get_queue; // gives deposits of an account std::map> *> get_readytasks; // used by task manager std::map currentsize; // total deposited data size (without containers) - long long maxsize = 0; // max total deposited data size (without containers) }; class BankAccount { diff --git a/src/utils/CompFunction.cpp b/src/utils/CompFunction.cpp index 306aebbf7..80009d9da 100644 --- a/src/utils/CompFunction.cpp +++ b/src/utils/CompFunction.cpp @@ -1517,7 +1517,6 @@ void rotate(CompFunctionVector &Phi, const ComplexMatrix &U, double prec) { void save_nodes(CompFunctionVector &Phi, FunctionTree<3> &refTree, BankAccount &account, int sizes) { int sizecoeff = (1 << refTree.getDim()) * refTree.getKp1_d(); int sizecoeffW = ((1 << refTree.getDim()) - 1) * refTree.getKp1_d(); - int max_nNodes = refTree.getNNodes(); std::vector coeffVec; std::vector coeffVec_cplx; std::vector scalefac; @@ -1594,7 +1593,6 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f // refine_grid(refTree, f); //to test mpi::allreduce_Tree_noCoeff(refTree, Phi, mpi::comm_wrk); - int kp1 = refTree.getKp1(); int kp1_d = refTree.getKp1_d(); int nCoefs = refTree.getTDim() * kp1_d; @@ -1688,7 +1686,7 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f // 3a) make values for f at this node // 3a1) get coordinates of quadrature points for this node Eigen::MatrixXd pts; // Eigen::Zero(D, nCoefs); - double fval[nCoefs]; + std::vector fval(nCoefs); Coord r; double *originalCoef = nullptr; MWNode<3> *Fnode = nullptr; @@ -1709,7 +1707,7 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f } else { originalCoef = Fnode->getCoefs(); for (int j = 0; j < nCoefs; j++) fval[j] = originalCoef[j]; - Fnode->attachCoefs(fval); // note that each thread has its own copy + Fnode->attachCoefs(fval.data()); // note that each thread has its own copy Fnode->mwTransform(Reconstruction); Fnode->cvTransform(Forward); } @@ -1755,8 +1753,6 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f } } else { // MPI - int count1 = 0; - int count2 = 0; TaskManager tasks(max_n); for (int nn = 0; nn < max_n; nn++) { int n = tasks.next_task(); @@ -1766,7 +1762,7 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f // 3a1) get coordinates of quadrature points for this node Eigen::MatrixXd pts; // Eigen::Zero(D, nCoefs); node.getExpandedChildPts(pts); // TODO: use getPrimitiveChildPts (less cache). - double fval[nCoefs]; + std::vector fval(nCoefs); Coord r; MWNode Fnode(*(refNodes[n]), false); if (Func == nullptr) { @@ -1776,17 +1772,15 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f } } else { int nIdx = Func->real().getIx(node.getNodeIndex()); - count1++; if (nIdx < 0) { // use the function f instead of Func - count2++; for (int j = 0; j < nCoefs; j++) { for (int d = 0; d < D; d++) r[d] = pts(d, j); fval[j] = f.evalf(r); } } else { - Func->real().getNodeCoeff(nIdx, fval); // fetch coef from Bank - Fnode.attachCoefs(fval); + Func->real().getNodeCoeff(nIdx, fval.data()); // fetch coef from Bank + Fnode.attachCoefs(fval.data()); Fnode.mwTransform(Reconstruction); Fnode.cvTransform(Forward); } @@ -1994,7 +1988,6 @@ ComplexMatrix calc_overlap_matrix_cplx(CompFunctionVector &BraKet) { } // 3) make dot product for all the nodes and accumulate into S - int ibank = 0; #pragma omp parallel if (serial) { ComplexMatrix S_omp = ComplexMatrix::Zero(N, N); // copy for each thread @@ -2143,7 +2136,6 @@ ComplexMatrix calc_overlap_matrix(CompFunctionVector &BraKet) { } // 3) make dot product for all the nodes and accumulate into S - int ibank = 0; #pragma omp parallel if (serial) { ComplexMatrix S_omp = ComplexMatrix::Zero(N, N); // copy for each thread @@ -2349,7 +2341,6 @@ ComplexMatrix calc_overlap_matrix_cplx(CompFunctionVector &Bra, CompFunctionVect int totsiz = 0; int totget = 0; int mxtotsiz = 0; - int ibank = 0; // the omp crashes sometime for unknown reasons? #pragma omp parallel if (serial) { @@ -2578,7 +2569,6 @@ ComplexMatrix calc_overlap_matrix(CompFunctionVector &Bra, CompFunctionVector &K int totsiz = 0; int totget = 0; int mxtotsiz = 0; - int ibank = 0; #pragma omp parallel if (serial) { DoubleMatrix S_omp = DoubleMatrix::Zero(N, M); // copy for each thread diff --git a/src/utils/tree_utils.cpp b/src/utils/tree_utils.cpp index 333544f6e..b01c03347 100644 --- a/src/utils/tree_utils.cpp +++ b/src/utils/tree_utils.cpp @@ -118,8 +118,8 @@ template void tree_utils::mw_transform(const MWTree &t int kp1_dm1 = math_utils::ipow(kp1, D - 1); const MWFilter &filter = tree.getMRA().getFilter(); double overwrite = 0.0; - T tmpcoeff[kp1_d * tDim]; - T tmpcoeff2[kp1_d * tDim]; + std::vector tmpcoeff(kp1_d * tDim); + std::vector tmpcoeff2(kp1_d * tDim); int ftlim = tDim; int ftlim2 = tDim; int ftlim3 = tDim; @@ -135,7 +135,7 @@ template void tree_utils::mw_transform(const MWTree &t int i = 0; int mask = 1; for (int gt = 0; gt < tDim; gt++) { - T *out = tmpcoeff + gt * kp1_d; + T *out = tmpcoeff.data() + gt * kp1_d; for (int ft = 0; ft < ftlim; ft++) { // Operate in direction i only if the bits along other // directions are identical. The bit of the direction we @@ -155,13 +155,13 @@ template void tree_utils::mw_transform(const MWTree &t i++; mask = 2; // 1 << i; for (int gt = 0; gt < tDim; gt++) { - T *out = tmpcoeff2 + gt * kp1_d; + T *out = tmpcoeff2.data() + gt * kp1_d; for (int ft = 0; ft < ftlim2; ft++) { // Operate in direction i only if the bits along other // directions are identical. The bit of the direction we // operate on determines the appropriate filter/operator if ((gt | mask) == (ft | mask)) { - T *in = tmpcoeff + ft * kp1_d; + T *in = tmpcoeff.data() + ft * kp1_d; int filter_index = 2 * ((gt >> i) & 1) + ((ft >> i) & 1); const Eigen::MatrixXd &oper = filter.getSubFilter(filter_index, operation); @@ -184,7 +184,7 @@ template void tree_utils::mw_transform(const MWTree &t // directions are identical. The bit of the direction we // operate on determines the appropriate filter/operator if ((gt | mask) == (ft | mask)) { - T *in = tmpcoeff2 + ft * kp1_d; + T *in = tmpcoeff2.data() + ft * kp1_d; int filter_index = 2 * ((gt >> i) & 1) + ((ft >> i) & 1); const Eigen::MatrixXd &oper = filter.getSubFilter(filter_index, operation); @@ -201,8 +201,8 @@ template void tree_utils::mw_transform(const MWTree &t if (D < 3) { T *out; - if (D == 1) out = tmpcoeff; - if (D == 2) out = tmpcoeff2; + if (D == 1) out = tmpcoeff.data(); + if (D == 2) out = tmpcoeff2.data(); if (b_overwrite) { for (int j = 0; j < tDim; j++) { for (int i = 0; i < kp1_d; i++) { coeff_out[i + j * stride] = out[i + j * kp1_d]; } @@ -234,7 +234,7 @@ template void tree_utils::mw_transform_back(MWTree<3, T> &tree, T * int kp1_dm1 = math_utils::ipow(kp1, 2); const MWFilter &filter = tree.getMRA().getFilter(); double overwrite = 0.0; - T tmpcoeff[kp1_d * tDim]; + std::vector tmpcoeff(kp1_d * tDim); int ftlim = tDim; int ftlim2 = tDim; @@ -262,7 +262,7 @@ template void tree_utils::mw_transform_back(MWTree<3, T> &tree, T * i++; mask = 2; // 1 << i; for (int gt = 0; gt < tDim; gt++) { - T *out = tmpcoeff + gt * kp1_d; + T *out = tmpcoeff.data() + gt * kp1_d; for (int ft = 0; ft < ftlim2; ft++) { // Operate in direction i only if the bits along other // directions are identical. The bit of the direction we @@ -288,7 +288,7 @@ template void tree_utils::mw_transform_back(MWTree<3, T> &tree, T * // directions are identical. The bit of the direction we // operate on determines the appropriate filter/operator if ((gt | mask) == (ft | mask)) { - T *in = tmpcoeff + ft * kp1_d; + T *in = tmpcoeff.data() + ft * kp1_d; int filter_index = 2 * ((gt >> i) & 1) + ((ft >> i) & 1); const Eigen::MatrixXd &oper = filter.getSubFilter(filter_index, operation); diff --git a/tests/factory_functions.h b/tests/factory_functions.h index d1c14a98f..571123263 100644 --- a/tests/factory_functions.h +++ b/tests/factory_functions.h @@ -129,7 +129,6 @@ void initialize(mrcpp::GaussFunc **func) { double beta = 1.0e4; double alpha = std::pow(beta / mrcpp::pi, D / 2.0); double pos_data[3] = {-0.2, 0.5, 1.0}; - const auto pow = std::array{}; auto pos = mrcpp::details::convert_to_std_array(pos_data); diff --git a/tests/functions/polynomial.cpp b/tests/functions/polynomial.cpp index 48b09cc51..e643d1639 100644 --- a/tests/functions/polynomial.cpp +++ b/tests/functions/polynomial.cpp @@ -223,7 +223,6 @@ SCENARIO("Polynomials can be added and multiplied", "[poly_arithmetics], [polyno Polynomial R; R = P * Q; THEN("The coefficients of R are known") { - VectorXd &cr = R.getCoefs(); REQUIRE(R.getCoefs()[0] == Catch::Approx(0.0)); REQUIRE(R.getCoefs()[1] == Catch::Approx(0.0)); REQUIRE(R.getCoefs()[2] == Catch::Approx(1.0)); diff --git a/tests/operators/helmholtz_operator.cpp b/tests/operators/helmholtz_operator.cpp index 8f570691d..ce669e27c 100644 --- a/tests/operators/helmholtz_operator.cpp +++ b/tests/operators/helmholtz_operator.cpp @@ -52,7 +52,6 @@ TEST_CASE("Helmholtz' kernel", "[init_helmholtz], [helmholtz_operator], [mw_oper const double exp_prec = 1.0e-4; const double proj_prec = 1.0e-3; const double ccc_prec = 1.0e-3; - const double band_prec = 1.0e-3; const int n = -3; const int k = 5; diff --git a/tests/operators/poisson_operator.cpp b/tests/operators/poisson_operator.cpp index 23bb22a06..e6ad04f69 100644 --- a/tests/operators/poisson_operator.cpp +++ b/tests/operators/poisson_operator.cpp @@ -50,7 +50,6 @@ TEST_CASE("Initialize Poisson operator", "[init_poisson], [poisson_operator], [m const double exp_prec = 1.0e-4; const double proj_prec = 1.0e-3; const double ccc_prec = 1.0e-3; - const double band_prec = 1.0e-3; const int n = -3; const int k = 5; @@ -161,7 +160,6 @@ TEST_CASE("Apply Periodic Poisson' operator", "[apply_periodic_Poisson], [poisso // 2.0*pi periodic in all dirs // UPDATE ME auto scaling_factor = std::array{pi, pi, pi}; - auto periodic = true; auto corner = std::array{-1, -1, -1}; auto boxes = std::array{2, 2, 2}; diff --git a/tests/treebuilders/map.cpp b/tests/treebuilders/map.cpp index 6be2153f0..64ced1e9c 100644 --- a/tests/treebuilders/map.cpp +++ b/tests/treebuilders/map.cpp @@ -80,7 +80,6 @@ template void testMapping() { const double ref_int = ref_tree.integrate(); const double ref_norm = ref_tree.getSquareNorm(); - const double inp_int = inp_tree.integrate(); const double inp_norm = inp_tree.getSquareNorm(); FMap fmap = [](double val) { return val * val; }; diff --git a/tests/trees/function_tree.cpp b/tests/trees/function_tree.cpp index d9492342e..0d7159a3d 100644 --- a/tests/trees/function_tree.cpp +++ b/tests/trees/function_tree.cpp @@ -69,8 +69,6 @@ SCENARIO("Generating FunctionTree nodes", "[function_tree_generating], [function } template void testGeneratedNodes() { - const int depth = 3; - Coord r; if (r.size() >= 1) r[0] = -0.3; if (r.size() >= 2) r[1] = 0.6; @@ -85,8 +83,6 @@ template void testGeneratedNodes() { THEN("there are no GenNodes") { REQUIRE(tree.getNGenNodes() == 0); } WHEN("a non-existing node is fetched") { - MWNode &node = tree.getNode(r, depth); - THEN("there will be allocated GenNodes") { REQUIRE(tree.getNGenNodes() > 0); diff --git a/tests/trees/node_index.cpp b/tests/trees/node_index.cpp index 791c94396..78d684a6c 100644 --- a/tests/trees/node_index.cpp +++ b/tests/trees/node_index.cpp @@ -72,7 +72,6 @@ template void testConstructors() { } SECTION("Parent constructor") { - int i = D; auto cIdx = nIdx->parent(); REQUIRE(cIdx.getScale() == (nIdx->getScale() - 1)); } From 1735bd3ae07f34f7915f1b7025972e6c80bcfeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=B6llmann?= Date: Mon, 5 Jan 2026 16:33:56 +0100 Subject: [PATCH 2/3] fixed failing tests --- src/treebuilders/ConvolutionCalculator.cpp | 2 +- src/treebuilders/DerivativeCalculator.cpp | 4 ++-- tests/trees/function_tree.cpp | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/treebuilders/ConvolutionCalculator.cpp b/src/treebuilders/ConvolutionCalculator.cpp index c9e7c5964..8cfcac1e6 100644 --- a/src/treebuilders/ConvolutionCalculator.cpp +++ b/src/treebuilders/ConvolutionCalculator.cpp @@ -228,7 +228,7 @@ template void ConvolutionCalculator::calcNode(MWNodeoper->getOperatorRoot(); if (manipulateOperator and this->oper->getOperatorRoot() < 0) o_depth = gNode.getDepth(); std::vector tmpCoefs(gNode.getNCoefs()); - OperatorState os(gNode, tmpCoefs); + OperatorState os(gNode, tmpCoefs.data()); this->operStat.incrementGNodeCounters(gNode); // Get all nodes in f within the bandwith of O in g diff --git a/src/treebuilders/DerivativeCalculator.cpp b/src/treebuilders/DerivativeCalculator.cpp index c59755c89..f4936c01d 100644 --- a/src/treebuilders/DerivativeCalculator.cpp +++ b/src/treebuilders/DerivativeCalculator.cpp @@ -91,7 +91,7 @@ template void DerivativeCalculator::calcNode(MWNode tmpCoefs(outNode.getNCoefs()); - OperatorState os(outNode, tmpCoefs); + OperatorState os(outNode, tmpCoefs.data()); os.setFNode(inpNode); os.setFIndex(inpNode.nodeIndex); @@ -117,7 +117,7 @@ template void DerivativeCalculator::calcNode(MWNode tmpCoefs(gNode.getNCoefs()); - OperatorState os(gNode, tmpCoefs); + OperatorState os(gNode, tmpCoefs.data()); this->operStat.incrementGNodeCounters(gNode); // Get all nodes in f within the bandwith of O in g diff --git a/tests/trees/function_tree.cpp b/tests/trees/function_tree.cpp index 0d7159a3d..99e5e709a 100644 --- a/tests/trees/function_tree.cpp +++ b/tests/trees/function_tree.cpp @@ -69,6 +69,7 @@ SCENARIO("Generating FunctionTree nodes", "[function_tree_generating], [function } template void testGeneratedNodes() { + unsigned int depth = 3; Coord r; if (r.size() >= 1) r[0] = -0.3; if (r.size() >= 2) r[1] = 0.6; @@ -83,6 +84,7 @@ template void testGeneratedNodes() { THEN("there are no GenNodes") { REQUIRE(tree.getNGenNodes() == 0); } WHEN("a non-existing node is fetched") { + MWNode &node = tree.getNode(r, depth); THEN("there will be allocated GenNodes") { REQUIRE(tree.getNGenNodes() > 0); @@ -91,6 +93,7 @@ template void testGeneratedNodes() { THEN("there will be no GenNodes") { REQUIRE(tree.getNGenNodes() == 0); } } } + (void)&node; // Clean up the fetched node } finalize(&mra); } From 294e0ca816eef7adcd4fb354d45f178957feca54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=B6llmann?= Date: Tue, 6 Jan 2026 16:16:33 +0100 Subject: [PATCH 3/3] included suggestion; fix for compiling mrchem+mrcpp on mac --- src/utils/Bank.cpp | 2 +- src/utils/CompFunction.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/Bank.cpp b/src/utils/Bank.cpp index 31fc1f869..94152c06e 100644 --- a/src/utils/Bank.cpp +++ b/src/utils/Bank.cpp @@ -8,8 +8,8 @@ namespace mrcpp { using namespace Eigen; using namespace std; -int metadata_block[3]; // can add more metadata in future #ifdef MRCPP_HAS_MPI + int metadata_block[3]; // can add more metadata in future int const size_metadata = 3; #endif diff --git a/src/utils/CompFunction.cpp b/src/utils/CompFunction.cpp index 80009d9da..250796c25 100644 --- a/src/utils/CompFunction.cpp +++ b/src/utils/CompFunction.cpp @@ -2719,6 +2719,7 @@ template ComplexDouble dot(CompFunction<3> bra, CompFunction<3> ket); template void project(CompFunction<3> &out, RepresentableFunction<3, double> &f, double prec); template void project(CompFunction<3> &out, RepresentableFunction<3, ComplexDouble> &f, double prec); template void multiply(CompFunction<3> &out, CompFunction<3> inp_a, CompFunction<3> inp_b, double prec, bool absPrec, bool useMaxNorms, bool conjugate); +template void multiply(double prec, CompFunction<3> &out, double coef, CompFunction<3> inp_a, CompFunction<3> inp_b, int maxIter = -1, bool absPrec = false, bool useMaxNorms = false, bool conjugate = false); template void multiply(CompFunction<3> &out, FunctionTree<3, double> &inp_a, RepresentableFunction<3, double> &f, double prec, int nrefine = 0, bool conjugate); template void multiply(CompFunction<3> &out, FunctionTree<3, ComplexDouble> &inp_a, RepresentableFunction<3, ComplexDouble> &f, double prec, int nrefine = 0, bool conjugate); template void multiply(CompFunction<3> &out, CompFunction<3> &inp_a, RepresentableFunction<3, double> &f, double prec, int nrefine = 0, bool conjugate);