Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62376098
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
Sun, May 12, 18:51
Size
2 KB
Mime Type
text/x-python
Expires
Tue, May 14, 18:51 (2 d)
Engine
blob
Format
Raw Data
Handle
17639699
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/>.
#
from
copy
import
deepcopy
as
copy
import
numpy
as
np
from
rrompy.utilities.base.types
import
Np1D
,
Np2D
,
List
,
paramList
,
radialFun
from
rrompy.parameter
import
checkParameterList
from
rrompy.utilities.exception_manager
import
RROMPyException
from
.der
import
polyder
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
=
basis
.
split
(
"_"
)
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
)
csh
=
copy
(
c
.
shape
)
if
len
(
csh
)
==
1
:
c
=
c
.
reshape
(
1
,
-
1
)
for
j
in
range
(
len
(
x
)):
muDiff
=
(
cFun
.
supportPoints
.
data
-
x
[
j
])
*
cFun
.
directionalWeights
r2j
=
np
.
sum
(
np
.
abs
(
muDiff
)
**
2.
,
axis
=
1
)
.
reshape
(
1
,
-
1
)
val
=
radialvalbase
(
r2j
)
.
dot
(
cFun
.
localCoeffs
)
try
:
c
[
...
,
j
]
+=
val
except
:
c
[
...
,
j
]
+=
val
.
flatten
()
if
len
(
csh
)
==
1
:
c
=
c
.
flatten
()
return
c
Event Timeline
Log In to Comment