@@ -1461,6 +1461,55 @@ def fit(self, X, t):
14611461
14621462 return self
14631463
1464+ def fit_econ (self , U , s , V , t ):
1465+ """
1466+ Compute the Optimized Dynamic Mode Decomposition using the
1467+ SVD results of the snapshot matrix.
1468+ Use this method if you have pre-computed the SVD and the
1469+ original snapshot matrix is not avaialble or too large to
1470+ store in memory.
1471+
1472+ :param U: the left singular vectors.
1473+ :type U: numpy.ndarray
1474+ :param s: the singular values.
1475+ :type s: numpy.ndarray
1476+ :param V: the right singular vectors.
1477+ :type V: numpy.ndarray
1478+ :param t: the input time vector.
1479+ :type t: numpy.ndarray
1480+ """
1481+ self ._reset ()
1482+ self ._time = np .array (t ).squeeze ()
1483+
1484+ # Check that input time vector is one-dimensional.
1485+ if self ._time .ndim > 1 :
1486+ msg = "Input time vector t must be one-dimensional."
1487+ raise ValueError (msg )
1488+
1489+ # Check that U is a 2D numpy.ndarray.
1490+ if not isinstance (U , np .ndarray ) or U .ndim != 2 :
1491+ msg = "U must be a 2D numpy.ndarray."
1492+ raise ValueError (msg )
1493+
1494+ # Check that s is a 1D numpy.ndarray.
1495+ if not isinstance (s , np .ndarray ) or s .ndim != 1 or len (s ) != U .shape [1 ]:
1496+ msg = "s must be a 1D numpy.ndarray with length equal to the number of columns in U."
1497+ raise ValueError (msg )
1498+
1499+ # Check that V is a 2D numpy.ndarray.
1500+ if (
1501+ not isinstance (V , np .ndarray )
1502+ or V .ndim != 2
1503+ or V .shape [0 ] != U .shape [1 ]
1504+ or V .shape [1 ] != len (self ._time )
1505+ ):
1506+ msg = """
1507+ V must be a 2D numpy.ndarray with the same number of rows
1508+ as U has columns and the same number of columns as the length
1509+ of the time vector t.
1510+ """
1511+ raise ValueError (msg )
1512+
14641513 def forecast (self , t ):
14651514 """
14661515 Predict the output X given the input time t using the fitted DMD model.
0 commit comments