Skip to content

Conversation

@maxglick
Copy link
Contributor

@maxglick maxglick commented Dec 5, 2025

Add a phased classical action for SelectedMajoranaFermion.
The classical action only exists for some choices of target_gate, and we assume specifically target_gate=cirq.X (and also that there is only 1 control register and 1 selection register).

Fixes #1699

Comment on lines +144 to +145
if len(self.control_registers) > 1 or len(self.selection_registers) > 1:
return NotImplemented
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this restriction necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - it is hard for me to understand what this gate does in the general case. Is my understanding in #1699 (comment) correct?

Comment on lines 142 to 143
if self.target_gate != cirq.X:
return NotImplemented
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In combination with basis_state_phase, this should be able to support Z as well. Z imparts a phase (and leaves the computational basis states unaffected)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now added Z.

Comment on lines +152 to +153
max_selection = self.selection_registers[0].dtype.iteration_length_or_zero() - 1
target = (2 ** (max_selection - selection)) ^ target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment describing how this logic works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write classical simulation tests for SelectedMajoranaFermion

2 participants