Checking if a matrix contains only zeros
|
10-07-2023, 12:59 PM
Post: #1
|
|||
|
|||
Checking if a matrix contains only zeros
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 |
|||
10-07-2023, 01:54 PM
Post: #2
|
|||
|
|||
RE: Checking if a matrix contains only zeros
ROWNORM or COLNORM will return 0 if there is only zeros in the matrix.
|
|||
10-07-2023, 04:15 PM
Post: #3
|
|||
|
|||
RE: Checking if a matrix contains only zeros
(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. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
10-07-2023, 06:59 PM
Post: #4
|
|||
|
|||
RE: Checking if a matrix contains only zeros
(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. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)