qsharp-lang 1.8.1-dev → 1.8.2-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/worker-browser.d.ts +1 -1
- package/dist/debug-service/worker-browser.d.ts +1 -1
- package/dist/katas-content.generated.js +73 -73
- package/dist/katas-content.generated.md.js +80 -80
- package/dist/language-service/worker-browser.d.ts +1 -1
- package/dist/samples.generated.js +3 -3
- package/dist/workers/common.js +1 -2
- package/dist/workers/node.js +1 -1
- package/docs/Microsoft.Quantum.Arrays/All.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Any.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Chunks.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Count.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Diagonal.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/DrawMany.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Enumerated.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Excluding.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Filtered.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Flattened.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Fold.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/ForEach.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Head.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IndexOf.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IndexRange.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Interleaved.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsSorted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Mapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Most.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Padded.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Partitioned.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Rest.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Reversed.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/SequenceI.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/SequenceL.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Sorted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Subarray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Swapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Tail.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Transposed.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Unzipped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Where.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Windows.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Zipped.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyP.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CX.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CY.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CZ.md +1 -1
- package/docs/Microsoft.Quantum.Canon/Fst.md +1 -1
- package/docs/Microsoft.Quantum.Canon/Snd.md +1 -1
- package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +1 -1
- package/docs/Microsoft.Quantum.Convert/DoubleAsStringWithPrecision.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +1 -1
- package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +1 -1
- package/docs/Microsoft.Quantum.Core/Length.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeEnd.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeReverse.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeStart.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeStep.md +1 -1
- package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/DumpRegister.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/Fact.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/AND.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Exp.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/H.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/I.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/M.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Measure.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Message.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R1.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Reset.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rx.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Ry.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/S.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/T.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/X.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Y.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Z.md +1 -1
- package/docs/Microsoft.Quantum.Logical/Xor.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsD.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsI.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsL.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcCos.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcCosh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcSin.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcSinh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTan.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTan2.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTanh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArgComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/Binom.md +1 -1
- package/docs/Microsoft.Quantum.Math/BitSizeI.md +1 -1
- package/docs/Microsoft.Quantum.Math/BitSizeL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Ceiling.md +1 -1
- package/docs/Microsoft.Quantum.Math/Complex.md +1 -1
- package/docs/Microsoft.Quantum.Math/ComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Cos.md +1 -1
- package/docs/Microsoft.Quantum.Math/Cosh.md +1 -1
- package/docs/Microsoft.Quantum.Math/DivRemI.md +1 -1
- package/docs/Microsoft.Quantum.Math/DivRemL.md +1 -1
- package/docs/Microsoft.Quantum.Math/DividedByC.md +1 -1
- package/docs/Microsoft.Quantum.Math/DividedByCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/E.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExpModI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExpModL.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +1 -1
- package/docs/Microsoft.Quantum.Math/FactorialI.md +1 -1
- package/docs/Microsoft.Quantum.Math/FactorialL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Floor.md +1 -1
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +1 -1
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +1 -1
- package/docs/Microsoft.Quantum.Math/HammingWeightI.md +1 -1
- package/docs/Microsoft.Quantum.Math/InverseModI.md +1 -1
- package/docs/Microsoft.Quantum.Math/InverseModL.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsInfinite.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsNaN.md +1 -1
- package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +1 -1
- package/docs/Microsoft.Quantum.Math/Lg.md +1 -1
- package/docs/Microsoft.Quantum.Math/Log.md +1 -1
- package/docs/Microsoft.Quantum.Math/Log10.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogFactorialD.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogGammaD.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogOf2.md +1 -1
- package/docs/Microsoft.Quantum.Math/Max.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxD.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxI.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Min.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinD.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinI.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinL.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinusC.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinusCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/ModulusI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ModulusL.md +1 -1
- package/docs/Microsoft.Quantum.Math/NegationC.md +1 -1
- package/docs/Microsoft.Quantum.Math/NegationCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/PI.md +1 -1
- package/docs/Microsoft.Quantum.Math/PNorm.md +1 -1
- package/docs/Microsoft.Quantum.Math/PNormalized.md +1 -1
- package/docs/Microsoft.Quantum.Math/PlusC.md +1 -1
- package/docs/Microsoft.Quantum.Math/PlusCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/PowC.md +1 -1
- package/docs/Microsoft.Quantum.Math/PowCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/RealMod.md +1 -1
- package/docs/Microsoft.Quantum.Math/Round.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignD.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignI.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sin.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sinh.md +1 -1
- package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sqrt.md +1 -1
- package/docs/Microsoft.Quantum.Math/SquaredNorm.md +1 -1
- package/docs/Microsoft.Quantum.Math/Tan.md +1 -1
- package/docs/Microsoft.Quantum.Math/Tanh.md +1 -1
- package/docs/Microsoft.Quantum.Math/TimesC.md +1 -1
- package/docs/Microsoft.Quantum.Math/TimesCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +1 -1
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Truncate.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetX.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetY.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +1 -1
- package/lib/node/qsc_wasm.cjs +150 -165
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.d.ts +7 -7
- package/lib/web/qsc_wasm.js +173 -178
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/ux/histogram.tsx +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const messageHandler: (e: MessageEvent
|
|
1
|
+
export declare const messageHandler: (e: MessageEvent) => void;
|
|
@@ -2,7 +2,7 @@ export default [
|
|
|
2
2
|
{
|
|
3
3
|
"title": "Minimal",
|
|
4
4
|
"shots": 100,
|
|
5
|
-
"code": "
|
|
5
|
+
"code": "// # Sample\n// Getting started\n//\n// # Description\n// This is a minimal Q# program that can be used to start writing Q# code.\n\noperation Main() : Unit {\n // TODO: Write your Q# code here.\n}\n"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"title": "Superposition",
|
|
@@ -52,12 +52,12 @@ export default [
|
|
|
52
52
|
{
|
|
53
53
|
"title": "Bernstein–Vazirani",
|
|
54
54
|
"shots": 1,
|
|
55
|
-
"code": "/// # Sample\n/// Bernstein-Vazirani algorithm\n///\n/// # Description\n/// The Bernstein-Vazirani algorithm determines the value of a bit string\n/// encoded in a function.\n///\n/// This Q# program implements the Bernstein-Vazirani algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : Result[] {\n // Consider a function 𝑓(𝑥⃗) on bitstrings 𝑥⃗ = (𝑥₀, …, 𝑥ₙ₋₁) of the form\n // 𝑓(𝑥⃗) ≔ Σᵢ 𝑥ᵢ 𝑟ᵢ\n // where 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁) is an unknown bit string that determines the\n // parity of 𝑓.\n\n // The Bernstein–Vazirani algorithm allows determining 𝑟 given a\n // quantum operation that implements\n // |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n\n // This entry point function of this program, `Main`, shows how to use\n // the `BernsteinVazirani` operation to determine the value of bitstring\n // 𝑟.\n let secretBitString = SecretBitStringAsBoolArray();\n let parityOperation = EncodeBitStringAsParityOperation(secretBitString);\n let decodedBitString = BernsteinVazirani(\n parityOperation,\n Length(secretBitString)\n );\n\n return decodedBitString;\n }\n\n /// # Summary\n /// This operation implements the Bernstein-Vazirani quantum algorithm.\n /// This algorithm computes for a given Boolean function that is promised to\n /// be a parity 𝑓(𝑥₀, …, 𝑥ₙ₋₁) = Σᵢ 𝑟ᵢ 𝑥ᵢ a result in the form of a bit\n /// vector (𝑟₀, …, 𝑟ₙ₋₁) corresponding to the parity function.\n /// Note that it is promised that the function is actually a parity\n /// function.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉,\n /// where 𝑓 is a Boolean function that implements a parity Σᵢ 𝑟ᵢ 𝑥ᵢ.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of type `Result[]` that contains the parity 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁).\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Ethan Bernstein and Umesh Vazirani*,\n /// SIAM J. Comput., 26(5), 1411–1473, 1997 ]\n /// (https://doi.org/10.1137/S0097539796300921)\n operation BernsteinVazirani(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function parameter Uf is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that a relative phase is\n // introduced when we apply a Hadamard gate later on and we can use\n // phase kickback when Uf is applied.\n X(target);\n\n within {\n // Now, a Hadamard transform is applied to each of the qubits. As\n // the last step before the measurement, a Hadamard transform is\n // applied to all qubits except the last one. We could also\n // transform the last qubit, but this would not affect the\n // final outcome.\n // We use a within-apply block to ensure that the Hadamard transform\n // is correctly inverted.\n ApplyToEachA(H, queryRegister);\n } apply {\n H(target);\n // We now apply Uf to the n+1 qubits, computing\n // |x, y〉 ↦ |x, y ⊕ f(x)〉.\n Uf(queryRegister, target);\n }\n\n // Measure all qubits and reset them to the |0〉 state so that they can\n // be safely deallocated at the end of the block.\n let resultArray = MResetEachZ(queryRegister);\n\n // Finally, the last qubit, which held the y-register, is reset.\n Reset(target);\n\n // The result is already contained in resultArray so no further\n // post-processing is necessary.\n return resultArray;\n }\n\n /// # Summary\n /// Given bit string 𝑟⃗ = (r₀, …, rₙ₋₁), represented as an array of Booleans,\n /// this operation applies a unitary 𝑈 that acts on 𝑛 + 1 qubits as:\n /// 𝑈 |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉\n /// where 𝑓(𝑥) = Σᵢ 𝑥ᵢ 𝑟ᵢ mod 2.\n ///\n /// # Input\n /// ## bitStringAsBoolArray\n /// A bit string 𝑟⃗, represented as an array of Booleans, used to define the\n /// function 𝑓.\n /// ## xRegister\n /// Represents the |𝑥〉 register that 𝑈 acts on.\n /// ## yQubit\n /// Represents the |𝑦〉 qubit that 𝑈 acts on.\n operation ApplyParityOperation(\n bitStringAsBoolArray : Bool[],\n xRegister : Qubit[],\n yQubit : Qubit\n ) : Unit {\n // `xRegister` muts have enough qubits to represent the integer.\n let requiredBits = Length(bitStringAsBoolArray);\n let availableQubits = Length(xRegister);\n Fact(\n availableQubits >= requiredBits,\n $\"The bitstring has {requiredBits} bits but the quantum register \" + $\"only has {availableQubits} qubits\"\n );\n\n // Apply the quantum operations that encode the bit string.\n for (index, bit) in Enumerated(bitStringAsBoolArray) {\n if bit {\n CNOT(xRegister[index], yQubit);\n }\n }\n }\n\n /// # Summary\n /// This is a higher-order operation which returns an operation (Qubit[], Qubit) => () of the form\n /// U_f |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n /// We define 𝑓 by providing the bit string 𝑟⃗ as an integer.\n
|
|
55
|
+
"code": "/// # Sample\n/// Bernstein-Vazirani algorithm\n///\n/// # Description\n/// The Bernstein-Vazirani algorithm determines the value of a bit string\n/// encoded in a function.\n///\n/// This Q# program implements the Bernstein-Vazirani algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : Result[] {\n // Consider a function 𝑓(𝑥⃗) on bitstrings 𝑥⃗ = (𝑥₀, …, 𝑥ₙ₋₁) of the form\n // 𝑓(𝑥⃗) ≔ Σᵢ 𝑥ᵢ 𝑟ᵢ\n // where 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁) is an unknown bit string that determines the\n // parity of 𝑓.\n\n // The Bernstein–Vazirani algorithm allows determining 𝑟 given a\n // quantum operation that implements\n // |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n\n // This entry point function of this program, `Main`, shows how to use\n // the `BernsteinVazirani` operation to determine the value of bitstring\n // 𝑟.\n let secretBitString = SecretBitStringAsBoolArray();\n let parityOperation = EncodeBitStringAsParityOperation(secretBitString);\n let decodedBitString = BernsteinVazirani(\n parityOperation,\n Length(secretBitString)\n );\n\n return decodedBitString;\n }\n\n /// # Summary\n /// This operation implements the Bernstein-Vazirani quantum algorithm.\n /// This algorithm computes for a given Boolean function that is promised to\n /// be a parity 𝑓(𝑥₀, …, 𝑥ₙ₋₁) = Σᵢ 𝑟ᵢ 𝑥ᵢ a result in the form of a bit\n /// vector (𝑟₀, …, 𝑟ₙ₋₁) corresponding to the parity function.\n /// Note that it is promised that the function is actually a parity\n /// function.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉,\n /// where 𝑓 is a Boolean function that implements a parity Σᵢ 𝑟ᵢ 𝑥ᵢ.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of type `Result[]` that contains the parity 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁).\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Ethan Bernstein and Umesh Vazirani*,\n /// SIAM J. Comput., 26(5), 1411–1473, 1997 ]\n /// (https://doi.org/10.1137/S0097539796300921)\n operation BernsteinVazirani(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function parameter Uf is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that a relative phase is\n // introduced when we apply a Hadamard gate later on and we can use\n // phase kickback when Uf is applied.\n X(target);\n\n within {\n // Now, a Hadamard transform is applied to each of the qubits. As\n // the last step before the measurement, a Hadamard transform is\n // applied to all qubits except the last one. We could also\n // transform the last qubit, but this would not affect the\n // final outcome.\n // We use a within-apply block to ensure that the Hadamard transform\n // is correctly inverted.\n ApplyToEachA(H, queryRegister);\n } apply {\n H(target);\n // We now apply Uf to the n+1 qubits, computing\n // |x, y〉 ↦ |x, y ⊕ f(x)〉.\n Uf(queryRegister, target);\n }\n\n // Measure all qubits and reset them to the |0〉 state so that they can\n // be safely deallocated at the end of the block.\n let resultArray = MResetEachZ(queryRegister);\n\n // Finally, the last qubit, which held the y-register, is reset.\n Reset(target);\n\n // The result is already contained in resultArray so no further\n // post-processing is necessary.\n return resultArray;\n }\n\n /// # Summary\n /// Given bit string 𝑟⃗ = (r₀, …, rₙ₋₁), represented as an array of Booleans,\n /// this operation applies a unitary 𝑈 that acts on 𝑛 + 1 qubits as:\n /// 𝑈 |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉\n /// where 𝑓(𝑥) = Σᵢ 𝑥ᵢ 𝑟ᵢ mod 2.\n ///\n /// # Input\n /// ## bitStringAsBoolArray\n /// A bit string 𝑟⃗, represented as an array of Booleans, used to define the\n /// function 𝑓.\n /// ## xRegister\n /// Represents the |𝑥〉 register that 𝑈 acts on.\n /// ## yQubit\n /// Represents the |𝑦〉 qubit that 𝑈 acts on.\n operation ApplyParityOperation(\n bitStringAsBoolArray : Bool[],\n xRegister : Qubit[],\n yQubit : Qubit\n ) : Unit {\n // `xRegister` muts have enough qubits to represent the integer.\n let requiredBits = Length(bitStringAsBoolArray);\n let availableQubits = Length(xRegister);\n Fact(\n availableQubits >= requiredBits,\n $\"The bitstring has {requiredBits} bits but the quantum register \" + $\"only has {availableQubits} qubits\"\n );\n\n // Apply the quantum operations that encode the bit string.\n for (index, bit) in Enumerated(bitStringAsBoolArray) {\n if bit {\n CNOT(xRegister[index], yQubit);\n }\n }\n }\n\n /// # Summary\n /// This is a higher-order operation which returns an operation (Qubit[], Qubit) => () of the form\n /// U_f |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n /// We define 𝑓 by providing the bit string 𝑟⃗ as an integer.\n function EncodeBitStringAsParityOperation(bitStringAsBoolArray : Bool[]) : (Qubit[], Qubit) => Unit {\n return ApplyParityOperation(bitStringAsBoolArray, _, _);\n }\n\n /// # Summary\n /// Returns a particular bit string as an array of Booleans.\n function SecretBitStringAsBoolArray() : Bool[] {\n return [true, false, true, false, true];\n }\n}\n"
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"title": "Bernstein–Vazirani (Advanced)",
|
|
59
59
|
"shots": 1,
|
|
60
|
-
"code": "/// # Sample\n/// Bernstein-Vazirani algorithm\n///\n/// # Description\n/// The Bernstein-Vazirani algorithm determines the value of a bit string\n/// encoded in a function.\n///\n/// This Q# program implements the Bernstein-Vazirani algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : Int[] {\n // Consider a function 𝑓(𝑥⃗) on bitstrings 𝑥⃗ = (𝑥₀, …, 𝑥ₙ₋₁) of the form\n // 𝑓(𝑥⃗) ≔ Σᵢ 𝑥ᵢ 𝑟ᵢ\n // where 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁) is an unknown bitstring that determines the\n // parity of 𝑓.\n\n // The Bernstein–Vazirani algorithm allows determining 𝑟 given a\n // quantum operation that implements\n // |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n\n // The entry point function of this program, `Main`, shows how to use\n // the `BernsteinVazirani` operation to determine the value of various\n // integers whose bits describe 𝑟.\n let nQubits = 10;\n\n // Use the Bernstein–Vazirani algorithm to determine the bit strings\n // that various integers represent.\n let integers = [127, 238, 512];\n mutable decodedIntegers = [];\n for integer in integers {\n // Create an operation that encodes a bit string represented by an\n // integer as a parity operation.\n let parityOperation = EncodeIntegerAsParityOperation(integer);\n\n // Use the parity operation as input to the Bernstein-Vazirani\n // algorithm to determine the bit string.\n let decodedBitString = BernsteinVazirani(parityOperation, nQubits);\n let decodedInteger = ResultArrayAsInt(decodedBitString);\n Fact(\n decodedInteger == integer,\n $\"Decoded integer {decodedInteger}, but expected {integer}.\"\n );\n\n Message($\"Successfully decoded bit string as int: {decodedInteger}\");\n set decodedIntegers += [decodedInteger];\n }\n\n return decodedIntegers;\n }\n\n /// # Summary\n /// This operation implements the Bernstein-Vazirani quantum algorithm.\n /// This algorithm computes for a given Boolean function that is promised to\n /// be a parity 𝑓(𝑥₀, …, 𝑥ₙ₋₁) = Σᵢ 𝑟ᵢ 𝑥ᵢ a result in the form of a bit\n /// vector (𝑟₀, …, 𝑟ₙ₋₁) corresponding to the parity function.\n /// Note that it is promised that the function is actually a parity\n /// function.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉,\n /// where 𝑓 is a Boolean function that implements a parity Σᵢ 𝑟ᵢ 𝑥ᵢ.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of type `Result[]` that contains the parity 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁).\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Ethan Bernstein and Umesh Vazirani*,\n /// SIAM J. Comput., 26(5), 1411–1473, 1997 ]\n /// (https://doi.org/10.1137/S0097539796300921)\n operation BernsteinVazirani(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function Uf is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that the function will actually\n // be computed into the phase when Uf is applied.\n X(target);\n\n within {\n // Now, a Hadamard transform is applied to each of the qubits. As\n // the last step before the measurement, a Hadamard transform is\n // applied to all qubits except last one. We could apply the\n // transform to the last qubit also, but this would not affect the\n // final outcome.\n // We use a within-apply block to ensure that the Hadamard transform\n // is correctly inverted.\n ApplyToEachA(H, queryRegister);\n } apply {\n H(target);\n // We now apply Uf to the n+1 qubits, computing\n // |x, y〉 ↦ |x, y ⊕ f(x)〉.\n Uf(queryRegister, target);\n }\n\n // Measure all qubits and reset them to the |0〉 state so that they can\n // be safely deallocated at the end of the block.\n let resultArray = MResetEachZ(queryRegister);\n\n // Finally, the last qubit, which held the y-register, is reset.\n Reset(target);\n\n // The result is already contained in resultArray so no further\n // post-processing is necessary.\n return resultArray;\n }\n\n /// # Summary\n /// Given an integer that can be represented as a bit string\n /// 𝑟⃗ = (r₀, …, rₙ₋₁), this operation applies a unitary 𝑈 that acts on 𝑛 + 1\n /// qubits as:\n /// 𝑈 |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉\n /// where 𝑓(𝑥) = Σᵢ 𝑥ᵢ 𝑟ᵢ mod 2.\n ///\n /// # Input\n /// ## bitStringAsInt\n /// An integer that can be represented as a bit string 𝑟⃗ used to define the\n /// function 𝑓.\n /// ## xRegister\n /// Represents the |𝑥〉 register that 𝑈 acts on.\n /// ## yQubit\n /// Represents the |𝑦〉 qubit that 𝑈 acts on.\n operation ApplyParityOperation(\n bitStringAsInt : Int,\n xRegister : Qubit[],\n yQubit : Qubit\n ) : Unit {\n // `xRegister` muts have enough qubits to represent the integer.\n let requiredBits = BitSizeI(bitStringAsInt);\n let availableQubits = Length(xRegister);\n Fact(\n availableQubits >= requiredBits,\n $\"Integer value {bitStringAsInt} requires {requiredBits} bits to be represented but the quantum register only has {availableQubits} qubits\"\n );\n\n // Apply the quantum operations that encode the bit string.\n for index in IndexRange(xRegister) {\n if ((bitStringAsInt &&& 2^index) != 0) {\n CNOT(xRegister[index], yQubit);\n }\n }\n }\n\n /// # Summary\n /// Returns black-box operations (Qubit[], Qubit) => () of the form\n /// U_f |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n /// We define 𝑓 by providing the bit string 𝑟⃗ as an integer.\n
|
|
60
|
+
"code": "/// # Sample\n/// Bernstein-Vazirani algorithm\n///\n/// # Description\n/// The Bernstein-Vazirani algorithm determines the value of a bit string\n/// encoded in a function.\n///\n/// This Q# program implements the Bernstein-Vazirani algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : Int[] {\n // Consider a function 𝑓(𝑥⃗) on bitstrings 𝑥⃗ = (𝑥₀, …, 𝑥ₙ₋₁) of the form\n // 𝑓(𝑥⃗) ≔ Σᵢ 𝑥ᵢ 𝑟ᵢ\n // where 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁) is an unknown bitstring that determines the\n // parity of 𝑓.\n\n // The Bernstein–Vazirani algorithm allows determining 𝑟 given a\n // quantum operation that implements\n // |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n\n // The entry point function of this program, `Main`, shows how to use\n // the `BernsteinVazirani` operation to determine the value of various\n // integers whose bits describe 𝑟.\n let nQubits = 10;\n\n // Use the Bernstein–Vazirani algorithm to determine the bit strings\n // that various integers represent.\n let integers = [127, 238, 512];\n mutable decodedIntegers = [];\n for integer in integers {\n // Create an operation that encodes a bit string represented by an\n // integer as a parity operation.\n let parityOperation = EncodeIntegerAsParityOperation(integer);\n\n // Use the parity operation as input to the Bernstein-Vazirani\n // algorithm to determine the bit string.\n let decodedBitString = BernsteinVazirani(parityOperation, nQubits);\n let decodedInteger = ResultArrayAsInt(decodedBitString);\n Fact(\n decodedInteger == integer,\n $\"Decoded integer {decodedInteger}, but expected {integer}.\"\n );\n\n Message($\"Successfully decoded bit string as int: {decodedInteger}\");\n set decodedIntegers += [decodedInteger];\n }\n\n return decodedIntegers;\n }\n\n /// # Summary\n /// This operation implements the Bernstein-Vazirani quantum algorithm.\n /// This algorithm computes for a given Boolean function that is promised to\n /// be a parity 𝑓(𝑥₀, …, 𝑥ₙ₋₁) = Σᵢ 𝑟ᵢ 𝑥ᵢ a result in the form of a bit\n /// vector (𝑟₀, …, 𝑟ₙ₋₁) corresponding to the parity function.\n /// Note that it is promised that the function is actually a parity\n /// function.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉,\n /// where 𝑓 is a Boolean function that implements a parity Σᵢ 𝑟ᵢ 𝑥ᵢ.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of type `Result[]` that contains the parity 𝑟⃗ = (𝑟₀, …, 𝑟ₙ₋₁).\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Ethan Bernstein and Umesh Vazirani*,\n /// SIAM J. Comput., 26(5), 1411–1473, 1997 ]\n /// (https://doi.org/10.1137/S0097539796300921)\n operation BernsteinVazirani(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function Uf is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that the function will actually\n // be computed into the phase when Uf is applied.\n X(target);\n\n within {\n // Now, a Hadamard transform is applied to each of the qubits. As\n // the last step before the measurement, a Hadamard transform is\n // applied to all qubits except last one. We could apply the\n // transform to the last qubit also, but this would not affect the\n // final outcome.\n // We use a within-apply block to ensure that the Hadamard transform\n // is correctly inverted.\n ApplyToEachA(H, queryRegister);\n } apply {\n H(target);\n // We now apply Uf to the n+1 qubits, computing\n // |x, y〉 ↦ |x, y ⊕ f(x)〉.\n Uf(queryRegister, target);\n }\n\n // Measure all qubits and reset them to the |0〉 state so that they can\n // be safely deallocated at the end of the block.\n let resultArray = MResetEachZ(queryRegister);\n\n // Finally, the last qubit, which held the y-register, is reset.\n Reset(target);\n\n // The result is already contained in resultArray so no further\n // post-processing is necessary.\n return resultArray;\n }\n\n /// # Summary\n /// Given an integer that can be represented as a bit string\n /// 𝑟⃗ = (r₀, …, rₙ₋₁), this operation applies a unitary 𝑈 that acts on 𝑛 + 1\n /// qubits as:\n /// 𝑈 |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉\n /// where 𝑓(𝑥) = Σᵢ 𝑥ᵢ 𝑟ᵢ mod 2.\n ///\n /// # Input\n /// ## bitStringAsInt\n /// An integer that can be represented as a bit string 𝑟⃗ used to define the\n /// function 𝑓.\n /// ## xRegister\n /// Represents the |𝑥〉 register that 𝑈 acts on.\n /// ## yQubit\n /// Represents the |𝑦〉 qubit that 𝑈 acts on.\n operation ApplyParityOperation(\n bitStringAsInt : Int,\n xRegister : Qubit[],\n yQubit : Qubit\n ) : Unit {\n // `xRegister` muts have enough qubits to represent the integer.\n let requiredBits = BitSizeI(bitStringAsInt);\n let availableQubits = Length(xRegister);\n Fact(\n availableQubits >= requiredBits,\n $\"Integer value {bitStringAsInt} requires {requiredBits} bits to be represented but the quantum register only has {availableQubits} qubits\"\n );\n\n // Apply the quantum operations that encode the bit string.\n for index in IndexRange(xRegister) {\n if ((bitStringAsInt &&& 2^index) != 0) {\n CNOT(xRegister[index], yQubit);\n }\n }\n }\n\n /// # Summary\n /// Returns black-box operations (Qubit[], Qubit) => () of the form\n /// U_f |𝑥〉|𝑦〉 = |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉.\n /// We define 𝑓 by providing the bit string 𝑟⃗ as an integer.\n function EncodeIntegerAsParityOperation(bitStringAsInt : Int) : (Qubit[], Qubit) => Unit {\n return ApplyParityOperation(bitStringAsInt, _, _);\n }\n}\n"
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"title": "Grover's search",
|
package/dist/workers/common.js
CHANGED
|
@@ -54,7 +54,6 @@ export function createProxyInternal(postMessage, terminator, methods) {
|
|
|
54
54
|
if (curr)
|
|
55
55
|
return;
|
|
56
56
|
while ((curr = queue.shift())) {
|
|
57
|
-
// eslint-disable-line no-cond-assign
|
|
58
57
|
if (curr.cancellationToken?.isCancellationRequested) {
|
|
59
58
|
curr.reject("cancelled");
|
|
60
59
|
continue;
|
|
@@ -262,7 +261,7 @@ export function initService(postMessage, serviceProtocol, wasm, qscLogLevel) {
|
|
|
262
261
|
// Test if this is the case.
|
|
263
262
|
structuredClone(args);
|
|
264
263
|
}
|
|
265
|
-
catch
|
|
264
|
+
catch {
|
|
266
265
|
// Uncloneable object.
|
|
267
266
|
// Use String(args) instead of ${args} to handle all possible values
|
|
268
267
|
// without throwing. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion
|
package/dist/workers/node.js
CHANGED
|
@@ -15,7 +15,7 @@ import { createProxyInternal, initService, } from "./common.js";
|
|
|
15
15
|
export function createWorker(protocol) {
|
|
16
16
|
if (isMainThread)
|
|
17
17
|
throw "Worker script should be loaded in a Worker thread only";
|
|
18
|
-
const port = parentPort;
|
|
18
|
+
const port = parentPort;
|
|
19
19
|
const postMessage = port.postMessage.bind(port);
|
|
20
20
|
const invokeService = initService(postMessage, protocol, wasm, // Need to cast due to difference in web and node wasm types
|
|
21
21
|
workerData && typeof workerData.qscLogLevel === "number"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
uid: Qdk.Microsoft.Quantum.Canon.ApplyControlledOnBitString
|
|
3
3
|
title: ApplyControlledOnBitString operation
|
|
4
|
-
ms.date:
|
|
4
|
+
ms.date: 09/10/2024 12:00:00 AM
|
|
5
5
|
ms.topic: managed-reference
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.namespace: Microsoft.Quantum.Canon
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
uid: Qdk.Microsoft.Quantum.Canon.ApplyControlledOnInt
|
|
3
3
|
title: ApplyControlledOnInt operation
|
|
4
|
-
ms.date:
|
|
4
|
+
ms.date: 09/10/2024 12:00:00 AM
|
|
5
5
|
ms.topic: managed-reference
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.namespace: Microsoft.Quantum.Canon
|