(self, a)
| 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) |