'Checks if a matrix is nilpotent.
A matrix B is nilpotent if for some integer k, B**k is
a zero matrix.
Examples
>>> from sympy import Matrix
>>> a = Matrix([[0, 0, 0], [1, 0, 0], [1, 1, 0]])
>>> a.is_nilpotent()
True
>>> a = Matrix([[1, 0, 1], [1, 0, 0], [1, 1, 0]])
>>> a.is_nilpotent()
False'

def is_nilpotent(self):

    if (not self):
        return True
    if (not self.is_square):
        raise NonSquareMatrixError('Nilpotency    is    valid    only    for    square    matrices')
    x = Dummy('x')
    if (self.charpoly(x).args[0] == (x ** self.rows)):
        return True
    return False
