MCPcopy Create free account
hub / github.com/PythonOT/POT / exp_bures

Function exp_bures

ot/utils.py:1428–1456  ·  view source on GitHub ↗

r""" Exponential map in Bures-Wasserstein space at Sigma: .. math:: \exp_\Sigma(S) = (I_d+S)\Sigma(I_d+S). Parameters ---------- Sigma : array-like (d,d) SPD matrix S : array-like (d,d) Symmetric matrix nx : module, optional The numerical

(Sigma, S, nx=None)

Source from the content-addressed store, hash-verified

1426
1427
1428def exp_bures(Sigma, S, nx=None):
1429 r"""
1430 Exponential map in Bures-Wasserstein space at Sigma:
1431
1432 .. math::
1433 \exp_\Sigma(S) = (I_d+S)\Sigma(I_d+S).
1434
1435 Parameters
1436 ----------
1437 Sigma : array-like (d,d)
1438 SPD matrix
1439 S : array-like (d,d)
1440 Symmetric matrix
1441 nx : module, optional
1442 The numerical backend module to use. If not provided, the backend will
1443 be fetched from the input matrices `Sigma, S`.
1444
1445 Returns
1446 -------
1447 P : array-like (d,d)
1448 SPD matrix obtained as the exponential map of S at Sigma
1449 """
1450 if nx is None:
1451 nx = get_backend(Sigma, S)
1452 d = S.shape[-1]
1453 Id = nx.eye(d, type_as=S)
1454 C = Id + S
1455
1456 return nx.einsum("ij,jk,kl -> il", C, Sigma, C)
1457
1458
1459def check_number_threads(numThreads):

Callers 1

Calls 3

get_backendFunction · 0.85
eyeMethod · 0.45
einsumMethod · 0.45

Tested by

no test coverage detected