Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63662977
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
Tue, May 21, 17:03
Size
1 KB
Mime Type
text/x-python
Expires
Thu, May 23, 17:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17803230
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
.base
import
polybases
from
.der
import
polyder
from
rrompy.utilities.base.types
import
Np1D
,
Np2D
,
List
,
paramList
from
rrompy.parameter
import
checkParameterList
from
rrompy.utilities.exception_manager
import
RROMPyException
__all__
=
[
'polyval'
]
def
polyval
(
x
:
paramList
,
c
:
Np2D
,
basis
:
str
,
m
:
List
[
int
]
=
None
,
scl
:
Np1D
=
None
)
->
Np2D
:
c
=
polyder
(
c
,
basis
,
m
=
m
,
scl
=
scl
)
x
=
checkParameterList
(
x
)
if
x
.
shape
[
1
]
>
c
.
ndim
:
raise
RROMPyException
(
"Incompatible parameter number."
)
if
basis
.
upper
()
not
in
polybases
:
raise
RROMPyException
(
"Polynomial basis not recognized."
)
polyvalbase
=
{
"CHEBYSHEV"
:
np
.
polynomial
.
chebyshev
.
chebval
,
"LEGENDRE"
:
np
.
polynomial
.
legendre
.
legval
,
"MONOMIAL"
:
np
.
polynomial
.
polynomial
.
polyval
}[
basis
.
upper
()]
c
=
polyvalbase
(
x
(
0
),
c
,
tensor
=
True
)
for
d
in
range
(
1
,
x
.
shape
[
1
]):
c
=
polyvalbase
(
x
(
d
),
c
,
tensor
=
False
)
return
c
Event Timeline
Log In to Comment