Module « scipy.sparse »
Classe « dok_matrix »
Informations générales
Héritage
builtins.object
builtins.dict
builtins.object
IndexMixin
builtins.object
spmatrix
dok_matrix
Définition
class dok_matrix(spmatrix, IndexMixin, builtins.dict):
Description [extrait de dok_matrix.__doc__]
Dictionary Of Keys based sparse matrix.
This is an efficient structure for constructing sparse
matrices incrementally.
This can be instantiated in several ways:
dok_matrix(D)
with a dense matrix, D
dok_matrix(S)
with a sparse matrix, S
dok_matrix((M,N), [dtype])
create the matrix with initial 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 nonzero elements
Notes
-----
Sparse matrices can be used in arithmetic operations: they support
addition, subtraction, multiplication, division, and matrix power.
Allows for efficient O(1) access of individual elements.
Duplicates are not allowed.
Can be efficiently converted to a coo_matrix once constructed.
Examples
--------
>>> import numpy as np
>>> from scipy.sparse import dok_matrix
>>> S = dok_matrix((5, 5), dtype=np.float32)
>>> for i in range(5):
... for j in range(5):
... S[i, j] = i + j # Update element
Constructeur(s)
Liste des attributs statiques
Liste des propriétés
nnz | Number of stored values, including explicit zeros. [extrait de __doc__] |
shape | Get shape of a matrix. [extrait de __doc__] |
Opérateurs hérités de la classe dict
__contains__,
__delitem__,
__eq__,
__ge__,
__getitem__,
__gt__,
__ior__,
__le__,
__lt__,
__ne__,
__or__,
__ror__,
__setitem__
Opérateurs hérités de la classe IndexMixin
__getitem__, __setitem__
Opérateurs hérités de la classe spmatrix
__eq__, __ge__, __gt__, __iadd__, __isub__, __le__, __lt__, __matmul__, __mul__, __ne__, __pow__, __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
__class_getitem__ |
See PEP 585 [extrait de __class_getitem__.__doc__] |
__len__(self) |
|
__reduce__(self) |
|
conjtransp(self) |
Return the conjugate transpose. [extrait de conjtransp.__doc__] |
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__] |
fromkeys(iterable, value=None) |
Create a new dictionary with keys from iterable and values set to value. [extrait de fromkeys.__doc__] |
get(self, key, default=0.0) |
This overrides the dict.get method, providing type checking [extrait de get.__doc__] |
getnnz(self, axis=None) |
Number of stored values, including explicit zeros. [extrait de getnnz.__doc__] |
resize(self, *shape) |
Resize the matrix in-place to dimensions given by ``shape`` [extrait de resize.__doc__] |
set_shape(self, shape) |
|
tocoo(self, copy=False) |
Convert this matrix to COOrdinate format. [extrait de tocoo.__doc__] |
tocsc(self, copy=False) |
Convert this matrix to Compressed Sparse Column format. [extrait de tocsc.__doc__] |
todok(self, copy=False) |
Convert this matrix to Dictionary Of Keys format. [extrait de todok.__doc__] |
transpose(self, axes=None, copy=False) |
|
update(self, val) |
|
Méthodes héritées de la classe dict
__getattribute__,
__init_subclass__,
__iter__,
__repr__,
__reversed__,
__sizeof__,
__subclasshook__,
clear,
items,
keys,
pop,
popitem,
setdefault,
values
Méthodes héritées de la classe IndexMixin
__init_subclass__, __subclasshook__, getcol, getrow
Méthodes héritées de la classe spmatrix
__abs__, __bool__, __div__, __getattr__, __idiv__, __iter__, __nonzero__, __rdiv__, __repr__, __rmatmul__, __round__, __str__, asformat, asfptype, astype, conj, conjugate, diagonal, dot, get_shape, getformat, getH, getmaxprint, maximum, mean, minimum, multiply, nonzero, power, reshape, setdiag, sum, toarray, tobsr, tocsr, todense, todia, tolil
Méthodes héritées de la classe object
__delattr__,
__dir__,
__format__,
__getattribute__,
__hash__,
__reduce_ex__,
__setattr__,
__sizeof__
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 :