def test_vech(): arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) assert (np.array_equal(vech(arr), [1, 4, 7, 5, 8, 9]))
def test_elimination_matrix(): for k in range(2, 10): m = np.random.randn(k, k) Lk = tools.elimination_matrix(k) assert (np.array_equal(vech(m), np.dot(Lk, vec(m))))
def test_duplication_matrix(): for k in range(2, 10): m = tools.unvech(np.random.randn(k * (k + 1) / 2)) Dk = tools.duplication_matrix(k) assert (np.array_equal(vec(m), np.dot(Dk, vech(m))))
def test_vech(): arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) assert(np.array_equal(vech(arr), [1, 4, 7, 5, 8, 9]))
def test_elimination_matrix(): for k in range(2, 10): m = np.random.randn(k, k) Lk = tools.elimination_matrix(k) assert(np.array_equal(vech(m), np.dot(Lk, vec(m))))
def test_duplication_matrix(): for k in range(2, 10): m = tools.unvech(np.random.randn(k * (k + 1) / 2)) Dk = tools.duplication_matrix(k) assert(np.array_equal(vec(m), np.dot(Dk, vech(m))))