fbdmd.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:PyDMD 作者: mathLab 项目源码 文件源码
def fit(self, X):
        """
        Compute the Dynamics Modes Decomposition to the input data.

        :param X: the input snapshots.
        :type X: numpy.ndarray or iterable
        """
        self._snapshots, self._snapshots_shape = self._col_major_2darray(X)

        n_samples = self._snapshots.shape[1]
        X = self._snapshots[:, :-1]
        Y = self._snapshots[:, 1:]

        X, Y = self._compute_tlsq(X, Y, self.tlsq_rank)

        Uy, sy, Vy = self._compute_svd(Y, self.svd_rank)
        Ux, sx, Vx = self._compute_svd(X, self.svd_rank)

        if len(sy) != len(sx):
            raise ValueError(
                'The optimal truncation produced different number of singular'
                'values for the X and Y matrix, please specify different'
                'svd_rank'
            )

        # Backward operator
        bAtilde = self._build_lowrank_op(Uy, sy, Vy, X)
        # Forward operator
        fAtilde = self._build_lowrank_op(Ux, sx, Vx, Y)

        self._Atilde = sqrtm(fAtilde.dot(np.linalg.inv(bAtilde)))

        self._eigs, self._modes = self._eig_from_lowrank_op(
            self._Atilde, Y, Ux, sx, Vx, self.exact
        )

        self._b = self._compute_amplitudes(
            self._modes, self._snapshots, self._eigs, self.opt
        )

        self.original_time = {'t0': 0, 'tend': n_samples - 1, 'dt': 1}
        self.dmd_time = {'t0': 0, 'tend': n_samples - 1, 'dt': 1}

        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号