Merge remote-tracking branch 'public/master' into cgranade/python-xplat

This commit is contained in:
Christopher Granade 2019-02-26 08:53:46 -08:00
Родитель 4acc80efbd a872d05008
Коммит 3b88a42415
46 изменённых файлов: 241 добавлений и 207 удалений

Просмотреть файл

@ -58,7 +58,7 @@ namespace Microsoft.Quantum.Canon
// instead of reflections.
// Note that amplitude amplification is a special case of oblivious
// amplitude amplifiction where `ObliviousOracle` is the identity operator,
// amplitude amplification where `ObliviousOracle` is the identity operator,
// and there are no system qubits i.e. `systemRegister` is empty.
// This is called through the operation `AmpAmByReflectionPhases` and
@ -332,8 +332,8 @@ namespace Microsoft.Quantum.Canon
/// An operation that implements amplitude amplification by partial reflections.
///
/// # Remarks
/// Amplitude amplification is a special case of oblivous amplitude amplification where there are no system qubits and the oblivious oracle is set to identity.
/// In most cases, `startQubits` is initialized in the state $\ket{\text{start}}\_1$, which is the $-1$ eigenstate of `startStateReflection`
/// Amplitude amplification is a special case of oblivious amplitude amplification where there are no system qubits and the oblivious oracle is set to identity.
/// In most cases, `startQubits` is initialized in the state $\ket{\text{start}}\_1$, which is the $-1$ eigenstate of `startStateReflection`.
function AmpAmpByReflectionsPhases (phases : AmpAmpReflectionPhases, startStateReflection : ReflectionOracle, targetStateReflection : ReflectionOracle) : (Qubit[] => Unit : Adjoint, Controlled)
{
// Pass empty qubit array using fact that NoOp does nothing.

Просмотреть файл

@ -41,7 +41,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Represents an oracle for state preparation.
///
/// The inputs to the opracle $O$ are:
/// The inputs to the oracle $O$ are:
/// - An integer indexing the flag qubit $f$.
/// - The system register $s$ that will store the desired quantum state $\ket{\psi}\_s$.
///

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.Quantum.Canon
/// A quantum register which is used to store `value` in little-endian encoding.
///
/// # See Also
/// - InPlaceXorLE
/// - InPlaceXorBE
operation InPlaceXorLE (value : Int, target : LittleEndian) : Unit
{
body (...)
@ -67,7 +67,7 @@ namespace Microsoft.Quantum.Canon
/// A quantum register which is used to store `value` in big-endian encoding.
///
/// # See Also
/// - InPlaceXorBE
/// - InPlaceXorLE
operation InPlaceXorBE(value : Int, target : BigEndian) : Unit {
body (...) {
ApplyReversedOpLittleEndianCA(InPlaceXorLE(value, _), target);
@ -80,11 +80,15 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// This computes the Majority function in-place on 3 qubits.
///
/// If we denote output qubit as $z$ and input qubits as $x$ and $y$,
/// the operation performs the following transformation:
/// $\ket{xyz} \rightarrow \ket{x \oplus z} \ket{y \oplus z} \ket{\operatorname{MAJ} (x, y, z)}$.
///
/// # Input
/// ## output
/// First input qubit. Note that the output is computed in-place
/// and stored in this qubit.
/// ## Input
/// ## input
/// Second and third input qubits.
operation InPlaceMajority(output: Qubit, input: Qubit[]) : Unit {
body (...){
@ -115,9 +119,9 @@ namespace Microsoft.Quantum.Canon
///
/// # Input
/// ## x
/// First nubmer to be compared stored in `LittleEndian` format in a qubit register.
/// First number to be compared stored in `LittleEndian` format in a qubit register.
/// ## y
/// Second nubmer to be compared stored in `LittleEndian` format in a qubit register.
/// Second number to be compared stored in `LittleEndian` format in a qubit register.
/// ## output
/// Qubit that stores the result of the comparison $x>y$.
///
@ -133,9 +137,9 @@ namespace Microsoft.Quantum.Canon
fail "Size of integer registers must be equal.";
}
using(auxillary = Qubit()){
using(auxiliary = Qubit()){
WithCA(
ApplyRippleCarryComparatorLE_(x, y, [auxillary], _),
ApplyRippleCarryComparatorLE_(x, y, [auxiliary], _),
BindCA([X, CNOT(x![nQubitsX-1], _)]),
output
);
@ -147,14 +151,14 @@ namespace Microsoft.Quantum.Canon
}
// Implementation step of `ApplyRippleCarryComparatorLE`.
operation ApplyRippleCarryComparatorLE_(x: LittleEndian, y: LittleEndian, auxillary: Qubit[], output: Qubit) : Unit {
operation ApplyRippleCarryComparatorLE_(x: LittleEndian, y: LittleEndian, auxiliary: Qubit[], output: Qubit) : Unit {
body (...) {
let nQubitsX = Length(x!);
// Take 2's complement
ApplyToEachCA(X, x! + auxillary);
ApplyToEachCA(X, x! + auxiliary);
InPlaceMajority(x![0], [y![0], auxillary[0]]);
InPlaceMajority(x![0], [y![0], auxiliary[0]]);
for(idx in 1..nQubitsX - 1){
InPlaceMajority(x![idx], [x![idx - 1], y![idx]]);
}
@ -206,9 +210,9 @@ namespace Microsoft.Quantum.Canon
///
/// # Input
/// ## x
/// First nubmer to be compared stored in `BigEndian` format in a qubit register.
/// First number to be compared stored in `BigEndian` format in a qubit register.
/// ## y
/// Second nubmer to be compared stored in `BigEndian` format in a qubit register.
/// Second number to be compared stored in `BigEndian` format in a qubit register.
/// ## output
/// Qubit that stores the result of the comparison $x>y$.
///
@ -289,7 +293,7 @@ namespace Microsoft.Quantum.Canon
/// The integer by which the `target` is incremented by.
///
/// # See Also
/// - Microsoft.Quantum.Canon.IntegerIncrementLE"
/// - Microsoft.Quantum.Canon.IntegerIncrementLE
///
/// # References
/// - [ *Thomas G. Draper*,
@ -592,7 +596,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Performs a modular multipy-and-add by integer constants on a qubit register.
/// Performs a modular multiply-and-add by integer constants on a qubit register.
///
/// Implements the map
/// $$
@ -639,7 +643,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// The same as ModularAddProductInPlaceLE, but assumes that summand encodes
/// The same as ModularAddProductLE, but assumes that summand encodes
/// integers in QFT basis
///
/// # See Also

Просмотреть файл

@ -123,7 +123,8 @@ namespace Microsoft.Quantum.Canon
/// each `idx`. If the two arrays are not of equal length, the output will
/// be as long as the shorter of the inputs.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// let left = [1, 3, 71];
/// let right = [false, true];
@ -238,7 +239,8 @@ namespace Microsoft.Quantum.Canon
/// such that `output[1]` is the second such element, and so
/// forth.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// let array = [10, 11, 12, 13, 14, 15];
/// // The following line returns [10, 12, 15].
@ -300,7 +302,8 @@ namespace Microsoft.Quantum.Canon
/// An array `output` that is the `inputArray` padded at the head
/// with `defaultElement`s until `output` has length `nElementsTotal`
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// let array = [10, 11, 12];
/// // The following line returns [10, 12, 15, 2, 2, 2].
@ -329,7 +332,7 @@ namespace Microsoft.Quantum.Canon
}
/// # Summary
/// Creates an array `arr` of integers enumnerated by start..step..end.
/// Creates an array `arr` of integers enumerated by start..step..end.
///
/// # Input
/// ## range
@ -338,7 +341,8 @@ namespace Microsoft.Quantum.Canon
/// # Output
/// A new array of integers corresponding to values iterated over by `range`.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// // The following returns [1,3,5,7];
/// let array = IntArrayFromRange(1..2..8);
@ -370,11 +374,12 @@ namespace Microsoft.Quantum.Canon
/// Input array to be split.
///
/// # Output
/// Multiple arrays where the first array is the first 'nElements[0]' of `arr`
/// and the second array are the next 'nElements[1]' of `arr` etc. The last array
/// Multiple arrays where the first array is the first `nElements[0]` of `arr`
/// and the second array are the next `nElements[1]` of `arr` etc. The last array
/// will contain all remaining elements.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// // The following returns [[1,5],[3],[7]];
/// let (arr1, arr2) = SplitArray([2,1], [1,5,3,7]);

Просмотреть файл

@ -31,7 +31,8 @@ namespace Microsoft.Quantum.Canon
/// ## tolerance
/// Absolute tolerance on the difference between actual and expected.
///
/// # Example
/// # Remarks
/// ## Example
/// Suppose that the `qubits` register encodes a 3-qubit quantum state
/// $\ket{\psi}=\sqrt{1/8}\ket{0}+\sqrt{7/8}\ket{6}$ in little-endian format.
/// This means that the number states $\ket{0}\equiv\ket{0}\ket{0}\ket{0}$
@ -77,7 +78,8 @@ namespace Microsoft.Quantum.Canon
/// ## tolerance
/// Absolute tolerance on the difference between actual and expected.
///
/// # Example
/// # Remarks
/// ## Example
/// Suppose that the `qubits` register encodes a 3-qubit quantum state
/// $\ket{\psi}=\sqrt{1/8}\ket{0}+\sqrt{7/8}\ket{6}$ in big-endian format.
/// This means that the number states $\ket{0}\equiv\ket{0}\ket{0}\ket{0}$
@ -109,7 +111,8 @@ namespace Microsoft.Quantum.Canon
/// ## tolerance
/// Absolute tolerance on the difference between actual and expected.
///
/// # Example
/// # Remarks
/// ## Example
/// The following assert succeeds:
/// `qubit` is in state $\ket{\psi}=e^{i 0.5}\sqrt{1/2}\ket{0}+e^{i 0.5}\sqrt{1/2}\ket{1}$;
/// - `AssertPhase(0.0,qubit,10e-10);`

Просмотреть файл

@ -19,6 +19,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
</ItemGroup>
</Project>

Просмотреть файл

@ -33,7 +33,8 @@ namespace Microsoft.Quantum.Canon
/// ## 'T
/// The target on which each of the operations in the array act.
///
/// # Example
/// # Remarks
/// ## Example
/// The following are equivalent:
/// ```qsharp
/// let bound = Bind([U, V]);
@ -98,7 +99,8 @@ namespace Microsoft.Quantum.Canon
/// ## 'T
/// The target on which each of the operations in the array act.
///
/// # Example
/// # Remarks
/// ## Example
/// The following are equivalent:
/// ```qsharp
/// let bound = Bind([U, V]);
@ -159,7 +161,8 @@ namespace Microsoft.Quantum.Canon
/// ## 'T
/// The target on which each of the operations in the array act.
///
/// # Example
/// # Remarks
/// ## Example
/// The following are equivalent:
/// ```qsharp
/// let bound = Bind([U, V]);
@ -239,7 +242,8 @@ namespace Microsoft.Quantum.Canon
/// ## 'T
/// The target on which each of the operations in the array act.
///
/// # Example
/// # Remarks
/// ## Example
/// The following are equivalent:
/// ```qsharp
/// let bound = Bind([U, V]);

Просмотреть файл

@ -150,9 +150,9 @@ namespace Microsoft.Quantum.Canon
/// The input type of the operation to be conditionally applied.
///
/// # See Also
/// - Microsoft.Quantum.Canon.ControlledC
/// - Microsoft.Quantum.Canon.ControlledA
/// - Microsoft.Quantum.Canon.ControlledCA
/// - Microsoft.Quantum.Canon.CControlledC
/// - Microsoft.Quantum.Canon.CControlledA
/// - Microsoft.Quantum.Canon.CControlledCA
function CControlled<'T> (op : ('T => Unit)) : ((Bool, 'T) => Unit)
{
return ApplyIf(op, _, _);
@ -176,7 +176,7 @@ namespace Microsoft.Quantum.Canon
/// The input type of the operation to be conditionally applied.
///
/// # See Also
/// - Microsoft.Quantum.Canon.Controlled
/// - Microsoft.Quantum.Canon.CControlled
function CControlledC<'T> (op : ('T => Unit : Controlled)) : ((Bool, 'T) => Unit : Controlled)
{
return ApplyIfC(op, _, _);
@ -200,7 +200,7 @@ namespace Microsoft.Quantum.Canon
/// The input type of the operation to be conditionally applied.
///
/// # See Also
/// - Microsoft.Quantum.Canon.Controlled
/// - Microsoft.Quantum.Canon.CControlled
function CControlledA<'T> (op : ('T => Unit : Adjoint)) : ((Bool, 'T) => Unit : Adjoint)
{
return ApplyIfA(op, _, _);
@ -224,7 +224,7 @@ namespace Microsoft.Quantum.Canon
/// The input type of the operation to be conditionally applied.
///
/// # See Also
/// - Microsoft.Quantum.Canon.Controlled
/// - Microsoft.Quantum.Canon.CControlled
function CControlledCA<'T> (op : ('T => Unit : Controlled, Adjoint)) : ((Bool, 'T) => Unit : Controlled, Adjoint)
{
return ApplyIfCA(op, _, _);

Просмотреть файл

@ -9,7 +9,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Given operations implementing operators `U` and `V`, performs the
/// operation `U<EFBFBD>VU` on a target. That is, this operation
/// operation `UVU` on a target. That is, this operation
/// conjugates `V` with `U`.
///
/// # Input
@ -45,7 +45,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Given operations implementing operators `U` and `V`, performs the
/// operation `U<EFBFBD>VU` on a target. That is, this operation
/// operation `UVU` on a target. That is, this operation
/// conjugates `V` with `U`.
/// The modifier `A` indicates that the inner operation is adjointable.
///
@ -85,9 +85,9 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Given operations implementing operators `U` and `V`, performs the
/// operation `U<EFBFBD>VU` on a target. That is, this operation
/// operation `UVU` on a target. That is, this operation
/// conjugates `V` with `U`.
/// The modifier `C` dicates that the inner operation is controllable.
/// The modifier `C` dictates that the inner operation is controllable.
///
/// # Input
/// ## outerOperation
@ -130,7 +130,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Given operations implementing operators `U` and `V`, performs the
/// operation `U<EFBFBD>VU` on a target. That is, this operation
/// operation `UVU` on a target. That is, this operation
/// conjugates `V` with `U`.
/// The modifier `CA` indicates that the inner operation is controllable
/// and adjointable.

Просмотреть файл

@ -10,7 +10,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Represents a single primitive term in the set of all dynamical generators, e.g.
/// Hermitian operators, for which there exists a map from that generator
/// to time-evolution by that that generator, through `EvolutionSet`.
/// to time-evolution by that generator, through `EvolutionSet`.
///
/// The first element
/// (Int[], Double[]) is indexes that single term -- For instance, the Pauli string
@ -24,7 +24,7 @@ namespace Microsoft.Quantum.Canon
/// > The interpretation of an `GeneratorIndex` is not defined except
/// > with reference to a particular set of generators.
///
/// # Example
/// ## Example
/// Using <xref:microsoft.quantum.canon.paulievolutionset>, the operator
/// $\pi X_2 X_5 Y_9$ is represented as:
/// ```qsharp
@ -211,11 +211,12 @@ namespace Microsoft.Quantum.Canon
/// A `GeneratorIndex` representing a term with coefficient a factor
/// `multiplier` larger.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// let gen = GeneratorIndex(([1,2,3],[coeff]),[1,2,3]);
/// let ((idxPaulis, idxDoubles), idxQubits) = MultiplyGeneratorIndex(multipler, gen);
/// // idxDoubles[0] == multipler * coeff;
/// let ((idxPaulis, idxDoubles), idxQubits) = MultiplyGeneratorIndex(multiplier, gen);
/// // idxDoubles[0] == multiplier * coeff;
/// ```
///
/// # See Also

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Input
/// ## predicate
/// A function from `'T' to Boolean that is used to filter elements.
/// A function from `'T` to Boolean that is used to filter elements.
/// ## array
/// An array of elements over `'T`.
///

Просмотреть файл

@ -27,7 +27,8 @@ namespace Microsoft.Quantum.Canon
/// The final state returned by the folder after iterating over
/// all elements of `array`.
///
/// # Example
/// # Remarks
/// ## Example
/// ```qsharp
/// function Plus(a : Double, b : Double) {
/// return a + b;

Просмотреть файл

@ -67,7 +67,8 @@ namespace Microsoft.Quantum.Canon
/// # Output
/// An array `'U[]` of elements that are mapped by the `mapper` function.
///
/// # Example
/// # Remarks
/// ## Example
/// The following two lines are equivalent:
/// ```qsharp
/// let arr = MapIndex(f, [x0, x1, x2]);

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.Quantum.Canon
/// subset of `array`. On the other hand, if `indices` contains repeated
/// elements, the corresponding elements of `array` will likewise be
/// repeated.
/// If `indices` and `array` are the same length, this this function
/// If `indices` and `array` are the same length, this function
/// provides permutations of `array`.
///
/// # Type Parameters

Просмотреть файл

@ -151,7 +151,7 @@ namespace Microsoft.Quantum.Canon
}
/// # Summary
/// Computes Trotter step size in recursive implementaiton of
/// Computes Trotter step size in recursive implementation of
/// Trotter simulation algorithm.
function _TrotterStepSize (order: Int) : Double {
return 1.0 / (4.0 - PowD(4.0, 1.0 / (2.0 * ToDouble(order) - 1.0)));

Просмотреть файл

@ -100,7 +100,7 @@ namespace Microsoft.Quantum.Canon
/// The `minValue` input then effectively specifies where to cut the
/// unit circle.
///
/// # Example
/// ## Example
/// ```qsharp
/// // Returns 3 π / 2.
/// let y = RealMod(5.5 * PI(), 2.0 * PI(), 0.0);
@ -137,7 +137,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Computes the inverse hyperbolic secant of a number.
/// Computes the inverse hyperbolic sine of a number.
///
/// # Input
/// ## x
@ -174,11 +174,11 @@ namespace Microsoft.Quantum.Canon
/// ## modulus
/// The modulus by which residues are take, must be positive
/// # Output
/// Integer r between 0 and `modulus - 1' such that `value - r' is divisible by modulus
/// Integer $r$ between 0 and `modulus - 1` such that `value - r` is divisible by modulus
///
/// # Remarks
/// This function behaves different to how the operator `%` behaves in C# and Q# as in the result
/// is always a positive integer between between 0 and `modulus - 1', even if value is negative.
/// is always a positive integer between 0 and `modulus - 1`, even if value is negative.
function Modulus (value : Int, modulus : Int) : Int
{
AssertBoolEqual(modulus > 0, true, $"`modulus` must be positive");
@ -199,10 +199,10 @@ namespace Microsoft.Quantum.Canon
/// Let us denote expBase by x, power by p and modulus by N.
/// The function returns xᵖ mod N.
///
/// We assume that N,x are positive and power is non-negative.
/// We assume that $N$, $x$ are positive and power is non-negative.
///
/// # Remarks
/// Takes time proportional to the number of bits in `power`, not the power itself
/// Takes time proportional to the number of bits in `power`, not the `power` itself.
function ExpMod (expBase : Int, power : Int, modulus : Int) : Int
{
AssertBoolEqual(power >= 0, true, $"`power` must be non-negative");
@ -412,7 +412,7 @@ namespace Microsoft.Quantum.Canon
/// Returns the `L(p)` norm of a vector of `Double`s.
///
/// That is, given an array $x$ of type `Double[]`, this returns the $p$-norm
/// $\|x\|_p= (\sum_{j}|x_j|^{p})^{1/p}$.
/// $\|x\|\_p= (\sum_{j}|x_j|^{p})^{1/p}$.
///
/// # Input
/// ## p

Просмотреть файл

@ -30,7 +30,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Remarks
/// This function calls <xref:microsoft.quantum.primitive.random>, so
/// its randomess depends on the implementation of `Random`.
/// its randomness depends on the implementation of `Random`.
operation RandomIntPow2 (maxBits : Int) : Int
{
mutable number = 0;
@ -66,7 +66,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Remarks
/// This function calls <xref:microsoft.quantum.primitive.random>, so
/// its randomess depends on the implementation of `Random`.
/// its randomness depends on the implementation of `Random`.
operation RandomInt (maxInt : Int) : Int
{
mutable nBits = 0;
@ -102,7 +102,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Remarks
/// This function calls <xref:microsoft.quantum.primitive.random>, so
/// its randomess depends on the implementation of `Random`.
/// its randomness depends on the implementation of `Random`.
operation RandomReal (bitsRandom : Int) : Double
{
if (bitsRandom < 1)

Просмотреть файл

@ -6,8 +6,8 @@ namespace Microsoft.Quantum.Canon {
open Microsoft.Quantum.Extensions.Math;
/// # Summary
/// Applies a multiply-controlled unitary operation `U` that applies a
/// unitary `V_j` when controlled by n-qubit number state `|j〉`.
/// Applies a multiply-controlled unitary operation $U$ that applies a
/// unitary $V_j$ when controlled by n-qubit number state $\ket{j}$.
///
/// $U = \sum^{N-1}_{j=0}\ket{j}\bra{j}\otimes V_j$.
///
@ -15,7 +15,7 @@ namespace Microsoft.Quantum.Canon {
/// ## unitaryGenerator
/// A tuple where the first element `Int` is the number of unitaries $N$,
/// and the second element `(Int -> ('T => () : Adjoint, Controlled))`
/// is a fuction that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// is a function that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// operation $V_j$.
///
/// ## index
@ -28,7 +28,7 @@ namespace Microsoft.Quantum.Canon {
/// # Remarks
/// `coefficients` will be padded with identity elements if
/// fewer than $2^n$ are specified. This implementation uses
/// $n-1$ auxillary qubits.
/// $n-1$ auxiliary qubits.
///
/// # References
/// - [ *Andrew M. Childs, Dmitri Maslov, Yunseong Nam, Neil J. Ross, Yuan Su*,
@ -41,8 +41,8 @@ namespace Microsoft.Quantum.Canon {
fail "MultiplexOperations failed. Number of index qubits must be greater than 0.";
}
if (nUnitaries > 0) {
let auxillary = new Qubit[0];
Adjoint MultiplexOperationsFromGenerator_(unitaryGeneratorWithOffset, auxillary, index, target);
let auxiliary = new Qubit[0];
Adjoint MultiplexOperationsFromGenerator_(unitaryGeneratorWithOffset, auxiliary, index, target);
}
}
adjoint auto;
@ -54,7 +54,7 @@ namespace Microsoft.Quantum.Canon {
/// Implementation step of `MultiplexOperationsFromGenerator`.
/// # See Also
/// - Microsoft.Quantum.Canon.MultiplexOperationsFromGenerator
operation MultiplexOperationsFromGenerator_<'T>(unitaryGenerator : (Int, Int, (Int -> ('T => Unit : Adjoint, Controlled))), auxillary: Qubit[], index: BigEndian, target: 'T) : Unit {
operation MultiplexOperationsFromGenerator_<'T>(unitaryGenerator : (Int, Int, (Int -> ('T => Unit : Adjoint, Controlled))), auxiliary: Qubit[], index: BigEndian, target: 'T) : Unit {
body (...) {
let nIndex = Length(index!);
let nStates = 2^nIndex;
@ -70,49 +70,49 @@ namespace Microsoft.Quantum.Canon {
let newControls = BigEndian(index![1..nIndex-1]);
if(nUnitaries > 0){
if(Length(auxillary) == 1 && nIndex==0){
if(Length(auxiliary) == 1 && nIndex==0){
// Termination case
(Controlled Adjoint (unitaryFunction(unitaryOffset)))(auxillary, target);
(Controlled Adjoint (unitaryFunction(unitaryOffset)))(auxiliary, target);
}
elif(Length(auxillary) == 0 && nIndex>=1){
elif(Length(auxiliary) == 0 && nIndex>=1){
// Start case
let newauxillary = [index![0]];
let newauxiliary = [index![0]];
if(nUnitariesRight > 0){
MultiplexOperationsFromGenerator_(rightUnitaries, newauxillary, newControls, target);
MultiplexOperationsFromGenerator_(rightUnitaries, newauxiliary, newControls, target);
}
X(newauxillary[0]);
MultiplexOperationsFromGenerator_(leftUnitaries, newauxillary, newControls, target);
X(newauxillary[0]);
X(newauxiliary[0]);
MultiplexOperationsFromGenerator_(leftUnitaries, newauxiliary, newControls, target);
X(newauxiliary[0]);
}
else{
// Recursion that reduces nIndex by 1 & sets Length(auxillary) to 1.
using(newauxillary = Qubit[1]){
// Recursion that reduces nIndex by 1 & sets Length(auxiliary) to 1.
using(newauxiliary = Qubit[1]){
let op = LogicalANDMeasAndFix_(_, _);
// Naive measurement-free approach uses 4x more T gates with
// let op = (Controlled X);
op(auxillary + [index![0]], newauxillary[0]);
op(auxiliary + [index![0]], newauxiliary[0]);
if(nUnitariesRight > 0){
MultiplexOperationsFromGenerator_(rightUnitaries, newauxillary, newControls, target);
MultiplexOperationsFromGenerator_(rightUnitaries, newauxiliary, newControls, target);
}
(Controlled X)(auxillary, newauxillary[0]);
MultiplexOperationsFromGenerator_(leftUnitaries, newauxillary, newControls, target);
(Controlled X)(auxillary, newauxillary[0]);
(Adjoint op)(auxillary + [index![0]], newauxillary[0]);
(Controlled X)(auxiliary, newauxiliary[0]);
MultiplexOperationsFromGenerator_(leftUnitaries, newauxiliary, newControls, target);
(Controlled X)(auxiliary, newauxiliary[0]);
(Adjoint op)(auxiliary + [index![0]], newauxiliary[0]);
}
}
}
}
adjoint auto;
controlled (controlRegister, (...)) {
MultiplexOperationsFromGenerator_(unitaryGenerator, auxillary + controlRegister, index, target);
MultiplexOperationsFromGenerator_(unitaryGenerator, auxiliary + controlRegister, index, target);
}
adjoint controlled auto;
}
/// # Summary
/// Applies multiply-controlled unitary operation `U` that applies a
/// unitary `V_j` when controlled by n-qubit number state `|j〉`.
/// Applies multiply-controlled unitary operation $U$ that applies a
/// unitary $V_j$ when controlled by n-qubit number state $\ket{j}$.
///
/// $U = \sum^{N-1}_{j=0}\ket{j}\bra{j}\otimes V_j$.
///
@ -120,7 +120,7 @@ namespace Microsoft.Quantum.Canon {
/// ## unitaryGenerator
/// A tuple where the first element `Int` is the number of unitaries $N$,
/// and the second element `(Int -> ('T => () : Adjoint, Controlled))`
/// is a fuction that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// is a function that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// operation $V_j$.
///
/// ## index
@ -149,8 +149,8 @@ namespace Microsoft.Quantum.Canon {
}
/// # Summary
/// Returns a multiply-controlled unitary operation `U` that applies a
/// unitary `V_j` when controlled by n-qubit number state `|j〉`.
/// Returns a multiply-controlled unitary operation $U$ that applies a
/// unitary $V_j$ when controlled by n-qubit number state $\ket{j}$.
///
/// $U = \sum^{2^n-1}_{j=0}\ket{j}\bra{j}\otimes V_j$.
///
@ -158,7 +158,7 @@ namespace Microsoft.Quantum.Canon {
/// ## unitaryGenerator
/// A tuple where the first element `Int` is the number of unitaries $N$,
/// and the second element `(Int -> ('T => () : Adjoint, Controlled))`
/// is a fuction that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// is a function that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// operation $V_j$.
///
/// # Output
@ -172,8 +172,8 @@ namespace Microsoft.Quantum.Canon {
}
/// # Summary
/// Returns a multiply-controlled unitary operation `U` that applies a
/// unitary `V_j` when controlled by n-qubit number state `|j〉`.
/// Returns a multiply-controlled unitary operation $U$ that applies a
/// unitary $V_j$ when controlled by n-qubit number state $\ket{j}$.
///
/// $U = \sum^{2^n-1}_{j=0}\ket{j}\bra{j}\otimes V_j$.
///
@ -181,7 +181,7 @@ namespace Microsoft.Quantum.Canon {
/// ## unitaryGenerator
/// A tuple where the first element `Int` is the number of unitaries $N$,
/// and the second element `(Int -> ('T => () : Adjoint, Controlled))`
/// is a fuction that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// is a function that takes an integer $j$ in $[0,N-1]$ and outputs the unitary
/// operation $V_j$.
///
/// # Output

Просмотреть файл

@ -11,7 +11,7 @@ namespace Microsoft.Quantum.Canon {
/// This can be useful whenever an input of an operation type is expected,
/// but no action should be taken.
/// For instance, if a particular error correction syndrome indicates that
/// no error has occured, `NoOp<Qubit[]>` may be the correct recovery
/// no error has occurred, `NoOp<Qubit[]>` may be the correct recovery
/// procedure.
/// Similarly, if an operation expects a state preparation procedure as
/// input, `NoOp<Qubit[]>` can be used to prepare the state
@ -24,7 +24,7 @@ namespace Microsoft.Quantum.Canon {
/// # Remarks
/// In almost all cases, the type parameter for `NoOp` needs to be specified
/// explicitly. For instance, `NoOp<Qubit>` is identical to
/// @"Microsoft.Quantum.Primitive.I".
/// <xref:microsoft.quantum.primitive.i>.
///
/// # See Also
/// - Microsoft.Quantum.Primitive.I

Просмотреть файл

@ -10,7 +10,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Performs the robust non-terative quantum phase estimation algorithm for a given oracle `U` and eigenstate,
/// Performs the robust non-iterative quantum phase estimation algorithm for a given oracle `U` and eigenstate,
/// and provides a single real-valued estimate of the phase with variance scaling at the Heisenberg limit.
///
/// # Input

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft.Quantum.Canon
/// Represents a continuous-time oracle.
///
/// This is an oracle that implements
/// $U(\delta t) : \ket{\psi(t)} \mapsto \ket{\psi(t + \delta t)}
/// $U(\delta t) : \ket{\psi(t)} \mapsto \ket{\psi(t + \delta t)}$
/// for all times $t$, where $U$ is a fixed operation, and where
/// $\delta t$ is a non-negative real number.
newtype ContinuousOracle = ((Double, Qubit[]) => Unit : Adjoint, Controlled);
@ -32,7 +32,8 @@ namespace Microsoft.Quantum.Canon
/// # Output
/// An operation partially applied over the "black-box" oracle representing the discrete-time oracle
///
/// # Example
/// # Remarks
/// ## Example
/// `OracleToDiscrete(U)(3, target)` is equivalent to `U(target)` repeated three times.
operation OracleToDiscrete (blackBoxOracle : (Qubit[] => Unit : Adjoint, Controlled)) : DiscreteOracle
{

Просмотреть файл

@ -175,17 +175,19 @@ namespace Microsoft.Quantum.Canon
/// If the identity operator is given, then the qubit is prepared in the maximally
/// mixed state.
///
/// That is, given a single qubit initially in the $\ket{0}$ state, prepares the
/// qubit in the $+1$ eigenstate of a given Pauli operator, or in the
/// maximally mixed state for the $\boldone$ Pauli operator `PauliI`.
/// If the qubit was initially in the $\ket{0}$ state, this operation prepares the
/// qubit in the $+1$ eigenstate of a given Pauli operator, or, for `PauliI`,
/// in the maximally mixed state instead (see <xref:microsoft.quantum.canon.preparesinglequbitidentity>).
///
/// If the qubit was in a state other than $\ket{0}$, this operation applies the following gates:
/// $H$ for `PauliX`, $HS$ for `PauliY`, $I$ for `PauliZ` and
/// <xref:microsoft.quantum.canon.preparesinglequbitidentity> for `PauliI`.
///
/// # Input
/// ## basis
/// A Pauli operator $P$ such that measuring $P$ immediately after this
/// operation will return `Zero`.
/// A Pauli operator $P$.
/// ## qubit
/// A qubit initially in the $\ket{0}$ state which is to be prepared in
/// the given basis.
/// A qubit to be prepared.
operation PrepareQubit (basis : Pauli, qubit : Qubit) : Unit
{
if (basis == PauliI)
@ -351,7 +353,7 @@ namespace Microsoft.Quantum.Canon
/// The Result `Zero` with probability
/// $$
/// \begin{align}
/// \Pr(\texttt{Zero} | \Lambda; P, Q) = \Tr\left(
/// \Pr(\texttt{Zero} | \Lambda; P, Q) = \operatorname{Tr}\left(
/// \frac{\boldone + Q}{2} \Lambda\left[
/// \frac{\boldone + P}{2}
/// \right]
@ -366,7 +368,7 @@ namespace Microsoft.Quantum.Canon
/// is identical to
/// $$
/// \begin{align}
/// \Pr(\texttt{Zero} | \rho; M) = \Tr(M \rho),
/// \Pr(\texttt{Zero} | \rho; M) = \operatorname{Tr}(M \rho),
/// \end{align}
/// $$
/// where $M = 2 (\boldone + P)^\mathrm{T} / 2 \cdot (\boldone + Q) / 2$

Просмотреть файл

@ -58,9 +58,9 @@ namespace Microsoft.Quantum.Canon
///
/// # Remarks
/// By iterating over all errors of weight $1$, we obtain a total of $3\times 5=15$ possible non-trivial syndromes.
/// Together with the identity, a table of error and corresponding syndrom is built up. For the 5 qubit code
/// this table is given by: $X\_1: (0,0,0,1); X\_2: (1,0,0,0); X\_3: (1,1,0,0); X\_4: (0,1,1,0); X\_5: (0,0,1,1),
/// Z\_1: (1,0,1,0); Z\_2: (0,1,0,1); Z\_3: (0,0,1,0); Z\_4: (1,0,0,1); Z\_5: (0,1,0,0)$ with $Y_i$ obtained by adding the $X_i$ and $Z_i$ syndromes. Note that the
/// Together with the identity, a table of error and corresponding syndrome is built up. For the 5 qubit code
/// this table is given by: $X\_1: (0,0,0,1); X\_2: (1,0,0,0); X\_3: (1,1,0,0); X\_4: (0,1,1,0); X\_5: (0,0,1,1)$,
/// $Z\_1: (1,0,1,0); Z\_2: (0,1,0,1); Z\_3: (0,0,1,0); Z\_4: (1,0,0,1); Z\_5: (0,1,0,0)$ with $Y_i$ obtained by adding the $X_i$ and $Z_i$ syndromes. Note that the
/// ordering in the table lookup recovery is given by converting the bitvectors to integers (using little endian).
///
/// # See Also
@ -123,7 +123,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Output
/// A qubit array of length 1 representing the unencoded state in the
/// first parameter, together with auxillary qubits in the second parameter.
/// first parameter, together with auxiliary qubits in the second parameter.
///
/// # See Also
/// - microsoft.quantum.canon.FiveQubitCodeEncoder

Просмотреть файл

@ -46,7 +46,13 @@ namespace Microsoft.Quantum.Canon
/// Represents an operation that is used to measure the syndrome
/// of an error-correcting code block.
///
/// # Example
/// # Remarks
/// The signature `(LogicalRegister => Syndrome)` represents an operation
/// that acts jointly on the qubits in `LogicalRegister` and some ancilla
/// qubits followed by a measurements of the ancilla to extract a `Syndrome`
/// type representing the `Result[]` of these measurements.
///
/// ## Example
/// Measure syndromes for the bit-flip code
/// $S = \langle ZZI, IZZ \rangle$ using scratch qubits in a
/// non–fault tolerant manner:
@ -57,12 +63,6 @@ namespace Microsoft.Quantum.Canon
/// ], _, MeasureWithScratch));
/// ```
///
/// # Remarks
/// The signature `(LogicalRegister => Syndrome)` represents an operation
/// that acts jointly on the qubits in `LogicalRegister` and some ancilla
/// qubits followed by a measurements of the ancilla to extract a `Syndrome
/// type representing the `Result[]` of these measurements.
///
/// # See Also
/// - Microsoft.Quantum.Canon.LogicalRegister
/// - Microsoft.Quantum.Canon.Syndrome

Просмотреть файл

@ -58,8 +58,8 @@ namespace Microsoft.Quantum.Canon
/// # Input
/// ## code
/// A quantum error-correcting code packaged as a `QECC` type describes
/// the encoding and deconding of quantum data, and how error syndromes
/// are to be measuremed.
/// the encoding and decoding of quantum data, and how error syndromes
/// are to be measured.
/// ## fn
/// A `RecoveryFn` that maps each error syndrome to the `Pauli[]` operations
/// that correct the detected error.
@ -86,8 +86,8 @@ namespace Microsoft.Quantum.Canon
/// # Input
/// ## code
/// A quantum CSS error-correcting code packaged as a `CSS` type describes
/// the encoding and deconding of quantum data, and how error syndromes
/// are to be measuremed.
/// the encoding and decoding of quantum data, and how error syndromes
/// are to be measured.
/// ## fnX
/// A `RecoveryFn` that maps each $X$ error syndrome to the `Pauli[]` operations
/// that correct the detected error.

Просмотреть файл

@ -129,12 +129,12 @@ namespace Microsoft.Quantum.Canon
}
// This simple time-depedendent simulation algorithm implements a
// This simple time-dependent simulation algorithm implements a
// sequence of uniformly-sized trotter steps
/// # Summary
/// Implementation of multiple Trotter steps to approximate a unitary
/// operator that solves the time-dependent Schr<EFBFBD>dinger equation.
/// operator that solves the time-dependent Schrödinger equation.
///
/// # Input
/// ## trotterStepSize

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft.Quantum.Canon {
///
/// That is, a `BlockEncoding` is a unitary $U$ where an arbitrary operator $H$ of
/// interest that acts on the system register `s` is encoded in the top-
/// left block corresponding to auxiliary state `\ket{0}_a`. That is,
/// left block corresponding to auxiliary state $\ket{0}_a$. That is,
///
/// $$
/// \begin{align}
@ -60,11 +60,11 @@ namespace Microsoft.Quantum.Canon {
/// That is, a `TimeDependentBlockEncoding` is a unitary $U$ controlled by a state
/// $\ket{k}_d$ in clock register `d` such that an arbitrary operator $H_k$ of
/// interest that acts on the system register `s` is encoded in the top-
/// left block corresponding to auxiliary state `\ket{0}_a`. That is,
/// left block corresponding to auxiliary state $\ket{0}_a$. That is,
///
/// $$
/// \begin{align}
/// (\bra{0}_a\otimes I_{ds})U(\ket{0}_a\otimes I_{ds}) = \sum_{k}\ket{k}\bra{k}_d\otimes H_k.
/// (\bra{0}\_a\otimes I_{ds})U(\ket{0}\_a\otimes I_{ds}) = \sum_{k}\ket{k}\bra{k}\_d\otimes H_k.
/// \end{align}
/// $$.
///
@ -74,7 +74,7 @@ namespace Microsoft.Quantum.Canon {
/// ## Second Parameter
/// An array of qubits representing the auxiliary register acted on by $U$.
/// The action of $U$ is only defined when this is $\ket{0}_a$.
/// ## This Parameter
/// ## Third Parameter
/// An array of qubits representing the system register acted on by $H$.
///
/// # Output
@ -87,7 +87,7 @@ namespace Microsoft.Quantum.Canon {
///
/// That is, given a `BlockEncoding` unitary $U$ that encodes some
/// operator $H$ of interest, converts it into a `BlockEncodingReflection` $U'$ that
/// encodes the same operator, but also satisfies $U'^\dag = U'$.
/// encodes the same operator, but also satisfies $U'^\dagger = U'$.
/// This increases the size of the auxiliary register of $U$ by one qubit.
///
/// # Input
@ -96,7 +96,7 @@ namespace Microsoft.Quantum.Canon {
///
/// # Output
/// A unitary $U'$ acting jointly on registers `a` and `s` that block-
/// encodes $H$, and satisfies $U'^\dag = U'$.
/// encodes $H$, and satisfies $U'^\dagger = U'$.
///
/// # Remarks
/// This increases the size of the auxiliary register of $U$ by one qubit.
@ -174,11 +174,11 @@ namespace Microsoft.Quantum.Canon {
/// # Summary
/// Encodes an operator of interest into a `BlockEncoding`.
///
/// This constructs a `BlockEncoding` unitary $U=P\cdot V\cdot P^\dag$ that encodes some
/// This constructs a `BlockEncoding` unitary $U=P\cdot V\cdot P^\dagger$ that encodes some
/// operator $H=\sum_{j}|\alpha_j|U_j$ of interest that is a linear combination of
/// unitaries. Typically, $P$ is a state preparation unitary such that
/// $P\ket{0}_a=\sum_j\sqrt{\alpha_j/\|\vec\alpha\|_2}\ket{j}_a$,
/// and $V=\sum_{j}\ket{j}\bra{j}_a\otimes U_j$.
/// $P\ket{0}\_a=\sum_j\sqrt{\alpha_j/\|\vec\alpha\|\_2}\ket{j}\_a$,
/// and $V=\sum_{j}\ket{j}\bra{j}\_a\otimes U_j$.
///
/// # Input
/// ## statePreparation
@ -188,7 +188,7 @@ namespace Microsoft.Quantum.Canon {
///
/// # Output
/// A unitary $U$ acting jointly on registers `a` and `s` that block-
/// encodes $H$, and satisfies $U^\dag = U$.
/// encodes $H$, and satisfies $U^\dagger = U$.
///
/// # Remarks
/// This `BlockEncoding` implementation gives it the properties of a
@ -223,11 +223,11 @@ namespace Microsoft.Quantum.Canon {
/// # Summary
/// Encodes an operator of interest into a `BlockEncodingReflection`.
///
/// This constructs a `BlockEncodingReflection` unitary $U=P\cdot V\cdot P^\dag$ that encodes some
/// This constructs a `BlockEncodingReflection` unitary $U=P\cdot V\cdot P^\dagger$ that encodes some
/// operator $H=\sum_{j}|\alpha_j|U_j$ of interest that is a linear combination of
/// unitaries. Typically, $P$ is a state preparation unitary such that
/// $P\ket{0}_a\sum_j\sqrt{\alpha_j/\|\vec\alpha\|_2}\ket{j}_a$,
/// and $V=\sum_{j}\ket{j}\bra{j}_a\otimes U_j$.
/// $P\ket{0}\_a\sum_j\sqrt{\alpha_j/\|\vec\alpha\|\_2}\ket{j}\_a$,
/// and $V=\sum_{j}\ket{j}\bra{j}\_a\otimes U_j$.
///
/// # Input
/// ## statePreparation

Просмотреть файл

@ -12,15 +12,15 @@ namespace Microsoft.Quantum.Canon
///
/// Given a list of $N$ coefficients $\alpha_j$, this returns a unitary $U$ that uses the Quantum-ROM
/// technique to prepare
/// an approximation $\tilde\rho\sum^{N-1}_{j=0}p_j\ket{j}\bra{j}$ of the purification of the density matrix
/// $\rho=\sum^{N-1}_{j=0}\frac{|alpha_j|}{\sum_k |\alpha_k|}\ket{j}\bra{j}$. In this approximation, the
/// an approximation $\tilde\rho\sum_{j=0}^{N-1}p_j\ket{j}\bra{j}$ of the purification of the density matrix
/// $\rho=\sum_{j=0}^{N-1}\frac{|alpha_j|}{\sum_k |\alpha_k|}\ket{j}\bra{j}$. In this approximation, the
/// error $\epsilon$ is such that $|p_j-\frac{|alpha_j|}{\sum_k |\alpha_k|}|\le \epsilon / N$ and
/// $\|\tilde\rho - \rho\|_1\| \le \epsilon$. In other words,
/// $\|\tilde\rho - \rho\| \le \epsilon$. In other words,
/// $$
/// \begin{align}
/// U\ket{0}^{\lceil\log_2 N\rceil}\ket{0}^{m}=\sum_{j=0}^{N-1}\sqrt{p_j} \ket{j}\ket{\text{garbage}_j}.
/// \end{align}
/// $$.
/// $$
///
/// # Input
/// ## targetError
@ -39,9 +39,10 @@ namespace Microsoft.Quantum.Canon
/// ## Third parameter
/// The unitary $U$.
///
/// # Example
/// # Remarks
/// ## Example
/// The following code snippet prepares an purification of the $3$-qubit state
/// $\rho=\sum^{4}_{j=0}\frac{|alpha_j|}{\sum_k |\alpha_k|}\ket{j}\bra{j}$, where
/// $\rho=\sum_{j=0}^{4}\frac{|alpha_j|}{\sum_k |\alpha_k|}\ket{j}\bra{j}$, where
/// $\vec\alpha=(1.0,2.0,3.0,4.0,5.0)$, and the error is `1e-3`;
/// ```qsharp
/// let coefficients = [1.0,2.0,3.0,4.0,5.0];
@ -108,7 +109,7 @@ namespace Microsoft.Quantum.Canon
let oneNorm = PNorm(1.0, coefficients);
let nCoefficients = Length(coefficients);
if(bitsPrecision > 31){
fail $"Bits of precision {bitsPrecision} unsurpported. Max is 31.";
fail $"Bits of precision {bitsPrecision} unsupported. Max is 31.";
}
if(nCoefficients <= 1){
fail $"Cannot prepare state with less than 2 coefficients.";
@ -128,7 +129,7 @@ namespace Microsoft.Quantum.Canon
set bars = bars + keepCoeff[idxCoeff] - barHeight;
}
//Message($"Excess bars {bars}.");
// Uniformly distribute excess bars acress coefficients.
// Uniformly distribute excess bars across coefficients.
for(idx in 0..AbsI(bars)-1){
if(bars > 0){
set keepCoeff[idx] = keepCoeff[idx]-1;

Просмотреть файл

@ -19,9 +19,11 @@ namespace Microsoft.Quantum.Canon
/// the $n$-qubit computational basis state $\ket{0...0}$.
///
/// The action of U on a newly-allocated register is given by
/// $$
/// \begin{align}
/// U \ket{0\cdots 0} = \ket{\psi} = \frac{\sum^{2^n-1}_{j=0}\alpha_j \ket{j}}{\sqrt{\sum^{2^n-1}_{j=0}|\alpha_j|^2}}$.
/// U \ket{0\cdots 0} = \ket{\psi} = \frac{\sum_{j=0}^{2^n-1}\alpha_j \ket{j}}{\sqrt{\sum_{j=0}^{2^n-1}|\alpha_j|^2}}.
/// \end{align}
/// $$
///
/// # Input
/// ## coefficients
@ -36,7 +38,7 @@ namespace Microsoft.Quantum.Canon
/// positive with value $|\alpha_j|$. `coefficients` will be padded with
/// elements $\alpha_j = 0.0$ if fewer than $2^n$ are specified.
///
/// # Example
/// ## Example
/// The following snippet prepares the quantum state $\ket{\psi}=\sqrt{1/8}\ket{0}+\sqrt{7/8}\ket{2}$
/// in the qubit register `qubitsBE`.
/// ```qsharp
@ -69,9 +71,11 @@ namespace Microsoft.Quantum.Canon
/// the $n$-qubit computational basis state $\ket{0...0}$.
///
/// The action of U on a newly-allocated register is given by
/// $$
/// \begin{align}
/// U\ket{0...0}=\ket{\psi}=\frac{\sum^{2^n-1}_{j=0}r_j e^{i t_j}\ket{j}}{\sqrt{\sum^{2^n-1}_{j=0}|r_j|^2}}.
/// U\ket{0...0}=\ket{\psi}=\frac{\sum_{j=0}^{2^n-1}r_j e^{i t_j}\ket{j}}{\sqrt{\sum_{j=0}^{2^n-1}|r_j|^2}}.
/// \end{align}
/// $$
///
/// # Input
/// ## coefficients
@ -88,7 +92,7 @@ namespace Microsoft.Quantum.Canon
/// elements $(r_j, t_j) = (0.0, 0.0)$ if fewer than $2^n$ are
/// specified.
///
/// # Example
/// ## Example
/// The following snippet prepares the quantum state $\ket{\psi}=e^{i 0.1}\sqrt{1/8}\ket{0}+\sqrt{7/8}\ket{2}$
/// in the qubit register `qubitsBE`.
/// ```qsharp
@ -96,9 +100,9 @@ namespace Microsoft.Quantum.Canon
/// let phases = [0.1, 0.0, 0.0, 0.0];
/// mutable complexNumbers = new ComplexPolar[4];
/// for (idx in 0..3) {
/// set complexNumbers[idx] = ComplexPolar(amplitudes, phases);
/// set complexNumbers[idx] = ComplexPolar(amplitudes[idx], phases[idx]);
/// }
/// let op = StatePreparationPositiveCoefficients(complexNumbers);
/// let op = StatePreparationComplexCoefficients(complexNumbers);
/// using (qubits = Qubit[2]) {
/// let qubitsBE = BigEndian(qubits);
/// op(qubitsBE);
@ -117,7 +121,11 @@ namespace Microsoft.Quantum.Canon
/// state $\ket{\psi}$ with complex coefficients $r_j e^{i t_j}$ from
/// the $n$-qubit computational basis state $\ket{0...0}$.
///
/// $U\ket{0...0}=\ket{\psi}=\frac{\sum^{2^n-1}_{j=0}r_j e^{i t_j}\ket{j}}{\sqrt{\sum^{2^n-1}_{j=0}|r_j|^2}}$.
/// $$
/// \begin{align}
/// U\ket{0...0}=\ket{\psi}=\frac{\sum_{j=0}^{2^n-1}r_j e^{i t_j}\ket{j}}{\sqrt{\sum_{j=0}^{2^n-1}|r_j|^2}}.
/// \end{align}
/// $$
///
/// # Input
/// ## coefficients
@ -128,7 +136,7 @@ namespace Microsoft.Quantum.Canon
/// ## qubits
/// Qubit register encoding number states in big-endian format. This is
/// expected to be initialized in the computational basis state
/// $ket{0...0}$.
/// $\ket{0...0}$.
///
/// # Remarks
/// Negative input coefficients $r_j < 0$ will be treated as though

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Quantum.Canon
/// $0$ to $M-1$, given an input state $\ket{0\cdots 0}$. In other words,
/// $$
/// \begin{align}
/// U\ket{0}=\frac{1}{\sqrt{M}}\sum_{j=1}^{M-1}\ket{j}.
/// U\ket{0}=\frac{1}{\sqrt{M}}\sum_{j=0}^{M-1}\ket{j}.
/// \end{align}
/// $$.
///
@ -26,8 +26,9 @@ namespace Microsoft.Quantum.Canon
/// This register must be able to store the number $M-1$, and is assumed to be
/// initialized in the state $\ket{0\cdots 0}$.
///
/// # Example
/// The following example prepares the state $\frac{1}{\sqrt{6}}\sum_{j=1}^{5}\ket{j}$
/// # Remarks
/// ## Example
/// The following example prepares the state $\frac{1}{\sqrt{6}}\sum_{j=0}^{5}\ket{j}$
/// on $3$ qubits.
/// ``` Q#
/// let nIndices = 6;

Просмотреть файл

@ -53,9 +53,9 @@ namespace Microsoft.Quantum.Canon
/// A big-endian register to be transformed.
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittlEndianA
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittlEndianC
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittlEndianCA
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittleEndianA
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittleEndianC
/// - Microsoft.Quantum.Canon.ApplyReversedOpLittleEndianCA
operation ApplyReversedOpLittleEndian (op : (LittleEndian => Unit), register : BigEndian) : Unit
{
let bareReversed = Reverse(register!);

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Canon
@ -67,7 +67,7 @@ namespace Microsoft.Quantum.Canon
///
/// # Remarks
/// This function calls <xref:microsoft.quantum.primitive.random>, so
/// its randomess depends on the implementation of `Random`.
/// its randomness depends on the implementation of `Random`.
operation RandomSingleQubitPauli () : Pauli
{
let probs = [0.5, 0.5, 0.5, 0.5];
@ -87,7 +87,8 @@ namespace Microsoft.Quantum.Canon
/// ## target
/// Register to apply the given Pauli operation on.
///
/// # Example
/// # Remarks
/// ## Example
/// The following are equivalent:
/// ```qsharp
/// ApplyPauli([PauliY, PauliZ, PauliX], target);
@ -180,7 +181,7 @@ namespace Microsoft.Quantum.Canon
/// Quantum register on which to selectively apply the specified Pauli operator
///
/// # Remarks
/// The Boolean array and the quantum register must be of equal length
/// The Boolean array and the quantum register must be of equal length.
operation ApplyPauliFromBitString (pauli : Pauli, bitApply : Bool, bits : Bool[], qubits : Qubit[]) : Unit
{
body (...)
@ -245,7 +246,8 @@ namespace Microsoft.Quantum.Canon
/// ## n
/// Length of the array to be returned.
///
/// # Example
/// # Remarks
/// ## Example
/// To obtain the array `[PauliI, PauliI, PauliX, PauliI]`:
/// ```qsharp
/// EmbedPauli(PauliX, 2, 3);

Просмотреть файл

@ -134,7 +134,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Produces a positive integer from a string of bits in in little Endian format.
/// Produces a positive integer from a string of bits in little endian format.
///
/// # Input
/// ## bits
@ -158,7 +158,7 @@ namespace Microsoft.Quantum.Canon
/// # Summary
/// Produces a positive integer from a string of Results in in little Endian format.
/// Produces a positive integer from a string of Results in little endian format.
///
/// # Input
/// ## results

Просмотреть файл

@ -65,7 +65,7 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Tests whether common builtin operations are self adjoint.
/// Tests whether common built-in operations are self adjoint.
/// These tests are already performed in Solid itself, such that
/// this operation tests whether we can reproduce that using our
/// operation equality assertions.

Просмотреть файл

@ -15,8 +15,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.4.1901.3104" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />

Просмотреть файл

@ -130,7 +130,7 @@ namespace Microsoft.Quantum.Tests {
let nCoefficients = Length(coefficients);
let nQubits = Length(qubits!);
// The absolute phase of a diagonal unitary can only be characeterized
// The absolute phase of a diagonal unitary can only be characterized
// using a controlled operation.
using (control = Qubit[1]) {

Просмотреть файл

@ -59,7 +59,7 @@ namespace Microsoft.Quantum.Tests {
// test passes
}
else{
fail $"index {i} reconstruced cofficient incorrect. Error is {errors[i]}";
fail $"index {i} reconstructed coefficient incorrect. Error is {errors[i]}";
}
}
}

Просмотреть файл

@ -27,13 +27,13 @@ namespace Microsoft.Quantum.Tests {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = BlockEncodingByLCU(statePreparation, selector);
using(qubits = Qubit[2]){
let auxillary = [qubits[0]];
let auxiliary = [qubits[0]];
let system = [qubits[1]];
for(rep in 0..5){
LCU(auxillary, system);
AssertProb([PauliZ], auxillary, Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(auxillary[0]);
LCU(auxiliary, system);
AssertProb([PauliZ], auxiliary, Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(auxiliary[0]);
if(result == Zero) {
Exp([PauliY],1.0 * inverseAngle, system);
AssertProb([PauliZ], system, Zero, 1.0, "Error1: Z Success probability does not match theory", 1e-10);
@ -50,14 +50,14 @@ namespace Microsoft.Quantum.Tests {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = BlockEncodingReflectionByLCU(statePreparation, selector);
using(qubits = Qubit[4]){
let auxillary = qubits[2..3];
let auxiliary = qubits[2..3];
let system = [qubits[0]];
let flag = qubits[1];
for (rep in 0..5) {
LCU!!(auxillary, system);
LCU!!(auxiliary, system);
X(flag);
(ControlledOnInt(0, X))(auxillary, flag);
(ControlledOnInt(0, X))(auxiliary, flag);
AssertProb([PauliZ],[flag], Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(flag);
if(result == Zero) {
@ -76,14 +76,14 @@ namespace Microsoft.Quantum.Tests {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = QuantumWalkByQubitization(BlockEncodingReflectionByLCU(statePreparation, selector));
using(qubits = Qubit[4]){
let auxillary = qubits[2..3];
let auxiliary = qubits[2..3];
let system = [qubits[0]];
let flag = qubits[1];
for(rep in 0..5){
LCU(auxillary, system);
LCU(auxiliary, system);
X(flag);
(ControlledOnInt(0, X))(auxillary, flag);
(ControlledOnInt(0, X))(auxiliary, flag);
AssertProb([PauliZ],[flag], Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(flag);
if(result == Zero) {
@ -114,13 +114,13 @@ namespace Microsoft.Quantum.Tests {
let (norm, LCU) = PauliBlockEncoding(generatorSystem);
using (qubits = Qubit[2]) {
let auxillary = [qubits[0]];
let auxiliary = [qubits[0]];
let system = [qubits[1]];
for (rep in 0..5) {
LCU!!(auxillary, system);
AssertProb([PauliZ], auxillary, Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(auxillary[0]);
LCU!!(auxiliary, system);
AssertProb([PauliZ], auxiliary, Zero, prob, "Error0: Z Success probability does not match theory", 1e-10);
let result = M(auxiliary[0]);
if(result == Zero) {
Exp([PauliY],1.0 * inverseAngle, system);
AssertProb([PauliZ], system, Zero, 1.0, "Error1: Z Success probability does not match theory", 1e-10);

Просмотреть файл

@ -42,7 +42,7 @@ namespace Microsoft.Quantum.Tests {
set testCases[nTests] = StatePreparationTestCase(3, [1.0986553, 0.359005, 0.465689, -0.467395, 0.419893, 0.118445, 0.461883, 0.149609], new Double[0]);
set nTests = nTests + 1;
// Test missing coefficicients
// Test missing coefficients
set testCases[nTests] = StatePreparationTestCase(3, [1.0986553, 0.359005, 0.465689, -0.467395, 0.419893, 0.118445], new Double[0]);
set nTests = nTests + 1;
@ -51,7 +51,7 @@ namespace Microsoft.Quantum.Tests {
let (nQubits, coefficientsAmplitude, coefficientsPhase) = testCases[idxTest]!;
let nCoefficients = Length(coefficientsAmplitude);
// Test negative coefficicients. Should give same results as positive coefficients.
// Test negative coefficients. Should give same results as positive coefficients.
using (qubits = Qubit[nQubits]) {
let qubitsBE = BigEndian(qubits);
let op = StatePreparationPositiveCoefficients(coefficientsAmplitude);

Просмотреть файл

@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="YamlDotNet" Version="5.0.1" />

Просмотреть файл

@ -458,7 +458,7 @@ namespace Microsoft.Quantum.Chemistry
{
/// <summary>
/// First parameter <c>Int64</c> is the the number of different spin-orbitals.
/// First parameter <c>Int64</c> is the number of different spin-orbitals.
/// Second parameter <c>QArray<Int64></c> represents a sequence of creation and annihilation operators.
/// Third parameter <c>string</c> annotates the term type.
/// </summary>

Просмотреть файл

@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -34,18 +34,18 @@ namespace Microsoft.Quantum.Chemistry {
/// # Summary
/// Converts an index to a Hamiltonian term in 'HTerm[]' data format to a GeneratorIndex.
/// Converts an index to a Hamiltonian term in `HTerm[]` data format to a GeneratorIndex.
///
/// # Input
/// ## data
/// Input data in 'HTerm[]' format.
/// Input data in `HTerm[]` format.
/// ## termType
/// Additional information added to GeneratorIndex.
/// ## idx
/// Index to a term of the Hamiltonian
///
/// # Output
/// A GeneratorIndex representing a Hamiltonian term represented by 'data[idx]',
/// A GeneratorIndex representing a Hamiltonian term represented by `data[idx]`,
/// together with additional information added by `termType`.
function HTermsToGenIdx (data : HTerm[], termType : Int[], idx : Int) : GeneratorIndex {
@ -54,11 +54,11 @@ namespace Microsoft.Quantum.Chemistry {
/// # Summary
/// Converts a Hamiltonian in 'HTerm[]' data format to a GeneratorSystem.
/// Converts a Hamiltonian in `HTerm[]` data format to a GeneratorSystem.
///
/// # Input
/// ## data
/// Input data in 'HTerm[]' format.
/// Input data in `HTerm[]` format.
/// ## termType
/// Additional information added to GeneratorIndex.
///
@ -79,7 +79,7 @@ namespace Microsoft.Quantum.Chemistry {
/// Number to be checked
///
/// # Output
/// Returns true if `number` has an absolute value greater '1e-15'.
/// Returns true if `number` has an absolute value greater than `1e-15`.
function IsNotZero (number : Double) : Bool {
if (AbsD(number) > PowD(10.0, -15.0)) {

Просмотреть файл

@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.4.1901.3104" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

Просмотреть файл

@ -14,8 +14,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.4.1901.3104" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

Просмотреть файл

@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.3.1811.203-preview" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />