pub fn determinant_tensor<T, S, I>(tensor: I) -> Option<T>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    I: Into<TensorView<T, S, 2>>,
    S: TensorRef<T, 2>,
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.

The first dimension in the Tensor’s shape will be taken as the rows of the matrix, and the second dimension as the columns. If you instead have columns and then rows for the Tensor’s shape, you should reorder the Tensor before calling this function to get the appropriate matrix.

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 Tensor, 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_tensor::<f32, _, _>(&tensor)

Alternatively, the compiler doesn’t seem to run into this problem if you use the equivalent methods on the tensor type like so: tensor.determinant()