Пример #1
0
    def test_simple_real(self):
        x = np.array([[1, 2, 3], [3, 4, 3], [1, 0, 2], [0, 0, 1]], np.float)

        for m in [x.T, x]:
            for k in range(1, 3):
                u, s, vh = sorted_svd(m, k)
                su, ss, svh = svd(m, k)

                m_hat = svd_estimate(u, s, vh)
                sm_hat = svd_estimate(su, ss, svh)

                assert_array_almost_equal_nulp(m_hat, sm_hat, nulp=1000)
Пример #2
0
    def test_simple_complex(self):
        x = np.array([[1, 2, 3], [3, 4, 3], [1 + 1j, 0, 2], [0, 0, 1]],
                     np.complex)

        for m in [x, x.T.conjugate()]:
            for k in range(1, 3):
                u, s, vh = sorted_svd(m, k)
                su, ss, svh = svd(m, k)

                m_hat = svd_estimate(u, s, vh)
                sm_hat = svd_estimate(su, ss, svh)

                assert_array_almost_equal_nulp(m_hat, sm_hat, nulp=1000)
Пример #3
0
    def test_simple_complex(self):
        x = np.array([[1, 2, 3],
                      [3, 4, 3],
                      [1+1j, 0, 2],
                      [0, 0, 1]], np.complex)

        for m in [x, x.T.conjugate()]:
            for k in range(1, 3):
                u, s, vh = sorted_svd(m, k)
                su, ss, svh = svd(m, k)

                m_hat = svd_estimate(u, s, vh)
                sm_hat = svd_estimate(su, ss, svh)

                assert_array_almost_equal_nulp(m_hat, sm_hat, nulp=1000)
Пример #4
0
    def test_simple_real(self):
        x = np.array([[1, 2, 3],
                      [3, 4, 3],
                      [1, 0, 2],
                      [0, 0, 1]], np.float)

        for m in [x.T, x]:
            for k in range(1, 3):
                u, s, vh = sorted_svd(m, k)
                su, ss, svh = svd(m, k)

                m_hat = svd_estimate(u, s, vh)
                sm_hat = svd_estimate(su, ss, svh)

                assert_array_almost_equal_nulp(m_hat, sm_hat, nulp=1000)