Beispiel #1
0
def test_mlpg_window_full():
    static_dim = 2
    T = 10

    def full_window_mat_native(win_mats, T):
        cocatenated_window = np.zeros((T * len(windows), T))
        for win_index, win_mat in enumerate(win_mats):
            win = win_mat.full()
            b = win_index * T
            cocatenated_window[b:b + T, :] = win
        return cocatenated_window

    for windows in _get_windows_set():
        win_mats = G.build_win_mats(windows, T)
        fullwin = G.full_window_mat(win_mats, T)
        assert fullwin.shape == (T * len(windows), T)
        assert np.allclose(full_window_mat_native(win_mats, T), fullwin)
Beispiel #2
0
def test_linalg_choleskey_inv():
    for windows in _get_windows_set():
        for T in [5, 10]:
            win_mats = build_win_mats(windows, T)
            P = _get_banded_test_mat(win_mats, T).full()
            L = scipy.linalg.cholesky(P, lower=True)
            U = scipy.linalg.cholesky(P, lower=False)
            assert np.allclose(L.dot(L.T), P)
            assert np.allclose(U.T.dot(U), P)

            Pinv = np.linalg.inv(P)
            Pinv_hat = cholesky_inv(L, lower=True)
            assert np.allclose(Pinv, Pinv_hat)
            Pinv_hat = cholesky_inv(U, lower=False)
            assert np.allclose(Pinv, Pinv_hat)

            Pinv_hat = cholesky_inv_banded(L, width=3)
            assert np.allclose(Pinv, Pinv_hat)