---
title: "Predicates"
canonical: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/SparseMatrices/predicates.html"
source: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/SparseMatrices/predicates.md"
part: "Matrices and Linear Algebra"
chapter: "Sparse 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": "Sparse Matrices", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/SparseMatrices/index-sparse-matrices.md"}
prev: {"title": "Changing Ring", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/SparseMatrices/change-ring.md"}
next: {"title": "Elementary Arithmetic", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/SparseMatrices/arithmetic.md"}
intrinsics:
  - {"name": "eq", "signature": "A eq B: MtrxSprs, MtrxSprs -> BoolElt"}
  - {"name": "IsZero", "signature": "IsZero(A): MtrxSprs -> BoolElt"}
  - {"name": "IsOne", "signature": "IsOne(A): MtrxSprs -> BoolElt"}
  - {"name": "IsMinusOne", "signature": "IsMinusOne(A): MtrxSprs -> BoolElt"}
  - {"name": "IsScalar", "signature": "IsScalar(A): MtrxSprs -> BoolElt"}
  - {"name": "IsDiagonal", "signature": "IsDiagonal(A): MtrxSprs -> BoolElt"}
  - {"name": "IsSymmetric", "signature": "IsSymmetric(A): MtrxSprs -> BoolElt"}
  - {"name": "IsUpperTriangular", "signature": "IsUpperTriangular(A): MtrxSprs -> BoolElt"}
  - {"name": "IsLowerTriangular", "signature": "IsLowerTriangular(A): MtrxSprs -> BoolElt"}
---

# Predicates

The functions in this section test various properties of sparse matrices.

<a id="operation-op-eq-mtrxsprs-mtrxsprs"></a>
## `A eq B: MtrxSprs, MtrxSprs -> BoolElt`

Given sparse matrices $A$ and $B$, return `true` if and only if $A$ and $B$ are equal.

<a id="function-iszero-mtrxsprs"></a>
## `IsZero(A): MtrxSprs -> BoolElt`

Given an $m \times n$ sparse matrix $A$ over the ring $R$, return `true` iff $A$ is the $m \times n$ zero sparse matrix.

<a id="function-isone-mtrxsprs"></a>
## `IsOne(A): MtrxSprs -> BoolElt`

Given a square $m \times m$ sparse matrix $A$ over the ring $R$, return `true` iff $A$ is the $m \times m$ identity sparse matrix.

<a id="function-isminusone-mtrxsprs"></a>
## `IsMinusOne(A): MtrxSprs -> BoolElt`

Given a square $m \times m$ sparse matrix $A$ over the ring $R$, return `true` iff $A$ is the negation of the $m \times m$ identity sparse matrix.

<a id="function-isscalar-mtrxsprs"></a>
## `IsScalar(A): MtrxSprs -> BoolElt`

Given a square $m \times m$ sparse matrix $A$ over the ring $R$, return `true` iff $A$ is scalar, i.e., iff $A$ is the product of some element of $R$ and the $m \times m$ identity sparse matrix.

<a id="function-isdiagonal-mtrxsprs"></a>
## `IsDiagonal(A): MtrxSprs -> BoolElt`

Given a square sparse matrix $A$ over the ring $R$, return `true` iff $A$ is diagonal, i.e., iff the only non-zero entries of $A$ are on the diagonal.

<a id="function-issymmetric-mtrxsprs"></a>
## `IsSymmetric(A): MtrxSprs -> BoolElt`

Given a square sparse matrix $A$ over the ring $R$, return `true` iff $A$ is symmetric, i.e., iff $A$ equals its transpose.

<a id="function-isuppertriangular-mtrxsprs"></a>
## `IsUpperTriangular(A): MtrxSprs -> BoolElt`

Given a sparse matrix $A$ over the ring $R$, return `true` iff $A$ is upper triangular, i.e., iff the only non-zero entries of $A$ are on or above the diagonal.

<a id="function-islowertriangular-mtrxsprs"></a>
## `IsLowerTriangular(A): MtrxSprs -> BoolElt`

Given a sparse matrix $A$ over the ring $R$, return `true` iff $A$ is lower triangular, i.e., iff the only non-zero entries of $A$ are on or below the diagonal.
