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

Method sqrtm

ot/backend.py:2397–2403  ·  view source on GitHub ↗
(self, a)

Source from the content-addressed store, hash-verified

2395 return torch.linalg.pinv(a, hermitian=hermitian)
2396
2397 def sqrtm(self, a):
2398 L, V = torch.linalg.eigh(a)
2399 L = torch.sqrt(L)
2400 # Q[...] = V[...] @ diag(L[...])
2401 Q = torch.einsum("...jk,...k->...jk", V, L)
2402 # R[...] = Q[...] @ V[...].T
2403 return torch.einsum("...jk,...kl->...jl", Q, torch.transpose(V, -1, -2))
2404
2405 def eigh(self, a):
2406 return torch.linalg.eigh(a)

Callers

nothing calls this directly

Calls 4

eighMethod · 0.45
sqrtMethod · 0.45
einsumMethod · 0.45
transposeMethod · 0.45

Tested by

no test coverage detected