Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 qubit unitary_to_observation has extra factor of 1/2 #34

Open
Farquhar13 opened this issue Feb 13, 2024 · 3 comments
Open

2 qubit unitary_to_observation has extra factor of 1/2 #34

Farquhar13 opened this issue Feb 13, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@Farquhar13
Copy link
Collaborator

Is this correct @choihrM3?

In the single qubit env:

    def unitary_to_observation(self, U):
        return (
            np.array(
                [(abs(x), (cmath.phase(x) / np.pi + 1) / 2) for x in U.flatten()],
                dtype=np.float64,
            )
            .squeeze()
            .reshape(-1)
        )

In the two qubit env:

def unitary_to_observation(self, U):
        return (
            np.array(
                [(abs(x), (cmath.phase(x) / 2 / np.pi + 1) / 2) for x in U.flatten()], 
                dtype=np.float64,
                )
            .squeeze()
            .reshape(-1)  # cmath phase gives -2pi to 2pi (?)
        )
@Farquhar13 Farquhar13 added the question Further information is requested label Feb 13, 2024
@Farquhar13
Copy link
Collaborator Author

If the extra /2 is not needed than we can have the two qubit env inherit this method.

@choihrM3
Copy link
Collaborator

choihrM3 commented Mar 6, 2024

extra "/2" is not needed, and I believe "self.observation_space" should be also fixed?

@Farquhar13
Copy link
Collaborator Author

@choihrM3 I don't think this should affect self.observation_space. If the extra \2 factor is fixed on your current 2-qubit work, then I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants