Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86847795
reduced_basis_utils.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, Oct 8, 23:15
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Oct 10, 23:15 (2 d)
Engine
blob
Format
Raw Data
Handle
21456448
Attached To
R6746 RationalROMPy
reduced_basis_utils.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.base.types
import
(
Np1D
,
Np2D
,
Tuple
,
List
,
ListAny
,
sampList
)
from
rrompy.utilities.numerical
import
hashIdxToDerivative
as
hashI
,
dot
from
rrompy.utilities.exception_manager
import
RROMPyAssert
from
rrompy.sampling
import
sampleList
__all__
=
[
'projectAffineDecomposition'
]
def
projectAffineDecomposition
(
As
:
List
[
Np2D
],
bs
:
List
[
Np1D
],
pMat
:
sampList
,
ARBsOld
:
List
[
Np2D
]
=
None
,
bRBsOld
:
List
[
Np1D
]
=
None
,
pMatOld
:
sampList
=
None
)
\
->
Tuple
[
List
[
Np2D
],
List
[
Np1D
]]:
"""Project affine decomposition of linear system onto basis."""
RROMPyAssert
((
ARBsOld
is
None
,
bRBsOld
is
None
),
(
pMatOld
is
None
,
pMatOld
is
None
),
"Old affine projected terms"
)
if
isinstance
(
pMat
,
(
sampleList
,)):
pMat
=
pMat
.
data
pMatC
=
pMat
.
conj
()
ARBs
=
[
None
]
*
len
(
As
)
bRBs
=
[
None
]
*
len
(
bs
)
if
pMatOld
is
None
:
for
j
in
range
(
max
(
len
(
As
),
len
(
bs
))):
if
j
<
len
(
As
):
ARBs
[
j
]
=
dot
(
dot
(
As
[
j
],
pMat
)
.
T
,
pMatC
)
.
T
if
j
<
len
(
bs
):
bRBs
[
j
]
=
dot
(
pMatC
.
T
,
bs
[
j
])
else
:
RROMPyAssert
((
len
(
ARBsOld
),
len
(
bRBsOld
)),
(
len
(
As
),
len
(
bs
)),
"Old affine projected terms"
)
if
isinstance
(
pMatOld
,
(
sampleList
,)):
pMatOld
=
pMatOld
.
data
pMatOldC
=
pMatOld
.
conj
()
Sold
=
pMatOld
.
shape
[
1
]
Snew
=
pMat
.
shape
[
1
]
for
j
in
range
(
max
(
len
(
As
),
len
(
bs
))):
if
j
<
len
(
As
):
ARBs
[
j
]
=
np
.
empty
((
Sold
+
Snew
,
Sold
+
Snew
),
dtype
=
ARBsOld
[
j
]
.
dtype
)
ARBs
[
j
][:
Sold
,
:
Sold
]
=
ARBsOld
[
j
]
ARBs
[
j
][:
Sold
,
Sold
:]
=
dot
(
dot
(
As
[
j
],
pMat
)
.
T
,
pMatOldC
)
.
T
ARBs
[
j
][
Sold
:,
:
Sold
]
=
dot
(
dot
(
As
[
j
],
pMatOld
)
.
T
,
pMatC
)
.
T
ARBs
[
j
][
Sold
:,
Sold
:]
=
dot
(
dot
(
As
[
j
],
pMat
)
.
T
,
pMatC
)
.
T
if
j
<
len
(
bs
):
bRBs
[
j
]
=
np
.
empty
((
Sold
+
Snew
),
dtype
=
bRBsOld
[
j
]
.
dtype
)
bRBs
[
j
][:
Sold
]
=
bRBsOld
[
j
]
bRBs
[
j
][
Sold
:]
=
dot
(
pMatC
.
T
,
bs
[
j
])
return
ARBs
,
bRBs
Event Timeline
Log In to Comment