Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60542613
vander.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, Apr 30, 23:47
Size
2 KB
Mime Type
text/x-python
Expires
Thu, May 2, 23:47 (2 d)
Engine
blob
Format
Raw Data
Handle
17370851
Attached To
R6746 RationalROMPy
vander.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.vander
import
polyvander
as
pvP
from
rrompy.utilities.base.types
import
Np1D
,
Np2D
,
List
,
paramList
from
rrompy.parameter
import
checkParameterList
from
rrompy.utilities.exception_manager
import
RROMPyException
__all__
=
[
'heavisidevander'
,
'polyvander'
]
def
heavisidevander
(
x
:
paramList
,
poles
:
Np1D
,
reorder
:
List
[
int
]
=
None
)
->
Np2D
:
"""Compute Heaviside-Vandermonde matrix."""
x
=
checkParameterList
(
x
,
1
)[
0
]
x_un
,
idx_un
=
x
.
unique
(
return_inverse
=
True
)
nx
=
len
(
x
)
if
len
(
x_un
)
<
nx
:
raise
RROMPyException
(
"Sample points must be distinct."
)
del
x_un
x
=
x
.
data
.
flatten
()
if
reorder
is
not
None
:
x
=
x
[
reorder
]
poles
=
poles
.
flatten
()
Van
=
np
.
empty
((
len
(
x
),
len
(
poles
)),
dtype
=
poles
.
dtype
)
for
j
in
range
(
len
(
x
)):
Van
[
j
,
:]
=
1.
/
(
x
[
j
]
-
poles
)
return
Van
def
polyvander
(
x
:
paramList
,
poles
:
Np1D
,
degs
:
List
[
int
]
=
None
,
basis
:
str
=
"MONOMIAL_HEAVISIDE"
,
derIdxs
:
List
[
List
[
List
[
int
]]]
=
None
,
reorder
:
List
[
int
]
=
None
,
scl
:
Np1D
=
None
)
->
Np2D
:
"""
Compute Heaviside-inclusive Hermite-Vandermonde matrix with specified
derivative directions.
"""
if
derIdxs
is
not
None
and
np
.
sum
(
np
.
sum
(
derIdxs
))
>
0
:
raise
RROMPyException
((
"Cannot take derivatives of heaviside "
"function."
))
basisp
=
basis
.
split
(
"_"
)[
0
]
VanH
=
heavisidevander
(
x
,
poles
,
reorder
=
reorder
)
if
degs
is
None
or
np
.
sum
(
degs
)
<
0
:
VanP
=
np
.
empty
((
len
(
x
),
0
))
else
:
VanP
=
pvP
(
x
,
degs
,
basisp
,
derIdxs
=
derIdxs
,
reorder
=
reorder
,
scl
=
scl
)
return
np
.
block
([[
VanH
,
VanP
]])
Event Timeline
Log In to Comment