Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102175935
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, Feb 17, 21:48
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Feb 19, 21:48 (2 d)
Engine
blob
Format
Raw Data
Handle
24269320
Attached To
R6746 RationalROMPy
val.py
View Options
# 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
Log In to Comment