Accessing Sparse Matrices

The following functions access basic properties of sparse matrices.

Contents

Elementary Properties

BaseRing(A) : MtrxSprs -> Rng
CoefficientRing(A) : MtrxSprs -> Rng
Given a sparse matrix A with entries lying in a ring R, return R.
NumberOfRows(A) : MtrxSprs -> RngIntElt
Nrows(A) : MtrxSprs -> RngIntElt
Given an m x n sparse matrix A, return m, the number of rows of A.
NumberOfColumns(A) : MtrxSprs -> RngIntElt
Ncols(A) : MtrxSprs -> RngIntElt
Given an m x n sparse matrix A, return n, the number of columns of A.
ElementToSequence(A) : Mtrx -> [ <RngIntElt, RngIntElt, RngElt> ]
Eltseq(A) : Mtrx -> [ <RngIntElt, RngIntElt, RngElt> ]
Given a sparse matrix A over the ring R having m rows and n columns, return the entries of A as a sequence of all tuples of the form <i, j, x> such that the [i, j]-th entry of A equals x and x is non-zero. It is always true that SparseMatrix(Nrows(A), Ncols(A), Eltseq(A)) equals A.
NumberOfNonZeroEntries(A) : MtrxSprs -> RngIntElt
NNZEntries(A) : MtrxSprs -> RngIntElt
Given a sparse matrix A, return the number of non-zero entries in A.
Density(A) : MtrxSprs -> FldRe
Given a sparse matrix A, return the density of A as a real number, which is the number of non-zero entries in A divided by the product of the number of rows of A and the number of columns of A (or zero if A has zero rows or columns).
Support(A, i) : MtrxSprs, RngIntElt -> [RngIntElt]
Given a sparse matrix A having r rows, and an integer i such that 1≤i≤r, return the support of row i of A; i.e., the column numbers of the non-zero entries of row i of A.
Support(A) : MtrxSprs -> [ <RngIntElt, RngIntElt, RngElt> ]
Given a sparse matrix A, return the sequence of all pairs <i, j> such that the [i, j]-th entry of A is non-zero.

Weights

RowWeight(A, i) : MtrxSprs, RngIntElt -> RngIntElt
Given a sparse matrix A with m rows and an integer i such that 1≤i≤m, return the weight (number of non-zero entries) of the i-th row of A.
RowWeights(A) : MtrxSprs -> [RngIntElt]
Given a sparse matrix A with m rows, return the length m sequence of integers whose i-th entry is the weight of the i-th row of A.
ColumnWeight(A, j) : MtrxSprs, RngIntElt -> RngIntElt
Given a sparse matrix A with n columns and an integer j such that 1≤j≤n, return the weight (number of non-zero entries) of the j-th column of A.
ColumnWeights(A) : MtrxSprs -> [RngIntElt]
Given a sparse matrix A with n columns, return the length n sequence of integers whose j-th entry is the weight of the j-th column of A.
V2.28, 13 July 2023