def trace(A: LinearOperator, alg: Algorithm = Auto()):
    r""" Compute the trace of a linear operator tr(A).

    Can use either the :math:`O(\tfrac{1}{\delta^2})` time stochastic estimation (alg=Hutch())
    or a deterministic :math:`O(n)` time algorithm (alg =Exact()).

    If only unbiased estimates of the diagonal are needed, use the Hutchinson algorithm.

    Args:
        A (LinearOperator): The linear operator to compute the diagonal of.
        alg (Algorithm, optional): The algorithm to use for the diagonal computation (Hutch or Exact).

    Returns:
        Array: trace"""
 Compute the trace of a linear operator tr(A).

    Can use either the :math:`O(\tfrac{1}{\delta^2})` time stochastic estimation (alg=Hutch())
    or a deterministic :math:`O(n)` time algorithm (alg =Exact()).

    If only unbiased estimates of the diagonal are needed, use the Hutchinson algorithm.

    Args:
        A (LinearOperator): The linear operator to compute the diagonal of.
        alg (Algorithm, optional): The algorithm to use for the diagonal computation (Hutch or Exact).

    Returns:
        Array: trace
cola/linalg/trace/diag_trace.py