Skip to content

Commit

Permalink
Add example to doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
swernli committed Dec 4, 2024
1 parent 46bf6e0 commit 6881e13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions library/std/src/Std/Intrinsic.qs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,24 @@ operation Z(qubit : Qubit) : Unit is Adj + Ctl {
///
/// # Remarks
/// The matrix is checked at runtime to ensure it's shape is square and that the matrix dimensions are `2 ^ Length(qubits)`.
///
/// # Example
/// This performs a two qubit CNOT using the unitary matrix representation:
/// ```qsharp
/// import Std.Math.Complex;
/// use qs = Qubit[2];
/// let one = new Complex { Real = 1.0, Imag = 0.0 };
/// let zero = new Complex { Real = 0.0, Imag = 0.0 };
/// ApplyUnitary(
/// [
/// [one, zero, zero, zero],
/// [zero, one, zero, zero],
/// [zero, zero, zero, one],
/// [zero, zero, one, zero]
/// ],
/// qs
/// );
/// ```
@Config(Unrestricted)
operation ApplyUnitary(matrix : Complex[][], qubits : Qubit[]) : Unit {
let num_rows = Length(matrix);
Expand Down

0 comments on commit 6881e13

Please sign in to comment.