Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Simulation/QsharpCore/Core.qs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ namespace Microsoft.Quantum.Core {
/// # Summary
/// Compiler-recognized attribute used to mark a type or callable as deprecated.
///
/// # Input
/// # Named Items
/// ## NewName
/// The full name of the type or callable to use instead.
/// Is set to the empty String if a type or callable has been deprecated without substitution.
///
@Attribute()
newtype Deprecated = (NewName : String);


/// # Summary
/// Returns a default instance of the specified type.
///
Expand Down Expand Up @@ -136,5 +135,3 @@ namespace Microsoft.Quantum.Core {
}

}


23 changes: 11 additions & 12 deletions src/Simulation/QsharpCore/Intrinsic.qs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.Quantum.Intrinsic {
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Targeting;

@Deprecated("Microsoft.Quantum.Random.DrawCategorical")
operation Random (probs : Double[]) : Int {
Expand Down Expand Up @@ -657,24 +658,26 @@ namespace Microsoft.Quantum.Intrinsic {
operation M (qubit : Qubit) : Result {
return Measure([PauliZ], [qubit]);
}


/// # Summary
/// Given a single qubit, measures it and ensures it is in the |0⟩ state
/// such that it can be safely released.
///
/// # Input
/// ## qubit
/// ## target
/// The qubit whose state is to be reset to $\ket{0}$.
@RequiresCapability(
"BasicQuantumFunctionality",
"Reset is replaced by a supported implementation on all execution targets."
)
operation Reset (target : Qubit) : Unit {

if (M(target) == One)
{
if (M(target) == One) {
X(target);
}
}


/// # Summary
/// Given an array of qubits, measure them and ensure they are in the |0⟩ state
/// such that they can be safely released.
Expand All @@ -683,12 +686,8 @@ namespace Microsoft.Quantum.Intrinsic {
/// ## qubits
/// An array of qubits whose states are to be reset to $\ket{0}$.
operation ResetAll (qubits : Qubit[]) : Unit {

for (qubit in qubits) {
Reset(qubit);
}
}

}


39 changes: 39 additions & 0 deletions src/Simulation/QsharpCore/Targeting.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/// # Summary
/// This namespace provides functionality for targeting specific quantum processors.
namespace Microsoft.Quantum.Targeting {
/// # Summary
/// Compiler-recognized attribute used to mark a callable with the runtime capabilities it
/// requires.
///
/// # Named Items
/// ## Level
/// The name of the runtime capability level required by the callable.
///
/// ## Reason
/// A description of why the callable requires this runtime capability.
///
/// # Remarks
/// This attribute is automatically added to callables by the compiler, unless an instance of
/// this attribute already exists on the callable. It should not be used except in rare cases
/// where the compiler does not infer the required capability correctly.
///
/// Below is the list of capability level names, in order of increasing capabilities or
/// decreasing restrictions:
///
/// ## `"BasicQuantumFunctionality"`
/// Measurement results cannot be compared for equality.
///
/// ## `"BasicMeasurementFeedback"`
/// Measurement results can be compared for equality only in if-statement conditional
/// expressions in operations. The block of an if-statement that depends on a result cannot
/// contain set statements for mutable variables declared outside the block, or return
/// statements.
///
/// ## `"FullComputation"`
/// No runtime restrictions. Any Q# program can be executed.
@Attribute()
newtype RequiresCapability = (Level : String, Reason : String);
}