Accessing Sparse Matrices
The following functions access basic properties of sparse matrices.
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 \times n\) sparse matrix \(A\), return \(m\), the number of rows of \(A\).
- NumberOfColumns(A): MtrxSprs -> RngIntElt
- Ncols(A): MtrxSprs -> RngIntElt
Given an \(m \times n\) sparse matrix \(A\), return \(n\), the number of columns of \(A\).
- ElementToSequence(A): MtrxSprs -> [ <RngIntElt, RngIntElt, RngElt> ]
- Eltseq(A): MtrxSprs -> [ <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 thatSparseMatrix(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).
Weights
- RowWeight(A, i): MtrxSprs, RngIntElt -> RngIntElt
Given a sparse matrix \(A\) with \(m\) rows and an integer \(i\) such that \(1\leq i\leq 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\).