Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@msoeken
Copy link
Member

@msoeken msoeken commented Apr 6, 2022

No description provided.

@msoeken msoeken requested review from cgranade and tcNickolas April 6, 2022 16:53
Copy link
Contributor

@cgranade cgranade left a comment

Choose a reason for hiding this comment

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

Approved with minor comments. Thanks!

/// # See Also
/// - Microsoft.Quantum.Canon.SinglyControlledA
function SinglyControlled<'T>(op : 'T => Unit is Ctl) : (Qubit, 'T) => Unit is Ctl {
return ApplySinglyControlled(op, _, _);
Copy link
Contributor

Choose a reason for hiding this comment

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

You may be able to write this as a lambda now:

Suggested change
return ApplySinglyControlled(op, _, _);
return (ctrl, originalInput) => Controlled op([ctrl], originalInput);

Not sure if that generates the right characteristics, as I've not tested that yet, sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's awesome! And the recent commit confirms it works.

open Microsoft.Quantum.Intrinsic;

@Test("ToffoliSimulator")
operation TestSinglyControlled() : Unit {
Copy link
Contributor

Choose a reason for hiding this comment

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

For testing, this is great, but I may also suggest an AssertOperationsEqualReferenced call for something like H:

AssertOperationsEqualReferenced(2,
     (qs) => SinglyControlled(H)(qs[0], qs[1]),
     (qs) => Controlled H([qs[0]], qs[1])
);

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this test case.

@msoeken msoeken merged commit c246868 into main Apr 7, 2022
@msoeken msoeken deleted the msoeken/pr4-442 branch April 7, 2022 06:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants