linalg::nonZeros -- number of
non-zero elements of a matrix
Introductionlinalg::nonZeros(A) returns the number of
non-zero components of the matrix A.
Call(s)linalg::nonZeros(A)
ParametersA |
- | a matrix of a domain of category Cat::Matrix |
Returnsa nonnegative integer
Example
1The 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