pub fn determinant<T: Numeric>(matrix: &Matrix<T>) -> Option<T>where
for<'a> &'a T: NumericRef<T>,
Expand description
Computes the determinant of a square matrix. For a 2 x 2 matrix this is given by
ad - bc
for:
[
a, b
c, d
]
This function will return the determinant only if it exists. Non square matrices do not have a determinant. A determinant is a scalar value computed from the elements of a square matrix and often corresponds to matrices with special properties.
Note that the determinant of a 1 x 1 matrix is just the element in the matrix.
This function computes the determinant using the same type as that of the Matrix, hence if the input type is unsigned (such as Wrapping<u8>) the value computed is likely to not make any sense because a determinant may be negative.
https://en.wikipedia.org/wiki/Determinant
§Warning
With some uses of this function the Rust compiler gets confused about what type T
should be and you will get the error:
overflow evaluating the requirement
&'a _: easy_ml::numeric::NumericByValue<_, _>
In this case you need to manually specify the type of T by using the
turbofish syntax like:
linear_algebra::determinant::<f32>(&matrix)
Alternatively, the compiler doesn’t seem to run into this problem if you
use the equivalent methods on the matrix type like so:
matrix.determinant()