Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « scipy.sparse »

Classe « lil_matrix »

Informations générales

Héritage

builtins.object
    IndexMixin
builtins.object
    spmatrix
        lil_matrix

Définition

class lil_matrix(spmatrix, IndexMixin):

Description [extrait de lil_matrix.__doc__]

Row-based list of lists sparse matrix

    This is a structure for constructing sparse matrices incrementally.
    Note that inserting a single item can take linear time in the worst case;
    to construct a matrix efficiently, make sure the items are pre-sorted by
    index, per row.

    This can be instantiated in several ways:
        lil_matrix(D)
            with a dense matrix or rank-2 ndarray D

        lil_matrix(S)
            with another sparse matrix S (equivalent to S.tolil())

        lil_matrix((M, N), [dtype])
            to construct an empty matrix with shape (M, N)
            dtype is optional, defaulting to dtype='d'.

    Attributes
    ----------
    dtype : dtype
        Data type of the matrix
    shape : 2-tuple
        Shape of the matrix
    ndim : int
        Number of dimensions (this is always 2)
    nnz
        Number of stored values, including explicit zeros
    data
        LIL format data array of the matrix
    rows
        LIL format row index array of the matrix

    Notes
    -----

    Sparse matrices can be used in arithmetic operations: they support
    addition, subtraction, multiplication, division, and matrix power.

    Advantages of the LIL format
        - supports flexible slicing
        - changes to the matrix sparsity structure are efficient

    Disadvantages of the LIL format
        - arithmetic operations LIL + LIL are slow (consider CSR or CSC)
        - slow column slicing (consider CSC)
        - slow matrix vector products (consider CSR or CSC)

    Intended Usage
        - LIL is a convenient format for constructing sparse matrices
        - once a matrix has been constructed, convert to CSR or
          CSC format for fast arithmetic and matrix vector operations
        - consider using the COO format when constructing large matrices

    Data Structure
        - An array (``self.rows``) of rows, each of which is a sorted
          list of column indices of non-zero elements.
        - The corresponding nonzero values are stored in similar
          fashion in ``self.data``.


    

Constructeur(s)

Signature du constructeur Description
__init__(self, arg1, shape=None, dtype=None, copy=False)

Liste des attributs statiques

Nom de l'attribut Valeur
formatlil
ndim2

Liste des propriétés

Nom de la propriétéDescription
nnzNumber of stored values, including explicit zeros. [extrait de __doc__]
shapeGet shape of a matrix. [extrait de __doc__]

Liste des opérateurs

Signature de l'opérateur Description
__getitem__(self, key)
__iadd__(self, other)
__imul__(self, other)
__isub__(self, other)
__itruediv__(self, other)
__setitem__(self, key, x)
__truediv__(self, other)

Opérateurs hérités de la classe spmatrix

__add__, __eq__, __ge__, __gt__, __le__, __lt__, __matmul__, __mul__, __ne__, __neg__, __pow__, __radd__, __rmul__, __rsub__, __rtruediv__, __sub__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__str__(self)
copy(self) Returns a copy of this matrix. [extrait de copy.__doc__]
count_nonzero(self) Number of non-zero entries, equivalent to [extrait de count_nonzero.__doc__]
getnnz(self, axis=None) Number of stored values, including explicit zeros. [extrait de getnnz.__doc__]
getrow(self, i) Returns a copy of the 'i'th row. [extrait de getrow.__doc__]
getrowview(self, i) Returns a view of the 'i'th row (without copying). [extrait de getrowview.__doc__]
reshape(self, *args, **kwargs) reshape(self, shape, order='C', copy=False) [extrait de reshape.__doc__]
resize(self, *shape) Resize the matrix in-place to dimensions given by ``shape`` [extrait de resize.__doc__]
toarray(self, order=None, out=None)
tocsr(self, copy=False) Convert this matrix to Compressed Sparse Row format. [extrait de tocsr.__doc__]
tolil(self, copy=False) Convert this matrix to List of Lists format. [extrait de tolil.__doc__]
transpose(self, axes=None, copy=False)

Méthodes héritées de la classe IndexMixin

__init_subclass__, __subclasshook__, getcol

Méthodes héritées de la classe spmatrix

__abs__, __bool__, __div__, __getattr__, __idiv__, __iter__, __len__, __nonzero__, __rdiv__, __repr__, __rmatmul__, __round__, asformat, asfptype, astype, conj, conjugate, diagonal, dot, get_shape, getformat, getH, getmaxprint, maximum, mean, minimum, multiply, nonzero, power, set_shape, setdiag, sum, tobsr, tocoo, tocsc, todense, todia, todok

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__