(self, simplify=False)
return [self._new(b) for b in basis]
Returns list of vectors (Matrix objects) that span nullspace of self
Returns list of vectors (Matrix objects) that span nullspace of self
Returns list of vectors ( Matrix objects ) that span nullspace of self
def nullspace(self, simplify=False):
        """Returns list of vectors (Matrix objects) that span nullspace of self
        """
        from sympy.matrices import zeros

        simpfunc = simplify if isinstance(
            simplify, FunctionType) else _simplify
        reduced, pivots = self.rref(simplify=simpfunc)

        basis = []
        # create a set of vectors for the basis
        for i in range(self.cols - len(pivots)):
            basis.append(zeros(self.cols, 1))
        # contains the variable index to which the vector corresponds
        basiskey, cur = [-1]*len(basis), 0
        for i in range(self.cols):
            if i not in pivots:
                basiskey[cur] = i
                cur += 1
        for i in range(self.cols):
            if i not in pivots:  # free var, just set vector's ith place to 1
                basis[basiskey.index(i)][i, 0] = 1
            else:               # add negative of nonpivot entry to corr vector
                for j in range(i + 1, self.cols):
                    line = pivots.index(i)
                    v = reduced[line, j]
                    if simplify:
                        v = simpfunc(v)
                    if v:
                        if j in pivots:
                            # XXX: Is this the correct error?
                            raise NotImplementedError(
                                "Could not compute the nullspace of `self`.")
                        basis[basiskey.index(j)][i, 0] = -v
        return [self._new(b) for b in basis]
def nullspace ( self , simplify = False ) : from sympy . matrices import zeros simpfunc = simplify if isinstance ( simplify , FunctionType ) else _simplify reduced , pivots = self . rref ( simplify = simpfunc ) basis = [ ] # create a set of vectors for the basis for i in range ( self . cols - len ( pivots ) ) : basis . append ( zeros ( self . cols , 1 ) ) # contains the variable index to which the vector corresponds basiskey , cur = [ - 1 ] * len ( basis ) , 0 for i in range ( self . cols ) : if i not in pivots : basiskey [ cur ] = i cur += 1 for i in range ( self . cols ) : if i not in pivots : # free var, just set vector's ith place to 1 basis [ basiskey . index ( i ) ] [ i , 0 ] = 1 else : # add negative of nonpivot entry to corr vector for j in range ( i + 1 , self . cols ) : line = pivots . index ( i ) v = reduced [ line , j ] if simplify : v = simpfunc ( v ) if v : if j in pivots : # XXX: Is this the correct error? raise NotImplementedError ( "Could not compute the nullspace of `self`." ) basis [ basiskey . index ( j ) ] [ i , 0 ] = - v return [ self . _new ( b ) for b in basis ]