Skip to content

Commit f81276d

Browse files
committed
refactor _initialize_alpha to accept singular values and right singular vectors as optional parameters
1 parent cdd8788 commit f81276d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pydmd/bopdmd.py

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

1354-
def _initialize_alpha(self, **kwargs):
1354+
def _initialize_alpha(self, s=None, V=None):
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.
1359+
If the singular values and right singular vectors are provided, they
1360+
will be used to compute the projection. Otherwise, the snapshot data
1361+
will be projected onto the projection basis.
13591362
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
1363+
:param s: the singular values of the snapshot matrix. If provided, they
1364+
will be used along with V to compute the projection.
1365+
:type s: numpy.ndarray
1366+
:param V: the right singular vectors of the snapshot matrix. If
1367+
provided, they will be used along with s to compute the projection.
1368+
:type V: numpy.ndarray
13631369
:return: Approximated eigenvalues of the matrix A.
13641370
:rtype: numpy.ndarray
13651371
"""
1366-
if "s" and "V" in kwargs:
1372+
if s is not None and V is not None:
13671373
# If the singular values and right singular vectors are provided,
13681374
# use them to compute the projection.
1369-
ux = np.diag(kwargs["s"]).dot(kwargs["V"])
1375+
ux = np.diag(s).dot(V)
13701376
else:
13711377
# Project the snapshot data onto the projection basis.
13721378
ux = self._proj_basis.conj().T.dot(self.snapshots)

0 commit comments

Comments
 (0)