From 47058eb41ed447057222d3d1145046f053407ec1 Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 19:46:20 +0800 Subject: [PATCH 1/7] Add Gauss-Legendre and Chebyshev-Gauss quadurature --- modepy/__init__.py | 3 +-- modepy/quadrature/jacobi_gauss.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index 72ee409..c2587b9 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -34,8 +34,7 @@ from modepy.matrices import (vandermonde, inverse_mass_matrix, mass_matrix, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable -from modepy.quadrature.jacobi_gauss import ( - JacobiGaussQuadrature, LegendreGaussQuadrature) +from modepy.quadrature.jacobi_gauss import JacobiGaussQuadrature from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadrature diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index ab268e1..115a28b 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -118,18 +118,22 @@ class JacobiGaussQuadrature(Quadrature): return nodes, weights -class LegendreGaussQuadrature(JacobiGaussQuadrature): - """An Gauss quadrature associated with weight 1. +class GaussLegendreQuadrature(JacobiGaussQuadrature): + """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature + with α = β = 0.5. + """ - Integrates on the interval (-1,1). - The quadrature rule is exact up to degree :math:`2N+1`. + def __init__(self, N): # noqa + JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) - Inherits from :class:`modepy.Quadrature`. See there for the interface - to obtain nodes and weights. + +class ChebyshevGaussQuadrature(JacobiGaussQuadrature): + """Chebyshev-Gauss quadrature is a special case of Gauss–Jacobi quadrature + with α = β = 1. """ def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 0, 0, N) + JacobiGaussQuadrature.__init__(self, 1, 1, N) def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa -- GitLab From 798ab9421ddf7292c48d5ca59ec2cb819cd6e0ac Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 19:54:31 +0800 Subject: [PATCH 2/7] Add Gauss-Gengenbauer quadrature --- modepy/__init__.py | 4 +++- modepy/quadrature/jacobi_gauss.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index c2587b9..8417bd1 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -34,7 +34,9 @@ from modepy.matrices import (vandermonde, inverse_mass_matrix, mass_matrix, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable -from modepy.quadrature.jacobi_gauss import JacobiGaussQuadrature +from modepy.quadrature.jacobi_gauss import ( + JacobiGaussQuadrature, GaussLegendreQuadrature, ChebyshevGaussQuadrature, + GaussGegenbauerQuadrature) from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadrature diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 115a28b..63add78 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -136,6 +136,15 @@ class ChebyshevGaussQuadrature(JacobiGaussQuadrature): JacobiGaussQuadrature.__init__(self, 1, 1, N) +class GaussGegenbauerQuadrature(JacobiGaussQuadrature): + """Gauss-Gegenbauer quadrature is a special case of Gauss–Jacobi quadrature + with α = β. + """ + + def __init__(self, alpha, N): # noqa + JacobiGaussQuadrature.__init__(self, alpha, alpha, N) + + def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa """Compute the Gauss-Lobatto quadrature nodes corresponding to the :class:`JacobiGaussQuadrature` -- GitLab From ad78f308f10a5cbdf10b9331574ac9c478d96414 Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 21:29:09 +0800 Subject: [PATCH 3/7] Bug fixes --- modepy/quadrature/jacobi_gauss.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 63add78..613804a 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -120,20 +120,24 @@ class JacobiGaussQuadrature(Quadrature): class GaussLegendreQuadrature(JacobiGaussQuadrature): """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 0.5. + with α = β = 0. """ def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) + JacobiGaussQuadrature.__init__(self, 0, 0, N) class ChebyshevGaussQuadrature(JacobiGaussQuadrature): - """Chebyshev-Gauss quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 1. + """Chebyshev-Gauss quadrature of the first/second kind are special cases + of Gauss–Jacobi quadrature with α = β = -0.5/0.5. """ - def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 1, 1, N) + def __init__(self, N, kind=1): # noqa + if kind == 1: + # FIXME: division by zero + JacobiGaussQuadrature.__init__(self, -0.5, -0.5, N) + elif kind == 2: + JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) class GaussGegenbauerQuadrature(JacobiGaussQuadrature): -- GitLab From 735e85cf01c0fcec0146e0a70a8255e27581d61e Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 20:58:58 -0600 Subject: [PATCH 4/7] Fix module interface --- modepy/__init__.py | 5 ++++- modepy/quadrature/jacobi_gauss.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index 8417bd1..02c7298 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -35,7 +35,7 @@ from modepy.matrices import (vandermonde, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable from modepy.quadrature.jacobi_gauss import ( - JacobiGaussQuadrature, GaussLegendreQuadrature, ChebyshevGaussQuadrature, + JacobiGaussQuadrature, LegendreGaussQuadrature, ChebyshevGaussQuadrature, GaussGegenbauerQuadrature) from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature @@ -43,6 +43,8 @@ from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadratur from modepy.version import VERSION_TEXT as __version__ # noqa: N811 +GaussLegendreQuadrature = LegendreGaussQuadrature + __all__ = [ "__version__", @@ -60,6 +62,7 @@ __all__ = [ "Quadrature", "QuadratureRuleUnavailable", "JacobiGaussQuadrature", "LegendreGaussQuadrature", + "GaussLegendreQuadrature", "ChebyshevGaussQuadrature", "XiaoGimbutasSimplexQuadrature", "GrundmannMoellerSimplexQuadrature", "VioreanuRokhlinSimplexQuadrature", ] diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 613804a..c04aa02 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -118,7 +118,7 @@ class JacobiGaussQuadrature(Quadrature): return nodes, weights -class GaussLegendreQuadrature(JacobiGaussQuadrature): +class LegendreGaussQuadrature(JacobiGaussQuadrature): """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature with α = β = 0. """ -- GitLab From a14b550ba46f926ac2fa1f851b564dfa6bc2bebf Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 21:12:41 -0600 Subject: [PATCH 5/7] Add back mis-removed docstring --- modepy/quadrature/jacobi_gauss.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index c04aa02..f5bc4d2 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -119,8 +119,16 @@ class JacobiGaussQuadrature(Quadrature): class LegendreGaussQuadrature(JacobiGaussQuadrature): - """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 0. + """An Gauss quadrature associated with weight 1. + + Integrates on the interval (-1,1). + The quadrature rule is exact up to degree :math:`2N+1`. + + Inherits from :class:`modepy.Quadrature`. See there for the interface + to obtain nodes and weights. + + (NOTE: Gauss–Legendre quadrature is a special case of Gauss–Jacobi + quadrature with α = β = 0.) """ def __init__(self, N): # noqa -- GitLab From d0771055b030054c0fa20b761f503cd3d379cd30 Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 23:21:44 -0600 Subject: [PATCH 6/7] Document new quad rules --- doc/quadrature.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/quadrature.rst b/doc/quadrature.rst index 95d406c..4200ff0 100644 --- a/doc/quadrature.rst +++ b/doc/quadrature.rst @@ -25,6 +25,10 @@ Jacobi-Gauss quadrature in one dimension .. autoclass:: LegendreGaussQuadrature +.. autoclass:: ChebyshevGaussQuadrature + +.. autoclass:: GaussGegenbauerQuadrature + .. currentmodule:: modepy.quadrature.jacobi_gauss .. autofunction:: jacobi_gauss_lobatto_nodes -- GitLab From 3c46ed7a7922f8bb5aac993b4b2634da4ee257c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Sun, 27 Jan 2019 20:54:11 +0100 Subject: [PATCH 7/7] Add versionadded markers to new Gauss shortcuts --- modepy/quadrature/jacobi_gauss.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index f5bc4d2..4e7ac83 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -138,6 +138,8 @@ class LegendreGaussQuadrature(JacobiGaussQuadrature): class ChebyshevGaussQuadrature(JacobiGaussQuadrature): """Chebyshev-Gauss quadrature of the first/second kind are special cases of Gauss–Jacobi quadrature with α = β = -0.5/0.5. + + .. versionadded:: 2019.1 """ def __init__(self, N, kind=1): # noqa @@ -151,6 +153,8 @@ class ChebyshevGaussQuadrature(JacobiGaussQuadrature): class GaussGegenbauerQuadrature(JacobiGaussQuadrature): """Gauss-Gegenbauer quadrature is a special case of Gauss–Jacobi quadrature with α = β. + + .. versionadded:: 2019.1 """ def __init__(self, alpha, N): # noqa -- GitLab