## `linalg::nonZeros` -- number of non-zero elements of a matrix

#### Introduction

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

#### Call(s)

`linalg::nonZeros(A)`

#### Parameters

`A` | - | a matrix of a domain of category `Cat::Matrix`

#### Returns

a nonnegative integer

#### Example 1

The matrix

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

                              +-                  -+
                              |  4 mod 7, 6 mod 7  |
                              |                    |
                              |  4 mod 7, 4 mod 7  |
                              +-                  -+

has four non-zero entries:

    >> linalg::nonZeros(A)

                                         4

The matrix:

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

                              +-                  -+
                              |  0 mod 7, 2 mod 7  |
                              |                    |
                              |  6 mod 7, 0 mod 7  |
                              +-                  -+

has only two non-zero entries:

    >> linalg::nonZeros(B)

                                         2

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000