From b09d4b8143d7eda458cd3cccf4f0af54e4d66272 Mon Sep 17 00:00:00 2001 From: Christoph Groth Date: Wed, 10 Jan 2018 17:15:59 +0100 Subject: no longer delete any intervals The maximum number of intervals is no longer limited. Arbitrarily deleting intervals introduced arbitrary inaccuracies and there's really no point. In typical cases the max_ivals=200 was not reached anyway and in pathological cases killing intervals is not a useful thing to do. When intervals become too narrow for further refinement they are no longer deleted but end up in self.attic. --- vquad/core.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/vquad/core.py b/vquad/core.py index 1866276..d7fcec4 100644 --- a/vquad/core.py +++ b/vquad/core.py @@ -1,4 +1,4 @@ -# Copyright 2017 Christoph Groth (CEA). +# Copyright 2017, 2018 Christoph Groth (CEA). # # This file is part of Vquad. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution. @@ -25,7 +25,6 @@ min_level = 1 max_level = 4 ndiv_max = 20 -max_ivals = 200 _sqrt_one_half = np.sqrt(0.5) @@ -124,7 +123,8 @@ class Vquad: ival.c00 = 0.0 # Will go away. ival.ndiv = 0 - self.ivals = [ival] + self.ivals = [ival] # Active intervals + self.attic = [] # Inactive intervals self.f = f self.nr_points = len(vals) self.igral_excess = 0 @@ -189,7 +189,7 @@ class Vquad: self.err_excess += self.ivals[i_max].err self.igral_excess += self.ivals[i_max].igral self.ivals[i_max] = self.ivals[-1] - self.ivals.pop() + self.attic.append(self.ivals.pop()) return if split: @@ -199,27 +199,14 @@ class Vquad: def totals(self): # Compute the total error and new max. i_max = 0 - i_min = 0 err = self.err_excess igral = self.igral_excess for i in range(len(self.ivals)): if self.ivals[i].err > self.ivals[i_max].err: i_max = i - elif self.ivals[i].err < self.ivals[i_min].err: - i_min = i err += self.ivals[i].err igral += self.ivals[i].igral - # If there are too many intervals, remove the one with smallest - # contribution to the error. - if len(self.ivals) > max_ivals: - self.err_excess += self.ivals[i_min].err - self.igral_excess += self.ivals[i_min].igral - self.ivals[i_min] = self.ivals[-1] - self.ivals.pop() - if i_max == len(self.ivals): - i_max = i_min - self.i_max = i_max return igral, err -- cgit v1.2.3-74-g4815