'Returns the LDL Decomposition (matrices ``L`` and ``D``) of matrix
``A``, such that ``L * D * L.T == A``. ``A`` must be a square,
symmetric, positive-definite and non-singular.
This method eliminates the use of square root and ensures that all
the diagonal entries of L are 1.
Examples
>>> from sympy.matrices import SparseMatrix
>>> A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
>>> L, D = A.LDLdecomposition()
>>> L
Matrix([
[   1,   0, 0],
[ 3/5,   1, 0],
[-1/5, 1/3, 1]])
>>> D
Matrix([
[25, 0, 0],
[ 0, 9, 0],
[ 0, 0, 9]])
>>> L * D * L.T == A
True'

def LDLdecomposition(self):

    from sympy.core.numbers import nan, oo
    if (not self.is_symmetric()):
        raise ValueError('LDL    decomposition    applies    only    to    symmetric    matrices.')
    (L, D) = self.as_mutable()._LDL_sparse()
    if (L.has(nan) or L.has(oo) or D.has(nan) or D.has(oo)):
        raise ValueError('LDL    decomposition    applies    only    to    positive-definite    matrices')
    return (self._new(L), self._new(D))
