pub fn is_diagonal(m: &Matrix3<f64>) -> bool
Expand description
Checks if the provided 3x3 matrix is diagonal.
A square matrix is considered diagonal if all its off-diagonal elements are zero.
This function verifies this property for a given 3x3 matrix.
It checks each off-diagonal element of the matrix and returns false
if any of them
is not approximately zero, considering a tolerance defined by f64::EPSILON
.
§Arguments
m
- A 3x3 matrix off64
elements to be checked.
§Returns
bool
- Returnstrue
if the matrix is diagonal,false
otherwise.
§Example
use nyx_space::utils::is_diagonal;
use nyx_space::linalg::Matrix3;
let m = Matrix3::new(1.0, 0.0, 0.0,
0.0, 2.0, 0.0,
0.0, 0.0, 3.0);
assert_eq!(is_diagonal(&m), true);
§Note
This function uses f64::EPSILON
as the tolerance for checking if an element is approximately zero.
This means that elements with absolute value less than f64::EPSILON
are considered zero.