code: def tril(A):
      
      if isinstance(A,spmatrix):
          idx = [i for i,ij in enumerate(zip(A.I,A.J)) if ij[0]>=ij[1]]
          return spmatrix(A.V[idx],A.I[idx],A.J[idx],A.size)
      elif isinstance(A,matrix):
          B = matrix(0.0, A.size)
          lapack.lacpy(A, B, uplo = 'L')
          return B
      else:
          raise TypeError
docs: Returns the lower triangular part of :math:`A`.