Skip to content

Commit f6dd0f4

Browse files
committed
update _initialize_alpha to pass s and V as optional arguments
1 parent c1c37cf commit f6dd0f4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pydmd/bopdmd.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,17 +1351,25 @@ def _check_eig_constraints(self, eig_constraints):
13511351
msg = "Invalid eigenvalue constraint combination provided."
13521352
raise ValueError(msg)
13531353

1354-
def _initialize_alpha(self):
1354+
def _initialize_alpha(self, **kwargs):
13551355
"""
13561356
Uses projected trapezoidal rule to approximate the eigenvalues of A in
13571357
z' = Az.
13581358
The computed eigenvalues will serve as our initial guess for alpha.
13591359
1360+
:param kwargs: Optionally provide the singular values (s) and right
1361+
singular vectors (V) of the snapshot data to compute the projection.
1362+
:type kwargs: numpy.ndarray
13601363
:return: Approximated eigenvalues of the matrix A.
13611364
:rtype: numpy.ndarray
13621365
"""
1363-
# Project the snapshot data onto the projection basis.
1364-
ux = self._proj_basis.conj().T.dot(self.snapshots)
1366+
if "s" and "V" in kwargs:
1367+
# If the singular values and right singular vectors are provided,
1368+
# use them to compute the projection.
1369+
ux = np.diag(kwargs["s"]).dot(kwargs["V"])
1370+
else:
1371+
# Project the snapshot data onto the projection basis.
1372+
ux = self._proj_basis.conj().T.dot(self.snapshots)
13651373
ux1 = ux[:, :-1]
13661374
ux2 = ux[:, 1:]
13671375

0 commit comments

Comments
 (0)