From 03ad53bd75a5b3738ec64d856695a82521a02809 Mon Sep 17 00:00:00 2001 From: fbischoff Date: Wed, 27 Sep 2023 11:10:39 +0200 Subject: [PATCH] fixing compress for functions with only the root node --- src/madness/mra/mraimpl.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/madness/mra/mraimpl.h b/src/madness/mra/mraimpl.h index 283d060803b..54c4e19528b 100644 --- a/src/madness/mra/mraimpl.h +++ b/src/madness/mra/mraimpl.h @@ -3213,10 +3213,21 @@ template return woT::task(world.rank(),&implT::compress_op, key, v, nonstandard1); } else { - Future result(node.coeff()); - if (!keepleaves) node.clear_coeff(); - node.set_dnorm(0.0); - return result; + // special case: tree has only root node: keep sum coeffs and make zero diff coeffs + if (key.level()==0) { +// if (0) { + Future result(node.coeff()); + coeffT sdcoeff(cdata.v2k,this->get_tensor_type()); + sdcoeff(cdata.s0)+=node.coeff(); + node.coeff()=sdcoeff; + node.set_dnorm(0.0); + return result; + } else { + Future result(node.coeff()); + if (!keepleaves) node.clear_coeff(); + node.set_dnorm(0.0); + return result; + } } }