Example #1
0
 def retr(self, X, U, mode="default"):
     if mode == "exp":
         return self.exp(X, U)
     elif mode == "qr":
         YR, YI = frac(X + U)
         Q, R = tensor.nlinalg.qr(YR + 1j * YI)
         Y = tensor.stack([Q.real, Q.imag])
         return Y
     elif mode == "svd":
         YR, YI = frac(X + U)
         U, S, V = tensor.nlinalg.svd(YR + 1j * YI, full_matrices=False)
         Y = U.dot(tensor.eye(S.size)).dot(V)
         Y = tensor.stack([Y.real, Y.imag])
         return Y
     elif mode == "cayley":
         A = complex_dot(hconj(U), X) + complex_dot(hconj(X), U)
         return complex_dot(
             complex_matrix_inverse(identity(self._n) + 0.5 * A),
             (identity(self._n) - 0.5 * A))
     elif mode == "default":
         return self.retr(X, U, mode=self.retr_mode)
     else:
         raise ValueError(
             'mode must equal to "svd", "qr", "exp" or "default", but "{}" is given'
             .format(mode))
Example #2
0
 def exp(self, X, U):
     # The exponential (in the sense of Lie group theory) of a tangent
     # vector U at X.
     first = self.concat([X, U], axis=1)
     XhU = complex_dot(hconj(X), U)
     second = complex_expm(self.concat([self.concat([XhU, -complex_dot(hconj(U), U)], 1),
                               self.concat([identity(self._n), XhU], 1)], 0))
     third = self.concat([complex_expm(-XhU), zeros((self._n, self._n))], 0)
     exponential = complex_dot(complex_dot(first, second), third)
     return exponential
Example #3
0
 def exp(self, X, U):
     # The exponential (in the sense of Lie group theory) of a tangent
     # vector U at X.
     first = self.concat([X, U], axis=1)
     XhU = complex_dot(hconj(X), U)
     second = complex_expm(
         self.concat([
             self.concat([XhU, -complex_dot(hconj(U), U)], 1),
             self.concat([identity(self._n), XhU], 1)
         ], 0))
     third = self.concat([complex_expm(-XhU), zeros((self._n, self._n))], 0)
     exponential = complex_dot(complex_dot(first, second), third)
     return exponential
Example #4
0
 def ehess2rhess(self, X, egrad, ehess, H):
     XHG = complex_dot(hconj(X), egrad)
     #XHG = X.conj().dot(egrad)
     herXHG = self.herm(XHG)
     HherXHG = complex_dot(H, herXHG)
     rhess = self.proj(X, ehess - HherXHG)
     return rhess
Example #5
0
 def ehess2rhess(self, X, egrad, ehess, H):
     XHG = complex_dot(hconj(X), egrad)
     #XHG = X.conj().dot(egrad)
     herXHG = self.herm(XHG)
     HherXHG = complex_dot(H, herXHG)
     rhess = self.proj(X, ehess - HherXHG)
     return rhess
Example #6
0
 def ehess2rhess(self, X, egrad, ehess, H):
     # TODO implement this for future
     XHG = complex_dot(hconj(X), egrad)
     #XHG = X.conj().dot(egrad)
     herXHG = self.herm(XHG)
     HherXHG = complex_dot(H, herXHG)
     rhess = self.proj(X, ehess - HherXHG)
     return rhess
Example #7
0
 def retr(self, X, U, mode="default"):
     if mode == "exp":
         return self.exp(X, U)
     elif mode == "qr":
         YR, YI = frac(X + U)
         Q, R = tensor.nlinalg.qr(YR + 1j * YI)
         Y = tensor.stack([Q.real, Q.imag])
         return Y
     elif mode == "svd":
         YR, YI = frac(X + U)
         U, S, V = tensor.nlinalg.svd(YR + 1j * YI, full_matrices=False)
         Y = U.dot(tensor.eye(S.size)).dot(V)
         Y = tensor.stack([Y.real, Y.imag])
         return Y
     elif mode == "cayley":
         A = complex_dot(hconj(U), X) + complex_dot(hconj(X), U)
         return complex_dot(complex_matrix_inverse(identity(self._n) + 0.5 * A),
                            (identity(self._n) - 0.5 * A))
     elif mode == "default":
         return self.retr(X, U, mode=self.retr_mode)
     else:
         raise ValueError('mode must equal to "svd", "qr", "exp" or "default", but "{}" is given'.format(mode))
Example #8
0
 def herm(self, X):
     Xman = skew_hermitian_expm(X)
     XH = hconj(Xman)
     return 0.5 * (Xman + XH)
Example #9
0
 def proj(self, X, U):
     XHU = complex_dot(hconj(X), U)
     herXHU = self.herm(XHU)
     Up = U - complex_dot(X, herXHU)
     return Up
Example #10
0
 def herm(self, X):
     XH = hconj(X)
     return 0.5 * (X + XH)
Example #11
0
 def hconj(self, X):
     return tuple(hconj(x) for (manifold, x) in zip(self._manifolds, X))
Example #12
0
 def hconj(self, X):
     return tuple(hconj(x) for (manifold, x) in zip(self._manifolds, X))
Example #13
0
 def proj(self, X, U):
     XHU = complex_dot(hconj(X), U)
     herXHU = self.herm(XHU)
     Up = U - complex_dot(X, herXHU)
     return Up
Example #14
0
 def herm(self, X):
     XH = hconj(X)
     return 0.5 * (X + XH)