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

Should the rotation axis in ControlledRotYInstruction be [0,1,0]? #40

Open
brunorijsman opened this issue Nov 16, 2022 · 0 comments
Open

Comments

@brunorijsman
Copy link

In file nv.py classes ControlledRotXInstruction and ControlledRotYInstruction both use axis = [1, 0, 0] as the rotation axis.

It seems to me that ControlledRotYInstruction should use axis = [0, 1, 0] as the rotation axis.

Although this seems "obvious", I don't dare to make the change and issue a pull request, because ControlledRotYInstruction is used twice in transpile.py to implement NV operations _move_electron_carbon and _move_carbon_electron. If ControlledRotYInstruction was really wrong, surely those move operations would not work correctly?

@dataclass
class ControlledRotXInstruction(core.ControlledRotationInstruction):
    id: int = 30
    mnemonic: str = "crot_x"

    def to_matrix(self) -> np.ndarray:
        axis = [1, 0, 0]
        angle = self.angle_num.value * np.pi / 2**self.angle_denom.value
        return get_controlled_rotation_matrix(axis, angle)

    def to_matrix_target_only(self) -> np.ndarray:
        axis = [1, 0, 0]
        angle = self.angle_num.value * np.pi / 2**self.angle_denom.value
        return get_rotation_matrix(axis, angle)


@dataclass
class ControlledRotYInstruction(core.ControlledRotationInstruction):
    id: int = 31
    mnemonic: str = "crot_y"

    def to_matrix(self) -> np.ndarray:
        axis = [1, 0, 0]
        angle = self.angle_num.value * np.pi / 2**self.angle_denom.value
        return get_controlled_rotation_matrix(axis, angle)

    def to_matrix_target_only(self) -> np.ndarray:
        axis = [1, 0, 0]
        angle = self.angle_num.value * np.pi / 2**self.angle_denom.value
        return get_rotation_matrix(axis, angle)

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

No branches or pull requests

1 participant