tril(A, k=0, format=None)
Returns the elements on or below the k-th diagonal of the matrix A.
k = 0 corresponds to the main diagonal
k > 0 is above the main diagonal
k < 0 is below the main diagonal
Matrix whose lower trianglar portion is desired.
The top-most diagonal of the lower triangle.
Sparse format of the result, e.g. format="csr", etc.
Lower triangular portion of A in sparse format.
Return the lower triangular portion of a matrix in sparse format
triu
upper triangle in sparse format
>>> from scipy.sparse import csr_matrix, tril
... A = csr_matrix([[1, 2, 0, 0, 3], [4, 5, 0, 6, 7], [0, 0, 8, 9, 0]],
... dtype='int32')
... A.toarray() array([[1, 2, 0, 0, 3], [4, 5, 0, 6, 7], [0, 0, 8, 9, 0]])
>>> tril(A).toarray() array([[1, 0, 0, 0, 0], [4, 5, 0, 0, 0], [0, 0, 8, 0, 0]])
>>> tril(A).nnz 4
>>> tril(A, k=1).toarray() array([[1, 2, 0, 0, 0], [4, 5, 0, 0, 0], [0, 0, 8, 9, 0]])
>>> tril(A, k=-1).toarray() array([[0, 0, 0, 0, 0], [4, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
>>> tril(A, format='csc') <3x5 sparse matrix of type '<class 'numpy.int32'>' with 4 stored elements in Compressed Sparse Column format>See :
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.sparse._extract.tril
scipy.sparse._extract.triu
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them