Page MenuHomec4science

quadrature_points.py
No OneTemporary

File Metadata

Created
Sun, Dec 1, 00:43

quadrature_points.py

# Copyright (C) 2018-2020 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
from rrompy.utilities.base.types import Np1D
from rrompy.utilities.exception_manager import RROMPyException
__all__ = ['quadraturePointsGenerate']
def quadraturePointsGenerate(n:int, kind:str) -> Np1D:
kind = kind.upper()
if kind == "UNIFORM":
x = np.linspace(-1., 1., n)
elif kind[-9 :] == "CHEBYSHEV":
x = np.cos(np.pi * np.linspace(1. - .5 / n, .5 / n, n))
elif kind[-13 :] == "GAUSSLEGENDRE":
x = np.polynomial.legendre.leggauss(n)[0]
elif kind == "CLENSHAWCURTIS":
x = np.cos(np.pi * np.linspace(1., 0., n)) if n > 1 else np.zeros(n)
else:
raise RROMPyException("Quadrature kind not recognized.")
if n > 1 and kind[: 8] == "EXTENDED": x /= x[-1]
return x

Event Timeline