mean_harm_spd#

hypercoil.functional.semidefinite.mean_harm_spd(input: Tensor, axis: int | Sequence[int] = 0, require_nonsingular: bool = True) Tensor[source]#

The harmonic mean is computed as the matrix inverse of the Euclidean mean of matrix inverses:

\(\bar{X} = \left(\frac{1}{N}\sum_{i=1}^N X_{i}^{-1}\right)^{-1}\)

Dimension:
Input : \((N, *, D, D)\)

N denotes batch size, * denotes any number of intervening dimensions, D denotes matrix row and column dimension.

Output : \((*, D, D)\)

As above.

Parameters:
inputTensor

Batch of matrices over which the Euclidean mean is to be computed.

axisint

Axis or axes over which the mean is computed.

require_nonsingularbool (default True)

Indicates that the input matrix must be nonsingular. If this is False, then the Moore-Penrose pseudoinverse is computed instead of the inverse.

Returns:
outputTensor

Log-Euclidean mean of the input batch.