---
title: "Elementary Properties"
canonical: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/access.html"
source: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/access.md"
part: "Matrices and Linear Algebra"
chapter: "Matrices"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Matrices and Linear Algebra", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/index-matrices-linear-algebra.md"}
  - {"title": "Matrices", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/index-matrices.md"}
prev: {"title": "Creation of Matrices", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/creation.md"}
next: {"title": "Accessing or Modifying Entries", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/entries.md"}
intrinsics:
  - {"name": "NumberOfRows", "signature": "NumberOfRows(A): Mtrx -> RngIntElt"}
  - {"name": "Nrows", "signature": "Nrows(A): Mtrx -> RngIntElt"}
  - {"name": "NumberOfColumns", "signature": "NumberOfColumns(A): Mtrx -> RngIntElt"}
  - {"name": "Ncols", "signature": "Ncols(A): Mtrx -> RngIntElt"}
  - {"name": "NumberOfNonZeroEntries", "signature": "NumberOfNonZeroEntries(A): Mtrx -> RngIntElt"}
  - {"name": "NNZEntries", "signature": "NNZEntries(A): Mtrx -> RngIntElt"}
  - {"name": "Density", "signature": "Density(A): Mtrx -> FldRe"}
  - {"name": "BaseRing", "signature": "BaseRing(A): Mtrx -> Rng"}
  - {"name": "CoefficientRing", "signature": "CoefficientRing(A): Mtrx -> Rng"}
  - {"name": "ElementToSequence", "signature": "ElementToSequence(A): Mtrx -> [ RngElt ]"}
  - {"name": "Eltseq", "signature": "Eltseq(A): Mtrx -> [ RngElt ]"}
  - {"name": "RowSequence", "signature": "RowSequence(A): Mtrx -> [ [RngElt] ]"}
---

# Elementary Properties

The following functions yield elementary properties of matrices and may be applied to matrices of any type, including vectors.

<a id="function-numberofrows-mtrx"></a>
## `NumberOfRows(A): Mtrx -> RngIntElt`

<a id="function-nrows-mtrx"></a>
## `Nrows(A): Mtrx -> RngIntElt`

Given an $m \times n$ matrix $A$, return $m$, the number of rows of $A$.

<a id="function-numberofcolumns-mtrx"></a>
## `NumberOfColumns(A): Mtrx -> RngIntElt`

<a id="function-ncols-mtrx"></a>
## `Ncols(A): Mtrx -> RngIntElt`

Given an $m \times n$ matrix $A$, return $n$, the number of columns of $A$.

<a id="function-numberofnonzeroentries-mtrx"></a>
## `NumberOfNonZeroEntries(A): Mtrx -> RngIntElt`

<a id="function-nnzentries-mtrx"></a>
## `NNZEntries(A): Mtrx -> RngIntElt`

Given a matrix $A$, return the number of non-zero entries in $A$.

<a id="function-density-mtrx"></a>
## `Density(A): Mtrx -> FldRe`

Given a 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).

<a id="function-basering-mtrx"></a>
## `BaseRing(A): Mtrx -> Rng`

<a id="function-coefficientring-mtrx"></a>
## `CoefficientRing(A): Mtrx -> Rng`

Given a matrix $A$ with entries lying in a ring $R$, return $R$.

<a id="function-elementtosequence-mtrx"></a>
## `ElementToSequence(A): Mtrx -> [ RngElt ]`

<a id="function-eltseq-mtrx"></a>
## `Eltseq(A): Mtrx -> [ RngElt ]`

Given a matrix $A$ over the ring $R$ having $m$ rows and $n$ columns, return the entries of $A$, in row-major order, as a sequence of $mn$ elements of $R$.

<a id="function-rowsequence-mtrx"></a>
## `RowSequence(A): Mtrx -> [ [RngElt] ]`

Returns the entries of $A$ as a sequence of rows where a row is represented as a sequence of entries of $A$.
