What is the simplest method to check if a matrix contains only zeros? If there's a method specifically for square matrices, I'm interested in that as well, but a solution for matrices of any dimensions would be more useful.

Piotr

ROWNORM or COLNORM will return 0 if there is only zeros in the matrix.

(10-07-2023 01:54 PM)Didier Lachieze Wrote: [ -> ]ROWNORM or COLNORM will return 0 if there is only zeros in the matrix.

ABS applied to a matrix will also return 0 only if the matrix is all zeros.

It actually computes the

Frobenius norm so it might be slightly slower than the norms you mention, but it looks much cleaner and understandable in the source code.

V.

(10-07-2023 01:54 PM)Didier Lachieze Wrote: [ -> ]ROWNORM or COLNORM will return 0 if there is only zeros in the matrix.

(10-07-2023 04:15 PM)Valentin Albillo Wrote: [ -> ]ABS applied to a matrix will also return 0 only if the matrix is all zeros.

Didier, Valentin,

Thank you for both answers. Both provide exactly what I was looking for.