Page MenuHomec4science

val.py
No OneTemporary

File Metadata

Created
Tue, May 21, 17:03
# Copyright (C) 2018 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 .base import polybases
from .der import polyder
from rrompy.utilities.base.types import Np1D, Np2D, List, paramList
from rrompy.parameter import checkParameterList
from rrompy.utilities.exception_manager import RROMPyException
__all__ = ['polyval']
def polyval(x:paramList, c:Np2D, basis:str, m : List[int] = None,
scl : Np1D = None) -> Np2D:
c = polyder(c, basis, m = m, scl = scl)
x = checkParameterList(x)
if x.shape[1] > c.ndim:
raise RROMPyException("Incompatible parameter number.")
if basis.upper() not in polybases:
raise RROMPyException("Polynomial basis not recognized.")
polyvalbase = {"CHEBYSHEV" : np.polynomial.chebyshev.chebval,
"LEGENDRE" : np.polynomial.legendre.legval,
"MONOMIAL" : np.polynomial.polynomial.polyval
}[basis.upper()]
c = polyvalbase(x(0), c, tensor = True)
for d in range(1, x.shape[1]):
c = polyvalbase(x(d), c, tensor = False)
return c

Event Timeline