Page MenuHomec4science

val.py
No OneTemporary

File Metadata

Created
Wed, May 1, 11:31
# 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.numerical import baseDistanceMatrix
from rrompy.utilities.base.types import Np1D, Np2D, paramList
from rrompy.parameter import checkParameterList
__all__ = ['polyval']
def polyval(x:paramList, cL:Np2D, supportPoints:paramList,
nNeighbors : int = 1, directionalWeights : Np1D = None) -> Np2D:
supportPoints = checkParameterList(supportPoints, return_data = True)
if directionalWeights is None:
directionalWeights = np.ones(supportPoints.shape[1])
npar = supportPoints.shape[1]
x = checkParameterList(x, npar, return_data = True)
muDiff = baseDistanceMatrix(supportPoints, x, weights = directionalWeights)
dist = (muDiff ** 2. + np.finfo(float).eps ** 2.) ** -.5
if len(dist) > nNeighbors:
iOut = np.argpartition(dist, - nNeighbors, axis = 0)[: - nNeighbors]
np.put_along_axis(dist, iOut, 0., 0)
dist /= np.linalg.norm(dist, axis = 0, ord = 1)
return np.moveaxis(np.tensordot(dist.T, cL, 1), 0, -1)

Event Timeline