Пример #1
0
    def testPhase(self):
        """Check that the Hopf map is invariant under multiplication 
        by a random phase."""

        X = hopf(self.psi)

        theta = random_vector(self.N) # Column vector of phases
        phase = hstack(np.exp(1j*theta), 2)

        self.assertTrue(is_float_equal(X, hopf(phase*self.psi)))
Пример #2
0
    def testInverse(self):
        """Check that Hopf map composed with its inverse yield the identity."""

        # Hopf composed with the inverse should give the identity exactly
        X1 = hopf(inverse_hopf(self.X)) 
        self.assertTrue(is_float_equal(X1, self.X))

        # Inverse hopf composed with Hopf gives the identity up to phase
        psi1 = inverse_hopf(hopf(self.psi))
        phases = psi1/self.psi

        # Test whether columns of phase matrix are equal
        self.assertTrue(is_float_equal(phases[:, 0], phases[:, 1]))
        # Test whether column elements have unit norm
        p = phases[:, 0]
        self.assertTrue(is_float_equal(p*p.conjugate(), np.ones(self.N)))