aboutsummaryrefslogtreecommitdiff
path: root/vquad/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'vquad/core.py')
-rw-r--r--vquad/core.py21
1 files 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