<commit_before>from __future__ import division
import numpy as np
from .code_utils import deprecate_method
from discretize.utils import (
    Zero,
    Identity,
    mkvc,
    sdiag,
    sdInv,
    speye,
    kron3,
    spzeros,
    ddx,
    av,
    av_extrap,
    ndgrid,
    ind2sub,
    sub2ind,
    getSubArray,
    inv3X3BlockDiagonal,
    inv2X2BlockDiagonal,
    TensorType,
    makePropertyTensor,
    invPropertyTensor,
)

avExtrap = deprecate_method(
    av_extrap, "avExtrap", removal_version="0.16.0", future_warn=True
)


def diagEst(matFun, n, k=None, approach="Probing"):
    """
    Estimate the diagonal of a matrix, A. Note that the matrix may be a
    function which returns A times a vector.

    Three different approaches have been implemented:

    1. Probing: cyclic permutations of vectors with 1's and 0's (default)
    2. Ones: random +/- 1 entries
    3. Random: random vectors

    :param callable matFun: takes a (numpy.ndarray) and multiplies it by a matrix to estimate the diagonal
    :param int n: size of the vector that should be used to compute matFun(v)
    :param int k: number of vectors to be used to estimate the diagonal
    :param str approach: approach to be used for getting vectors
    :rtype: numpy.ndarray
    :return: est_diag(A)

    Based on Saad http://www-users.cs.umn.edu/~saad/PDF/umsi-2005-082.pdf,<commit_msg>update link to https<commit_after>from __future__ import division
import numpy as np
from .code_utils import deprecate_method
from discretize.utils import (
    Zero,
    Identity,
    mkvc,
    sdiag,
    sdInv,
    speye,
    kron3,
    spzeros,
    ddx,
    av,
    av_extrap,
    ndgrid,
    ind2sub,
    sub2ind,
    getSubArray,
    inv3X3BlockDiagonal,
    inv2X2BlockDiagonal,
    TensorType,
    makePropertyTensor,
    invPropertyTensor,
)

avExtrap = deprecate_method(
    av_extrap, "avExtrap", removal_version="0.16.0", future_warn=True
)


def diagEst(matFun, n, k=None, approach="Probing"):
    """
    Estimate the diagonal of a matrix, A. Note that the matrix may be a
    function which returns A times a vector.

    Three different approaches have been implemented:

    1. Probing: cyclic permutations of vectors with 1's and 0's (default)
    2. Ones: random +/- 1 entries
    3. Random: random vectors

    :param callable matFun: takes a (numpy.ndarray) and multiplies it by a matrix to estimate the diagonal
    :param int n: size of the vector that should be used to compute matFun(v)
    :param int k: number of vectors to be used to estimate the diagonal
    :param str approach: approach to be used for getting vectors
    :rtype: numpy.ndarray
    :return: est_diag(A)

    Based on Saad https://www-users.cse.umn.edu/~saad/PDF/umsi-2005-082.pdf,
{'fraction_non_alphanumeric': 0.07728764126868393, 'fraction_numerical': 0.017499088589135983, 'mean_word_length': 3.12012012012012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1173169', 'n_tokens_mistral': 921, 'n_tokens_neox': 868, 'n_words': 310}