Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63897974
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
Thu, May 23, 05:54
Size
2 KB
Mime Type
text/x-python
Expires
Sat, May 25, 05:54 (2 d)
Engine
blob
Format
Raw Data
Handle
17832318
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
.kernel
import
(
radialGaussian
,
thinPlateSpline
,
multiQuadric
,
nearestNeighbor
)
from
rrompy.utilities.poly_fitting.polynomial.val
import
polyval
as
pvP
from
rrompy.utilities.base.types
import
Np1D
,
Np2D
,
paramList
from
rrompy.parameter
import
checkParameterList
from
rrompy.utilities.exception_manager
import
RROMPyException
__all__
=
[
'polyval'
]
def
polyval
(
x
:
paramList
,
cG
:
Np2D
,
cL
:
Np2D
,
supportPoints
:
paramList
,
directionalWeights
:
Np1D
,
basis
:
str
,
nNearestNeighbor
:
int
=
-
1
)
->
Np2D
:
x
=
checkParameterList
(
x
)[
0
]
basisp
,
basisr
=
basis
.
split
(
"_"
)
c
=
pvP
(
x
,
cG
,
basisp
)
try
:
radialvalbase
=
{
"GAUSSIAN"
:
radialGaussian
,
"THINPLATE"
:
thinPlateSpline
,
"MULTIQUADRIC"
:
multiQuadric
,
"NEARESTNEIGHBOR"
:
nearestNeighbor
}[
basisr
.
upper
()]
except
:
raise
RROMPyException
(
"Radial basis not recognized."
)
supportPoints
=
checkParameterList
(
supportPoints
)[
0
]
isnearestneighbor
=
basisr
.
upper
()
==
"NEARESTNEIGHBOR"
csh
=
copy
(
c
.
shape
)
if
len
(
csh
)
==
1
:
c
=
c
.
reshape
(
1
,
-
1
)
for
j
in
range
(
len
(
x
)):
muDiff
=
(
supportPoints
.
data
-
x
[
j
])
*
directionalWeights
r2j
=
np
.
sum
(
np
.
abs
(
muDiff
)
**
2.
,
axis
=
1
)
.
reshape
(
1
,
-
1
)
if
isnearestneighbor
:
if
nNearestNeighbor
>
0
and
nNearestNeighbor
<
len
(
supportPoints
):
cutoffValue
=
np
.
partition
(
r2j
,
nNearestNeighbor
-
1
)[
0
,
nNearestNeighbor
-
1
]
r2j
/=
cutoffValue
else
:
r2j
[
0
,
:]
=
1.
*
(
nNearestNeighbor
==
0
)
val
=
radialvalbase
(
r2j
)
.
dot
(
cL
)
try
:
c
[
...
,
j
]
+=
val
except
:
c
[
...
,
j
]
+=
val
.
flatten
()
if
len
(
csh
)
==
1
:
c
=
c
.
flatten
()
return
c
Event Timeline
Log In to Comment