def test_EndomorphismRing_represent(): T = Poly(cyclotomic_poly(5, x)) A = PowerBasis(T) R = A.endomorphism_ring() phi = R.inner_endomorphism(A(1)) col = R.represent(phi) assert col.transpose() == DomainMatrix( [[0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, -1, -1, -1]], (1, 16), ZZ) B = A.submodule_from_matrix(DomainMatrix.zeros((4, 0), ZZ)) S = B.endomorphism_ring() psi = S.inner_endomorphism(A(1)) col = S.represent(psi) assert col == DomainMatrix([], (0, 0), ZZ) raises(NotImplementedError, lambda: R.represent(3.14))
def fill(self, value): """Fill self with the given value. Notes ===== Unless many values are going to be deleted (i.e. set to zero) this will create a matrix that is slower than a dense matrix in operations. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix.zeros(3); M Matrix([ [0, 0, 0], [0, 0, 0], [0, 0, 0]]) >>> M.fill(1); M Matrix([ [1, 1, 1], [1, 1, 1], [1, 1, 1]]) See Also ======== zeros ones """ value = _sympify(value) if not value: self._rep = DomainMatrix.zeros(self.shape, EXRAW) else: elements_dod = { i: {j: value for j in range(self.cols)} for i in range(self.rows) } self._rep = DomainMatrix(elements_dod, self.shape, EXRAW)
def zeros(cls, m, n, gens): return cls.from_dm(DomainMatrix.zeros((m, n), QQ[gens]))
def _eval_zeros(cls, rows, cols): rep = DomainMatrix.zeros((rows, cols), ZZ) return cls._fromrep(rep)