HP Forums
Checking if a matrix contains only zeros - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Checking if a matrix contains only zeros (/thread-20598.html)



Checking if a matrix contains only zeros - komame - 10-07-2023 12:59 PM

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


RE: Checking if a matrix contains only zeros - Didier Lachieze - 10-07-2023 01:54 PM

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


RE: Checking if a matrix contains only zeros - Valentin Albillo - 10-07-2023 04:15 PM

(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.


RE: Checking if a matrix contains only zeros - komame - 10-07-2023 06:59 PM

(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.