def is_rep(self, image, n, force=False): """ Returns `True` if the map generated by mapping the generators to the matrices defined in `image` is an `n`-dimensional representation of `self`, and `False` otherwise. The entries of `image` must be `n`-by-`n` matrices with entries in the algebraic closure of the base field of `self`. Its length must match the number of generators of `self.` Use `force=True` if the function does not recognize the base field as computable, but the field is computable. """ if (not force and self.base_field() not in NumberFields and self.base_field() not in FiniteFields): raise TypeError('Base field must be computable. If %s is' % self.base_field() + ' computable then use force=True to bypass this.') if n not in ZZ or n < 1: raise ValueError('Dimension must be a positive integer.') M = MatrixSpace(self.base_field().algebraic_closure(), n, sparse=True) if len(image) != self.ngens(): raise ValueError( 'Length of image does not match number of generators.') if False in {mat in M for mat in image}: raise TypeError('Improper image, must contain elements of %s.' % M._repr_()) image = [M(image[i]) for i in range(len(image))] for rel in self.rels(): if self._to_matrix(rel, M, image) != M.zero(): return False return True