def test_smith_normal_deprecated(): from sympy.polys.solvers import RawMatrix as Matrix with warns_deprecated_sympy(): m = Matrix([[12, 6, 4, 8], [3, 9, 6, 12], [2, 16, 14, 28], [20, 10, 10, 20]]) setattr(m, 'ring', ZZ) with warns_deprecated_sympy(): smf = Matrix([[1, 0, 0, 0], [0, 10, 0, 0], [0, 0, -30, 0], [0, 0, 0, 0]]) assert smith_normal_form(m) == smf x = Symbol('x') with warns_deprecated_sympy(): m = Matrix([[Poly(x - 1), Poly(1, x), Poly(-1, x)], [0, Poly(x), Poly(-1, x)], [Poly(0, x), Poly(-1, x), Poly(x)]]) setattr(m, 'ring', QQ[x]) invs = (Poly(1, x, domain='QQ'), Poly(x - 1, domain='QQ'), Poly(x**2 - 1, domain='QQ')) assert invariant_factors(m) == invs with warns_deprecated_sympy(): m = Matrix([[2, 4]]) setattr(m, 'ring', ZZ) with warns_deprecated_sympy(): smf = Matrix([[2, 0]]) assert smith_normal_form(m) == smf
def _is_infinite(self): """ Test if the group is infinite. Return `True` if the test succeeds and `None` otherwise """ used_gens = set() for r in self.relators: used_gens.update(r.contains_generators()) if any([g not in used_gens for g in self.generators]): return True # Abelianisation test: check is the abelianisation is infinite abelian_rels = [] from sympy.polys.solvers import RawMatrix as Matrix from sympy.polys.domains import ZZ from sympy.matrices.normalforms import invariant_factors for rel in self.relators: abelian_rels.append([rel.exponent_sum(g) for g in self.generators]) m = Matrix(abelian_rels) setattr(m, "ring", ZZ) if 0 in invariant_factors(m): return True else: return None
def test_smith_normal(): m = Matrix([[12, 6, 4,8],[3,9,6,12],[2,16,14,28],[20,10,10,20]]) setattr(m, 'ring', ZZ) smf = Matrix([[1, 0, 0, 0], [0, 10, 0, 0], [0, 0, -30, 0], [0, 0, 0, 0]]) assert smith_normal_form(m) == smf x = Symbol('x') m = Matrix([[Poly(x-1), Poly(1, x),Poly(-1,x)], [0, Poly(x), Poly(-1,x)], [Poly(0,x),Poly(-1,x),Poly(x)]]) setattr(m, 'ring', QQ[x]) invs = (Poly(1, x), Poly(x - 1), Poly(x**2 - 1)) assert invariant_factors(m) == invs
def test_smith_normal(): m = Matrix([[12, 6, 4, 8], [3, 9, 6, 12], [2, 16, 14, 28], [20, 10, 10, 20]]) setattr(m, 'ring', ZZ) smf = Matrix([[1, 0, 0, 0], [0, 10, 0, 0], [0, 0, -30, 0], [0, 0, 0, 0]]) assert smith_normal_form(m) == smf x = Symbol('x') m = Matrix([[Poly(x - 1), Poly(1, x), Poly(-1, x)], [0, Poly(x), Poly(-1, x)], [Poly(0, x), Poly(-1, x), Poly(x)]]) setattr(m, 'ring', QQ[x]) invs = (Poly(1, x), Poly(x - 1), Poly(x**2 - 1)) assert invariant_factors(m) == invs
def test_smith_normal(): m = Matrix([[12,6,4,8],[3,9,6,12],[2,16,14,28],[20,10,10,20]]) smf = Matrix([[1, 0, 0, 0], [0, 10, 0, 0], [0, 0, -30, 0], [0, 0, 0, 0]]) assert smith_normal_form(m) == smf x = Symbol('x') with warns_deprecated_sympy(): m = Matrix([[Poly(x-1), Poly(1, x),Poly(-1,x)], [0, Poly(x), Poly(-1,x)], [Poly(0,x),Poly(-1,x),Poly(x)]]) invs = 1, x - 1, x**2 - 1 assert invariant_factors(m, domain=QQ[x]) == invs m = Matrix([[2, 4]]) smf = Matrix([[2, 0]]) assert smith_normal_form(m) == smf
def _is_infinite(self): ''' Test if the group is infinite. Return `True` if the test succeeds and `None` otherwise ''' # Abelianisation test: check is the abelianisation is infinite abelian_rels = [] from sympy.polys.solvers import RawMatrix as Matrix from sympy.polys.domains import ZZ from sympy.matrices.normalforms import invariant_factors for rel in self.relators: abelian_rels.append([rel.exponent_sum(g) for g in self.generators]) m = Matrix(abelian_rels) setattr(m, "ring", ZZ) if 0 in invariant_factors(m): return True else: return None
def _is_infinite(self): ''' Test if the group is infinite. Return `True` if the test succeeds and `None` otherwise ''' used_gens = set() for r in self.relators: used_gens.update(r.contains_generators()) if not set(self.generators) <= used_gens: return True # Abelianisation test: check is the abelianisation is infinite abelian_rels = [] for rel in self.relators: abelian_rels.append([rel.exponent_sum(g) for g in self.generators]) m = Matrix(Matrix(abelian_rels)) if 0 in invariant_factors(m): return True else: return None