Esempio n. 1
0
    def test_proj_lyap_smw_transposeflag(self):
        """check the solution of the projected lyap eqn

        via ADI iteration"""

        U = self.U
        V = self.V

        Z = pru.solve_proj_lyap_stein(amat=self.F, mmat=self.M,
                                      umat=U, vmat=V,
                                      jmat=self.J, wmat=self.W,
                                      adi_dict=self.nwtn_adi_dict)['zfac']

        Z2 = pru.solve_proj_lyap_stein(amat=self.F - self.uvs, mmat=self.M,
                                       jmat=self.J, wmat=self.W,
                                       adi_dict=self.nwtn_adi_dict)['zfac']

        Z3 = pru.solve_proj_lyap_stein(amat=self.F.T-self.uvs.T, mmat=self.M.T,
                                       jmat=self.J, wmat=self.W,
                                       adi_dict=self.nwtn_adi_dict,
                                       transposed=True)['zfac']

        Z4 = pru.solve_proj_lyap_stein(amat=self.F.T, mmat=self.M.T,
                                       jmat=self.J, wmat=self.W,
                                       umat=U, vmat=V,
                                       adi_dict=self.nwtn_adi_dict,
                                       transposed=True)['zfac']

# TEST: {smw} x {transposed}
        self.assertTrue(np.allclose(Z, Z2))
        self.assertTrue(np.allclose(Z2, Z3))
        self.assertTrue(np.allclose(Z3, Z4))
        self.assertTrue(np.allclose(Z, Z4))
Esempio n. 2
0
    def test_proj_lyap_sol(self):
        """check the solution of the projected lyap eqn

        via ADI iteration"""

        Z = pru.solve_proj_lyap_stein(amat=self.F, mmat=self.M,
                                      umat=self.U, vmat=self.V,
                                      jmat=self.J, wmat=self.W,
                                      adi_dict=self.nwtn_adi_dict)['zfac']

        MtXM = self.M.T * np.dot(Z, Z.T) * self.M
        FtXM = (self.F.T - self.uvs.T) * np.dot(Z, Z.T) * self.M

        PtW = np.dot(self.P.T, self.W)

        ProjRes = np.dot(self.P.T, np.dot(FtXM, self.P)) + \
            np.dot(np.dot(self.P.T, FtXM.T), self.P) + \
            np.dot(PtW, PtW.T)

# TEST: result is 'projected'
        self.assertTrue(np.allclose(MtXM,
                                    np.dot(self.P.T, np.dot(MtXM, self.P))))

# TEST: check projected residual
        self.assertTrue(np.linalg.norm(ProjRes) / np.linalg.norm(MtXM)
                        < 1e-8)
Esempio n. 3
0
    def test_proj_lyap_sol(self):
        """check the solution of the projected lyap eqn

        via ADI iteration"""

        Z = pru.solve_proj_lyap_stein(amat=self.F,
                                      mmat=self.M,
                                      umat=self.U,
                                      vmat=self.V,
                                      jmat=self.J,
                                      wmat=self.W,
                                      adi_dict=self.nwtn_adi_dict)['zfac']

        MtXM = self.M.T * np.dot(Z, Z.T) * self.M
        FtXM = (self.F.T - self.uvs.T) * np.dot(Z, Z.T) * self.M

        PtW = np.dot(self.P.T, self.W)

        ProjRes = np.dot(self.P.T, np.dot(FtXM, self.P)) + \
            np.dot(np.dot(self.P.T, FtXM.T), self.P) + \
            np.dot(PtW, PtW.T)

        # TEST: result is 'projected'
        self.assertTrue(
            np.allclose(MtXM, np.dot(self.P.T, np.dot(MtXM, self.P))))

        # TEST: check projected residual
        self.assertTrue(np.linalg.norm(ProjRes) / np.linalg.norm(MtXM) < 1e-8)
Esempio n. 4
0
    def test_proj_lyap_smw_transposeflag(self):
        """check the solution of the projected lyap eqn

        via ADI iteration"""

        U = self.U
        V = self.V

        Z = pru.solve_proj_lyap_stein(amat=self.F,
                                      mmat=self.M,
                                      umat=U,
                                      vmat=V,
                                      jmat=self.J,
                                      wmat=self.W,
                                      adi_dict=self.nwtn_adi_dict)['zfac']

        Z2 = pru.solve_proj_lyap_stein(amat=self.F - self.uvs,
                                       mmat=self.M,
                                       jmat=self.J,
                                       wmat=self.W,
                                       adi_dict=self.nwtn_adi_dict)['zfac']

        Z3 = pru.solve_proj_lyap_stein(amat=self.F.T - self.uvs.T,
                                       mmat=self.M.T,
                                       jmat=self.J,
                                       wmat=self.W,
                                       adi_dict=self.nwtn_adi_dict,
                                       transposed=True)['zfac']

        Z4 = pru.solve_proj_lyap_stein(amat=self.F.T,
                                       mmat=self.M.T,
                                       jmat=self.J,
                                       wmat=self.W,
                                       umat=U,
                                       vmat=V,
                                       adi_dict=self.nwtn_adi_dict,
                                       transposed=True)['zfac']

        # TEST: {smw} x {transposed}
        self.assertTrue(np.allclose(Z, Z2))
        self.assertTrue(np.allclose(Z2, Z3))
        self.assertTrue(np.allclose(Z3, Z4))
        self.assertTrue(np.allclose(Z, Z4))