quadax 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {quadax-0.2.2/quadax.egg-info → quadax-0.2.4}/PKG-INFO +4 -4
- {quadax-0.2.2 → quadax-0.2.4}/README.rst +1 -1
- {quadax-0.2.2 → quadax-0.2.4}/quadax/_version.py +3 -3
- {quadax-0.2.2 → quadax-0.2.4}/quadax/adaptive.py +7 -5
- {quadax-0.2.2 → quadax-0.2.4}/quadax/fixed_order.py +1 -1
- {quadax-0.2.2 → quadax-0.2.4}/quadax/romberg.py +1 -1
- {quadax-0.2.2 → quadax-0.2.4/quadax.egg-info}/PKG-INFO +4 -4
- quadax-0.2.4/quadax.egg-info/requires.txt +3 -0
- quadax-0.2.4/requirements.txt +3 -0
- {quadax-0.2.2 → quadax-0.2.4}/tests/test_adaptive.py +37 -1
- quadax-0.2.2/quadax.egg-info/requires.txt +0 -3
- quadax-0.2.2/requirements.txt +0 -3
- {quadax-0.2.2 → quadax-0.2.4}/LICENSE +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/MANIFEST.in +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/pyproject.toml +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax/__init__.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax/quad_weights.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax/sampled.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax/utils.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax.egg-info/SOURCES.txt +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax.egg-info/dependency_links.txt +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/quadax.egg-info/top_level.txt +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/requirements-dev.txt +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/setup.cfg +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/setup.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/tests/test_derivatives.py +0 -0
- {quadax-0.2.2 → quadax-0.2.4}/tests/test_sampled.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: quadax
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Numerical quadrature with JAX
|
|
5
5
|
Home-page: https://github.com/f0uriest/quadax
|
|
6
6
|
Author: Rory Conlin
|
|
@@ -25,9 +25,9 @@ Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
|
25
25
|
Requires-Python: >=3.8
|
|
26
26
|
Description-Content-Type: text/x-rst
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist: equinox
|
|
28
|
+
Requires-Dist: equinox<0.12,>=0.11
|
|
29
29
|
Requires-Dist: jax<=0.5.0,>=0.3.2
|
|
30
|
-
Requires-Dist: numpy<2.
|
|
30
|
+
Requires-Dist: numpy<2.2,>=1.20.0
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
########
|
|
@@ -42,7 +42,7 @@ quadax is a library for numerical quadrature and integration using JAX.
|
|
|
42
42
|
- ``vmap``-able, ``jit``-able, differentiable.
|
|
43
43
|
- Scalar or vector valued integrands.
|
|
44
44
|
- Finite or infinite domains with discontinuities or singularities within the domain of integration.
|
|
45
|
-
- Globally adaptive Gauss-
|
|
45
|
+
- Globally adaptive Gauss-Kronrod and Clenshaw-Curtis quadrature for smooth integrands (similar to ``scipy.integrate.quad``)
|
|
46
46
|
- Adaptive tanh-sinh quadrature for singular or near singular integrands.
|
|
47
47
|
- Quadrature from sampled values using trapezoidal and Simpsons methods.
|
|
48
48
|
|
|
@@ -11,7 +11,7 @@ quadax is a library for numerical quadrature and integration using JAX.
|
|
|
11
11
|
- ``vmap``-able, ``jit``-able, differentiable.
|
|
12
12
|
- Scalar or vector valued integrands.
|
|
13
13
|
- Finite or infinite domains with discontinuities or singularities within the domain of integration.
|
|
14
|
-
- Globally adaptive Gauss-
|
|
14
|
+
- Globally adaptive Gauss-Kronrod and Clenshaw-Curtis quadrature for smooth integrands (similar to ``scipy.integrate.quad``)
|
|
15
15
|
- Adaptive tanh-sinh quadrature for singular or near singular integrands.
|
|
16
16
|
- Quadrature from sampled values using trapezoidal and Simpsons methods.
|
|
17
17
|
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-
|
|
11
|
+
"date": "2024-12-07T14:57:57-0500",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "0.2.
|
|
14
|
+
"full-revisionid": "75fbdd94dce98d54a6be302eb92bc7c94a8eaf60",
|
|
15
|
+
"version": "0.2.4"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -39,7 +39,7 @@ def quadgk(
|
|
|
39
39
|
order=21,
|
|
40
40
|
norm=jnp.inf,
|
|
41
41
|
):
|
|
42
|
-
"""Global adaptive quadrature using Gauss-
|
|
42
|
+
"""Global adaptive quadrature using Gauss-Kronrod rule.
|
|
43
43
|
|
|
44
44
|
Integrate fun from `interval[0]` to `interval[-1]` using a h-adaptive scheme with
|
|
45
45
|
error estimate. Breakpoints can be specified in `interval` where integration
|
|
@@ -422,19 +422,21 @@ def adaptive_quadrature(
|
|
|
422
422
|
epsrel = setdefault(epsrel, jnp.sqrt(jnp.finfo(jnp.array(1.0)).eps))
|
|
423
423
|
fun, interval = map_interval(fun, interval)
|
|
424
424
|
vfunc = wrap_func(fun, args)
|
|
425
|
-
f = jax.eval_shape(vfunc, (interval[0] + interval[-1] / 2)
|
|
425
|
+
f = jax.eval_shape(vfunc, (interval[0] + interval[-1]) / 2)
|
|
426
426
|
epmach = jnp.finfo(f.dtype).eps
|
|
427
427
|
shape = f.shape
|
|
428
428
|
|
|
429
429
|
state = {}
|
|
430
430
|
state["neval"] = 0 # number of evaluations of local quadrature rule
|
|
431
431
|
state["ninter"] = len(interval) - 1 # current number of intervals
|
|
432
|
-
state["r_arr"] = jnp.zeros(
|
|
432
|
+
state["r_arr"] = jnp.zeros(
|
|
433
|
+
(max_ninter, *shape), f.dtype
|
|
434
|
+
) # local results from each interval
|
|
433
435
|
state["e_arr"] = jnp.zeros(max_ninter) # local error est. from each interval
|
|
434
436
|
state["a_arr"] = jnp.zeros(max_ninter) # start of each interval
|
|
435
437
|
state["b_arr"] = jnp.zeros(max_ninter) # end of each interval
|
|
436
438
|
state["s_arr"] = jnp.zeros(
|
|
437
|
-
(max_ninter, *shape)
|
|
439
|
+
(max_ninter, *shape), f.dtype
|
|
438
440
|
) # global est. of I from n intervals
|
|
439
441
|
state["a_arr"] = state["a_arr"].at[: state["ninter"]].set(interval[:-1])
|
|
440
442
|
state["b_arr"] = state["b_arr"].at[: state["ninter"]].set(interval[1:])
|
|
@@ -442,7 +444,7 @@ def adaptive_quadrature(
|
|
|
442
444
|
state["roundoff2"] = 0 # for keeping track of roundoff errors
|
|
443
445
|
state["status"] = 0 # error flag
|
|
444
446
|
state["err_bnd"] = 0.0 # error bound we're trying to reach
|
|
445
|
-
state["area"] = jnp.zeros(shape) # current best estimate for I
|
|
447
|
+
state["area"] = jnp.zeros(shape, f.dtype) # current best estimate for I
|
|
446
448
|
state["err_sum"] = 0.0 # current estimate for error in I
|
|
447
449
|
|
|
448
450
|
def init_body(i, state_):
|
|
@@ -97,7 +97,7 @@ def romberg(
|
|
|
97
97
|
fun, interval = map_interval(fun, interval)
|
|
98
98
|
vfunc = wrap_func(fun, args)
|
|
99
99
|
a, b = interval
|
|
100
|
-
f = jax.eval_shape(vfunc, (a + b / 2)
|
|
100
|
+
f = jax.eval_shape(vfunc, (a + b) / 2)
|
|
101
101
|
|
|
102
102
|
result = jnp.zeros((divmax + 1, divmax + 1, *f.shape), f.dtype)
|
|
103
103
|
result = result.at[0, 0].set(vfunc(a) + vfunc(b))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: quadax
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Numerical quadrature with JAX
|
|
5
5
|
Home-page: https://github.com/f0uriest/quadax
|
|
6
6
|
Author: Rory Conlin
|
|
@@ -25,9 +25,9 @@ Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
|
25
25
|
Requires-Python: >=3.8
|
|
26
26
|
Description-Content-Type: text/x-rst
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist: equinox
|
|
28
|
+
Requires-Dist: equinox<0.12,>=0.11
|
|
29
29
|
Requires-Dist: jax<=0.5.0,>=0.3.2
|
|
30
|
-
Requires-Dist: numpy<2.
|
|
30
|
+
Requires-Dist: numpy<2.2,>=1.20.0
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
########
|
|
@@ -42,7 +42,7 @@ quadax is a library for numerical quadrature and integration using JAX.
|
|
|
42
42
|
- ``vmap``-able, ``jit``-able, differentiable.
|
|
43
43
|
- Scalar or vector valued integrands.
|
|
44
44
|
- Finite or infinite domains with discontinuities or singularities within the domain of integration.
|
|
45
|
-
- Globally adaptive Gauss-
|
|
45
|
+
- Globally adaptive Gauss-Kronrod and Clenshaw-Curtis quadrature for smooth integrands (similar to ``scipy.integrate.quad``)
|
|
46
46
|
- Adaptive tanh-sinh quadrature for singular or near singular integrands.
|
|
47
47
|
- Quadrature from sampled values using trapezoidal and Simpsons methods.
|
|
48
48
|
|
|
@@ -87,11 +87,17 @@ example_problems = [
|
|
|
87
87
|
"interval": [0, 1, 2],
|
|
88
88
|
"val": -4,
|
|
89
89
|
},
|
|
90
|
+
# problem 16 - complex function
|
|
91
|
+
{
|
|
92
|
+
"fun": lambda t: t * jnp.log(1 + t) * 1j,
|
|
93
|
+
"interval": [0, 1],
|
|
94
|
+
"val": 0.25j,
|
|
95
|
+
},
|
|
90
96
|
]
|
|
91
97
|
|
|
92
98
|
|
|
93
99
|
class TestQuadGK:
|
|
94
|
-
"""Tests for Gauss-
|
|
100
|
+
"""Tests for Gauss-Kronrod quadrature."""
|
|
95
101
|
|
|
96
102
|
def _base(self, i, tol, fudge=1, **kwargs):
|
|
97
103
|
prob = example_problems[i]
|
|
@@ -210,6 +216,12 @@ class TestQuadGK:
|
|
|
210
216
|
self._base(14, 1e-8)
|
|
211
217
|
self._base(14, 1e-12)
|
|
212
218
|
|
|
219
|
+
def test_prob16(self):
|
|
220
|
+
"""Test for example problem #16."""
|
|
221
|
+
self._base(16, 1e-4)
|
|
222
|
+
self._base(16, 1e-8)
|
|
223
|
+
self._base(16, 1e-12)
|
|
224
|
+
|
|
213
225
|
|
|
214
226
|
class TestQuadCC:
|
|
215
227
|
"""Tests for Clenshaw-Curtis quadrature."""
|
|
@@ -331,6 +343,12 @@ class TestQuadCC:
|
|
|
331
343
|
self._base(14, 1e-8)
|
|
332
344
|
self._base(14, 1e-12)
|
|
333
345
|
|
|
346
|
+
def test_prob16(self):
|
|
347
|
+
"""Test for example problem #16."""
|
|
348
|
+
self._base(16, 1e-4)
|
|
349
|
+
self._base(16, 1e-8)
|
|
350
|
+
self._base(16, 1e-12)
|
|
351
|
+
|
|
334
352
|
|
|
335
353
|
class TestQuadTS:
|
|
336
354
|
"""Tests for adaptive tanh-sinh quadrature."""
|
|
@@ -452,6 +470,12 @@ class TestQuadTS:
|
|
|
452
470
|
self._base(14, 1e-8)
|
|
453
471
|
self._base(14, 1e-12)
|
|
454
472
|
|
|
473
|
+
def test_prob16(self):
|
|
474
|
+
"""Test for example problem #16."""
|
|
475
|
+
self._base(16, 1e-4)
|
|
476
|
+
self._base(16, 1e-8)
|
|
477
|
+
self._base(16, 1e-12)
|
|
478
|
+
|
|
455
479
|
|
|
456
480
|
class TestRombergTS:
|
|
457
481
|
"""Tests for tanh-sinh quadrature with adaptive refinement."""
|
|
@@ -567,6 +591,12 @@ class TestRombergTS:
|
|
|
567
591
|
self._base(14, 1e-8)
|
|
568
592
|
self._base(14, 1e-12)
|
|
569
593
|
|
|
594
|
+
def test_prob16(self):
|
|
595
|
+
"""Test for example problem #16."""
|
|
596
|
+
self._base(16, 1e-4)
|
|
597
|
+
self._base(16, 1e-8)
|
|
598
|
+
self._base(16, 1e-12)
|
|
599
|
+
|
|
570
600
|
|
|
571
601
|
class TestRomberg:
|
|
572
602
|
"""Tests for Romberg's method (only for well behaved integrands)."""
|
|
@@ -670,3 +700,9 @@ class TestRomberg:
|
|
|
670
700
|
self._base(14, 1e-4)
|
|
671
701
|
self._base(14, 1e-8)
|
|
672
702
|
self._base(14, 1e-12)
|
|
703
|
+
|
|
704
|
+
def test_prob16(self):
|
|
705
|
+
"""Test for example problem #16."""
|
|
706
|
+
self._base(16, 1e-4)
|
|
707
|
+
self._base(16, 1e-8)
|
|
708
|
+
self._base(16, 1e-12)
|
quadax-0.2.2/requirements.txt
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|