(m, n, density, format='csr')
return A.asformat(format)
Return a random sparse matrix.

    Parameters
    ----------
    m, n : int
        shape of the result
    density : float
        target a matrix with nnz(A) = m*n*density, 0<=density<=1
    format : string
        sparse matrix format to return, e.g. 'csr', 'coo', etc.

    Return
    ------
    A : sparse matrix
        m x n sparse matrix

    Examples
    --------
    >>> from pyamg.gallery import sprand
    >>> A = sprand(5,5,3/5.0)
Return a random sparse matrix.
Return a random sparse matrix .
def sprand(m, n, density, format='csr'):
    """Return a random sparse matrix.

    Parameters
    ----------
    m, n : int
        shape of the result
    density : float
        target a matrix with nnz(A) = m*n*density, 0<=density<=1
    format : string
        sparse matrix format to return, e.g. 'csr', 'coo', etc.

    Return
    ------
    A : sparse matrix
        m x n sparse matrix

    Examples
    --------
    >>> from pyamg.gallery import sprand
    >>> A = sprand(5,5,3/5.0)

    """
    m, n = int(m), int(n)

    # get sparsity pattern
    A = _rand_sparse(m, n, density)

    # replace data with random values
    A.data = np.random.rand(A.nnz)

    return A.asformat(format)
def sprand ( m , n , density , format = 'csr' ) : m , n = int ( m ) , int ( n ) # get sparsity pattern A = _rand_sparse ( m , n , density ) # replace data with random values A . data = np . random . rand ( A . nnz ) return A . asformat ( format )