Page MenuHomec4science

homogeneization.py
No OneTemporary

File Metadata

Created
Fri, Feb 14, 09:50

homogeneization.py

# 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 rrompy.utilities.base.types import Np1D, Np2D, Tuple, List, paramList
from rrompy.utilities.poly_fitting.polynomial.homogeneization import (
homogeneizedpolyvander as hpvP)
from rrompy.utilities.exception_manager import RROMPyException
from .vander import heavisidevander
__all__ = ['homogeneizedpolyvander']
def homogeneizedpolyvander(x:paramList, poles:Np1D, deg : int = None,
basis : str = "MONOMIAL_HEAVISIDE",
derIdxs : List[List[List[int]]] = None,
reorder : List[int] = None, scl : Np1D = None)\
-> Tuple[Np2D, List[List[int]], List[int]]:
"""
Compute radial-basis-inclusive homogeneized Hermite-Vandermonde matrix with
specified derivative directions.
"""
if derIdxs is not None and np.sum(np.sum(derIdxs)) > 0:
raise RROMPyException(("Cannot take derivatives of radial basis "
"function."))
basisp = basis.split("_")[0]
VanR = heavisidevander(x, poles, reorder = reorder)
if deg is None or deg < 0:
VanP = np.empty((len(x), 0))
derIdxs, ordIdxs = np.zeros(0, dtype = int), np.zeros(0, dtype = int)
else:
VanP, derIdxs, ordIdxs = hpvP(x, deg, basisp, derIdxs = derIdxs,
reorder = reorder, scl = scl)
ordIdxsEff = np.concatenate((np.arange(len(VanR)), ordIdxs + len(VanR)))
return (np.block([[VanR, VanP],
[VanP.T.conj(), np.zeros(tuple([VanP.shape[1]] * 2))]]),
derIdxs, ordIdxsEff)

Event Timeline