Computes the Mahalanobis distance between two input feature vectors x and y.
If a covariance matrix cov is provided, it is used directly in the calculation.
Otherwise, the procedure estimates the covariance matrix from the two-sample dataset
formed by x and y. A Cholesky-based solver is used to perform the distance
calculation.
The Mahalanobis distance is defined as:
where is the covariance matrix. The inverse is applied via
the Cholesky decomposition for numerical stability.
Note: If passed, the covariance matrix (cov) must be positive definite
for the factorisation to succeed.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.