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

Method sqrtm

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

Source from the content-addressed store, hash-verified

2821 return cp.linalg.pinv(a)
2822
2823 def sqrtm(self, a):
2824 L, V = cp.linalg.eigh(a)
2825 L = cp.sqrt(L)
2826 # Q[...] = V[...] @ diag(L[...])
2827 Q = cp.einsum("...jk,...k->...jk", V, L)
2828 # R[...] = Q[...] @ V[...].T
2829 return cp.einsum("...jk,...kl->...jl", Q, cp.swapaxes(V, -1, -2))
2830
2831 def eigh(self, a):
2832 return cp.linalg.eigh(a)

Callers

nothing calls this directly

Calls 3

eighMethod · 0.45
sqrtMethod · 0.45
einsumMethod · 0.45

Tested by

no test coverage detected