fsml_mahalanobis Interface

public interface fsml_mahalanobis

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.

Calls

interface~~fsml_mahalanobis~~CallsGraph interface~fsml_mahalanobis fsml_mahalanobis proc~f_lin_mahalanobis f_lin_mahalanobis interface~fsml_mahalanobis->proc~f_lin_mahalanobis proc~f_lin_mahalanobis_core f_lin_mahalanobis_core proc~f_lin_mahalanobis->proc~f_lin_mahalanobis_core proc~s_err_print s_err_print proc~f_lin_mahalanobis->proc~s_err_print proc~f_sts_cov_core f_sts_cov_core proc~f_lin_mahalanobis_core->proc~f_sts_cov_core proc~s_utl_cholesky_solve s_utl_cholesky_solve proc~f_lin_mahalanobis_core->proc~s_utl_cholesky_solve proc~f_utl_r2c f_utl_r2c proc~s_err_print->proc~f_utl_r2c proc~f_sts_mean_core f_sts_mean_core proc~f_sts_cov_core->proc~f_sts_mean_core chol chol proc~s_utl_cholesky_solve->chol

Module Procedures

public impure function f_lin_mahalanobis(x, y, cov) result(dist)

Impure wrapper function for f_lin_mahalanobis_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(:)

input vector 1

real(kind=wp), intent(in) :: y(:)

input vector 2

real(kind=wp), intent(in), optional :: cov(:,:)

covariance matrix

Return Value real(kind=wp)

Mahalanobis distance