![]() |
STAG Python
2.0.2
Spectral Toolkit of Algorithms for Graphs
|
An object representing a sparse matrix for use by the STAG library.
The data is stored natively on the 'C++' side of the library, allowing for fast computation.
The object is designed for easy interoperability with scipy sparse matrix objects. The SprsMat object can be constructed directly from a scipy sparse matrix, and the to_scipy() method can be used to convert back to a scipy matrix.
If they are only used as arguments to STAG library methods, they will be very efficient since the data will stay on the C++ side of the library.
Public Member Functions | |
def | __init__ (self, Union[scipy.sparse.spmatrix, List[List[float]]] matrix) |
Construct a STAG SprsMat. | |
scipy.sparse.csc_matrix | to_scipy (self) |
Convert the STAG SprsMat object to a scipy sparse matrix. | |
np.ndarray | to_dense (self) |
Convert the STAG SprsMat object to a dense numpy matrix. | |
'SprsMat' | transpose (self) |
Return the transpose of the matrix. | |
Tuple[int, int] | shape (self) |
Return the shape of the matrix. | |
Public Attributes | |
scipy_mat | |
def stag.utility.SprsMat.__init__ | ( | self, | |
Union[scipy.sparse.spmatrix, List[List[float]]] | matrix | ||
) |
Construct a STAG SprsMat.
Pass either a scipy sparse matrix object or a List of Lists representing the dense matrix to be stored in sparse format.
For example:
scipy.sparse.csc_matrix stag.utility.SprsMat.to_scipy | ( | self | ) |
Convert the STAG SprsMat object to a scipy sparse matrix.
np.ndarray stag.utility.SprsMat.to_dense | ( | self | ) |
Convert the STAG SprsMat object to a dense numpy matrix.
'SprsMat' stag.utility.SprsMat.transpose | ( | self | ) |
Return the transpose of the matrix.
Tuple[int, int] stag.utility.SprsMat.shape | ( | self | ) |
Return the shape of the matrix.
stag.utility.SprsMat.scipy_mat |