Documentation Center

  • Trial Software
  • Product Updates

linalg::nonZeros

Number of non-zero elements of a matrix

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

linalg::nonZeros(A)

Description

linalg::nonZeros(A) returns the number of non-zero components of the matrix A.

Examples

Example 1

The matrix

MZ7 := Dom::Matrix(Dom::IntegerMod(7)):
A := MZ7([[18, -1], [4, 81]])

has four non-zero entries:

linalg::nonZeros(A)

The matrix:

B := MZ7([[21, 2], [-1, 14]])

has only two non-zero entries:

linalg::nonZeros(B)

Parameters

A

A matrix of a domain of category Cat::Matrix

Return Values

Nonnegative integer

Was this topic helpful?