Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61360657
val.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 6, 04:46
Size
2 KB
Mime Type
text/x-python
Expires
Wed, May 8, 04:46 (2 d)
Engine
blob
Format
Raw Data
Handle
17500994
Attached To
R6746 RationalROMPy
val.py
View Options
# 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.poly_fitting.polynomial
import
polyder
from
rrompy.utilities.base.types
import
Np1D
,
Np2D
,
List
,
paramList
,
radialFun
from
rrompy.parameter
import
checkParameterList
from
rrompy.utilities.exception_manager
import
RROMPyException
from
.base
import
splitpolybasis
from
.kernel
import
radialGaussian
,
thinPlateSpline
,
multiQuadric
__all__
=
[
'polyval'
]
def
polyval
(
x
:
paramList
,
c
:
radialFun
,
basis
:
str
,
m
:
List
[
int
]
=
None
,
scl
:
Np1D
=
None
)
->
Np2D
:
cFun
=
polyder
(
c
,
basis
,
m
=
m
,
scl
=
scl
)
c
=
cFun
.
globalCoeffs
x
,
_
=
checkParameterList
(
x
)
if
x
.
shape
[
1
]
>
c
.
ndim
:
raise
RROMPyException
(
"Incompatible parameter number."
)
basisp
,
basisr
=
splitpolybasis
(
basis
)
try
:
polyvalbase
=
{
"CHEBYSHEV"
:
np
.
polynomial
.
chebyshev
.
chebval
,
"LEGENDRE"
:
np
.
polynomial
.
legendre
.
legval
,
"MONOMIAL"
:
np
.
polynomial
.
polynomial
.
polyval
}[
basisp
.
upper
()]
except
:
raise
RROMPyException
(
"Polynomial basis not recognized."
)
try
:
radialvalbase
=
{
"GAUSSIAN"
:
radialGaussian
,
"THINPLATE"
:
thinPlateSpline
,
"MULTIQUADRIC"
:
multiQuadric
}[
basisr
.
upper
()]
except
:
raise
RROMPyException
(
"Radial basis not recognized."
)
c
=
polyvalbase
(
x
(
0
),
c
,
tensor
=
True
)
for
d
in
range
(
1
,
x
.
shape
[
1
]):
c
=
polyvalbase
(
x
(
d
),
c
,
tensor
=
False
)
print
(
c
.
shape
)
for
j
,
xp
in
enumerate
(
x
):
muDiff
=
cFun
.
supportPoints
-
xp
c
[
j
]
+=
radialvalbase
(
np
.
sum
(
np
.
abs
(
muDiff
)
**
2.
,
axis
=
1
))
.
dot
(
cFun
.
localCoeffs
)
return
c
Event Timeline
Log In to Comment