Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85934975
sampling_engine_linear_pod.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, Oct 3, 04:01
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Oct 5, 04:01 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
21303174
Attached To
R6746 RationalROMPy
sampling_engine_linear_pod.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.sampling.base.pod_engine
import
PODEngine
from
.sampling_engine_linear
import
SamplingEngineLinear
from
rrompy.utilities.base.types
import
Np1D
,
paramVal
,
sampList
from
rrompy.utilities.base
import
verbosityDepth
__all__
=
[
'SamplingEngineLinearPOD'
]
class
SamplingEngineLinearPOD
(
SamplingEngineLinear
):
"""HERE"""
def
resetHistory
(
self
):
super
()
.
resetHistory
()
self
.
RPOD
=
None
def
popSample
(
self
):
if
hasattr
(
self
,
"nsamples"
)
and
self
.
nsamples
>
1
:
self
.
RPOD
=
self
.
RPOD
[:
-
1
,
:
-
1
]
super
()
.
popSample
()
@property
def
HFEngine
(
self
):
"""Value of HFEngine. Its assignment resets history."""
return
self
.
_HFEngine
@HFEngine.setter
def
HFEngine
(
self
,
HFEngine
):
self
.
_HFEngine
=
HFEngine
self
.
resetHistory
()
self
.
PODEngine
=
PODEngine
(
self
.
_HFEngine
)
def
preprocesssamples
(
self
,
idxs
:
Np1D
)
->
sampList
:
idxMax
=
np
.
max
(
idxs
)
+
1
sampleBase
=
super
()
.
preprocesssamples
(
np
.
arange
(
idxMax
))
##### maybe square brackets should be used below...
RPODBase
=
self
.
RPOD
[:
idxMax
,
idxs
]
return
sampleBase
.
dot
(
RPODBase
)
def
postprocessu
(
self
,
u
:
sampList
,
overwrite
:
bool
=
False
)
->
Np1D
:
if
self
.
verbosity
>=
10
:
verbosityDepth
(
"INIT"
,
"Starting orthogonalization."
,
timestamp
=
self
.
timestamp
)
ns
=
self
.
nsamples
if
ns
==
0
:
u
,
r
,
_
=
self
.
PODEngine
.
GS
(
u
,
np
.
empty
((
0
,
0
)))
r
=
r
[
0
]
else
:
u
,
r
,
_
=
self
.
PODEngine
.
GS
(
u
,
self
.
samples
(
np
.
arange
(
ns
)),
ns
)
if
overwrite
:
self
.
RPOD
[:
ns
+
1
,
ns
]
=
r
else
:
if
ns
==
0
:
self
.
RPOD
=
r
.
reshape
((
1
,
1
))
else
:
self
.
RPOD
=
np
.
block
([[
self
.
RPOD
,
r
[:
-
1
,
None
]],
[
np
.
zeros
((
1
,
ns
)),
r
[
-
1
]]])
if
self
.
verbosity
>=
10
:
verbosityDepth
(
"DEL"
,
"Done orthogonalizing."
,
timestamp
=
self
.
timestamp
)
return
u
def
preallocateSamples
(
self
,
u
:
Np1D
,
mu
:
paramVal
,
n
:
int
):
super
()
.
preallocateSamples
(
u
,
mu
,
n
)
r
=
self
.
RPOD
self
.
RPOD
=
np
.
zeros
((
n
,
n
),
dtype
=
u
.
dtype
)
self
.
RPOD
[
0
,
0
]
=
r
[
0
,
0
]
Event Timeline
Log In to Comment