def test_Submodule_reduce_element(): T = Poly(cyclotomic_poly(5, x)) A = PowerBasis(T) B = A.whole_submodule() b = B(to_col([90, 84, 80, 75]), denom=120) C = B.submodule_from_matrix(DomainMatrix.eye(4, ZZ), denom=2) b_bar_expected = B(to_col([30, 24, 20, 15]), denom=120) b_bar = C.reduce_element(b) assert b_bar == b_bar_expected C = B.submodule_from_matrix(DomainMatrix.eye(4, ZZ), denom=4) b_bar_expected = B(to_col([0, 24, 20, 15]), denom=120) b_bar = C.reduce_element(b) assert b_bar == b_bar_expected C = B.submodule_from_matrix(DomainMatrix.eye(4, ZZ), denom=8) b_bar_expected = B(to_col([0, 9, 5, 0]), denom=120) b_bar = C.reduce_element(b) assert b_bar == b_bar_expected a = A(to_col([1, 2, 3, 4])) raises(NotImplementedError, lambda: C.reduce_element(a)) C = B.submodule_from_matrix( DomainMatrix( [[5, 4, 3, 2], [0, 8, 7, 6], [0, 0, 11, 12], [0, 0, 0, 1]], (4, 4), ZZ).transpose()) raises(StructureError, lambda: C.reduce_element(b))
def test_Module_whole_submodule(): T = Poly(cyclotomic_poly(5, x)) A = PowerBasis(T) B = A.whole_submodule() e = B(to_col([1, 2, 3, 4])) f = e.to_parent() assert f.col.flat() == [1, 2, 3, 4] e0, e1, e2, e3 = B(0), B(1), B(2), B(3) assert e2 * e3 == e0 assert e3**2 == e1