qsharp-lang 1.25.2-dev → 1.25.4-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/katas-content.generated.js +1 -1
- package/dist/katas-content.generated.md.js +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/RangeStart.md +1 -1
- package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
- package/docs/Microsoft.Quantum.Core/index.md +1 -1
- package/docs/Std.Arithmetic/AddLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfEqualLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
- package/docs/Std.Arithmetic/FourierTDIncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByI.md +1 -1
- package/docs/Std.Arithmetic/IncByIUsingIncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByL.md +1 -1
- package/docs/Std.Arithmetic/IncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByLEUsingAddLE.md +1 -1
- package/docs/Std.Arithmetic/IncByLUsingIncByLE.md +1 -1
- package/docs/Std.Arithmetic/LookAheadDKRSAddLE.md +1 -1
- package/docs/Std.Arithmetic/MAJ.md +1 -1
- package/docs/Std.Arithmetic/ReflectAboutInteger.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryCGAddLE.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryCGIncByLE.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
- package/docs/Std.Arithmetic/index.md +1 -1
- package/docs/Std.Arrays/All.md +1 -1
- package/docs/Std.Arrays/Any.md +1 -1
- package/docs/Std.Arrays/Chunks.md +1 -1
- package/docs/Std.Arrays/CircularlyShifted.md +1 -1
- package/docs/Std.Arrays/ColumnAt.md +1 -1
- package/docs/Std.Arrays/Count.md +1 -1
- package/docs/Std.Arrays/Diagonal.md +1 -1
- package/docs/Std.Arrays/DrawMany.md +1 -1
- package/docs/Std.Arrays/Enumerated.md +1 -1
- package/docs/Std.Arrays/Excluding.md +1 -1
- package/docs/Std.Arrays/Filtered.md +1 -1
- package/docs/Std.Arrays/FlatMapped.md +1 -1
- package/docs/Std.Arrays/Flattened.md +1 -1
- package/docs/Std.Arrays/Fold.md +1 -1
- package/docs/Std.Arrays/ForEach.md +1 -1
- package/docs/Std.Arrays/Head.md +1 -1
- package/docs/Std.Arrays/HeadAndRest.md +1 -1
- package/docs/Std.Arrays/IndexOf.md +1 -1
- package/docs/Std.Arrays/IndexRange.md +1 -1
- package/docs/Std.Arrays/Interleaved.md +1 -1
- package/docs/Std.Arrays/IsEmpty.md +1 -1
- package/docs/Std.Arrays/IsRectangularArray.md +1 -1
- package/docs/Std.Arrays/IsSorted.md +1 -1
- package/docs/Std.Arrays/IsSquareArray.md +1 -1
- package/docs/Std.Arrays/Mapped.md +1 -1
- package/docs/Std.Arrays/MappedByIndex.md +1 -1
- package/docs/Std.Arrays/MappedOverRange.md +1 -1
- package/docs/Std.Arrays/Most.md +1 -1
- package/docs/Std.Arrays/MostAndTail.md +1 -1
- package/docs/Std.Arrays/Padded.md +1 -1
- package/docs/Std.Arrays/Partitioned.md +1 -1
- package/docs/Std.Arrays/Rest.md +1 -1
- package/docs/Std.Arrays/Reversed.md +1 -1
- package/docs/Std.Arrays/SequenceI.md +1 -1
- package/docs/Std.Arrays/SequenceL.md +1 -1
- package/docs/Std.Arrays/Sorted.md +1 -1
- package/docs/Std.Arrays/Subarray.md +1 -1
- package/docs/Std.Arrays/Swapped.md +1 -1
- package/docs/Std.Arrays/Tail.md +1 -1
- package/docs/Std.Arrays/Transposed.md +1 -1
- package/docs/Std.Arrays/Unzipped.md +1 -1
- package/docs/Std.Arrays/Where.md +1 -1
- package/docs/Std.Arrays/Windows.md +1 -1
- package/docs/Std.Arrays/Zipped.md +1 -1
- package/docs/Std.Arrays/index.md +1 -1
- package/docs/Std.Canon/ApplyCNOTChain.md +1 -1
- package/docs/Std.Canon/ApplyControlledOnBitString.md +1 -1
- package/docs/Std.Canon/ApplyControlledOnInt.md +1 -1
- package/docs/Std.Canon/ApplyOperationPowerA.md +1 -1
- package/docs/Std.Canon/ApplyOperationPowerCA.md +1 -1
- package/docs/Std.Canon/ApplyP.md +1 -1
- package/docs/Std.Canon/ApplyPauli.md +1 -1
- package/docs/Std.Canon/ApplyPauliFromBitString.md +1 -1
- package/docs/Std.Canon/ApplyPauliFromInt.md +1 -1
- package/docs/Std.Canon/ApplyQFT.md +1 -1
- package/docs/Std.Canon/ApplyQPE.md +1 -1
- package/docs/Std.Canon/ApplyToEach.md +1 -1
- package/docs/Std.Canon/ApplyToEachA.md +1 -1
- package/docs/Std.Canon/ApplyToEachC.md +1 -1
- package/docs/Std.Canon/ApplyToEachCA.md +1 -1
- package/docs/Std.Canon/ApplyXorInPlace.md +1 -1
- package/docs/Std.Canon/ApplyXorInPlaceL.md +1 -1
- package/docs/Std.Canon/CX.md +1 -1
- package/docs/Std.Canon/CY.md +1 -1
- package/docs/Std.Canon/CZ.md +1 -1
- package/docs/Std.Canon/Fst.md +1 -1
- package/docs/Std.Canon/MapPauliAxis.md +1 -1
- package/docs/Std.Canon/Relabel.md +1 -1
- package/docs/Std.Canon/Snd.md +1 -1
- package/docs/Std.Canon/SwapReverseRegister.md +1 -1
- package/docs/Std.Canon/index.md +1 -1
- package/docs/Std.Convert/BigIntAsBoolArray.md +1 -1
- package/docs/Std.Convert/BigIntAsInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsBigInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsResultArray.md +1 -1
- package/docs/Std.Convert/BoolAsResult.md +1 -1
- package/docs/Std.Convert/ComplexAsComplexPolar.md +1 -1
- package/docs/Std.Convert/ComplexPolarAsComplex.md +1 -1
- package/docs/Std.Convert/DoubleAsStringWithPrecision.md +1 -1
- package/docs/Std.Convert/IntAsBigInt.md +1 -1
- package/docs/Std.Convert/IntAsBoolArray.md +1 -1
- package/docs/Std.Convert/IntAsDouble.md +1 -1
- package/docs/Std.Convert/ResultArrayAsBoolArray.md +1 -1
- package/docs/Std.Convert/ResultArrayAsInt.md +1 -1
- package/docs/Std.Convert/ResultAsBool.md +1 -1
- package/docs/Std.Convert/index.md +1 -1
- package/docs/Std.Core/Complex.md +1 -1
- package/docs/Std.Core/Length.md +1 -1
- package/docs/Std.Core/Repeated.md +1 -1
- package/docs/Std.Core/index.md +1 -1
- package/docs/Std.Diagnostics/ApplyIdleNoise.md +1 -1
- package/docs/Std.Diagnostics/BitFlipNoise.md +1 -1
- package/docs/Std.Diagnostics/CheckAllZero.md +1 -1
- package/docs/Std.Diagnostics/CheckOperationsAreEqual.md +1 -1
- package/docs/Std.Diagnostics/CheckZero.md +1 -1
- package/docs/Std.Diagnostics/ConfigurePauliNoise.md +1 -1
- package/docs/Std.Diagnostics/ConfigureQubitLoss.md +1 -1
- package/docs/Std.Diagnostics/DepolarizingNoise.md +1 -1
- package/docs/Std.Diagnostics/DumpMachine.md +1 -1
- package/docs/Std.Diagnostics/DumpOperation.md +1 -1
- package/docs/Std.Diagnostics/DumpRegister.md +1 -1
- package/docs/Std.Diagnostics/Fact.md +1 -1
- package/docs/Std.Diagnostics/NoNoise.md +1 -1
- package/docs/Std.Diagnostics/PhaseFlipNoise.md +1 -1
- package/docs/Std.Diagnostics/StartCountingFunction.md +1 -1
- package/docs/Std.Diagnostics/StartCountingOperation.md +1 -1
- package/docs/Std.Diagnostics/StartCountingQubits.md +1 -1
- package/docs/Std.Diagnostics/StopCountingFunction.md +1 -1
- package/docs/Std.Diagnostics/StopCountingOperation.md +1 -1
- package/docs/Std.Diagnostics/StopCountingQubits.md +1 -1
- package/docs/Std.Diagnostics/index.md +1 -1
- package/docs/Std.Intrinsic/AND.md +1 -1
- package/docs/Std.Intrinsic/ApplyUnitary.md +1 -1
- package/docs/Std.Intrinsic/CCNOT.md +1 -1
- package/docs/Std.Intrinsic/CNOT.md +1 -1
- package/docs/Std.Intrinsic/Exp.md +1 -1
- package/docs/Std.Intrinsic/H.md +1 -1
- package/docs/Std.Intrinsic/I.md +1 -1
- package/docs/Std.Intrinsic/M.md +1 -1
- package/docs/Std.Intrinsic/Measure.md +1 -1
- package/docs/Std.Intrinsic/Message.md +1 -1
- package/docs/Std.Intrinsic/R.md +1 -1
- package/docs/Std.Intrinsic/R1.md +1 -1
- package/docs/Std.Intrinsic/R1Frac.md +1 -1
- package/docs/Std.Intrinsic/RFrac.md +1 -1
- package/docs/Std.Intrinsic/Reset.md +1 -1
- package/docs/Std.Intrinsic/ResetAll.md +1 -1
- package/docs/Std.Intrinsic/Rx.md +1 -1
- package/docs/Std.Intrinsic/Rxx.md +1 -1
- package/docs/Std.Intrinsic/Ry.md +1 -1
- package/docs/Std.Intrinsic/Ryy.md +1 -1
- package/docs/Std.Intrinsic/Rz.md +1 -1
- package/docs/Std.Intrinsic/Rzz.md +1 -1
- package/docs/Std.Intrinsic/S.md +1 -1
- package/docs/Std.Intrinsic/SWAP.md +1 -1
- package/docs/Std.Intrinsic/SX.md +1 -1
- package/docs/Std.Intrinsic/T.md +1 -1
- package/docs/Std.Intrinsic/X.md +1 -1
- package/docs/Std.Intrinsic/Y.md +1 -1
- package/docs/Std.Intrinsic/Z.md +1 -1
- package/docs/Std.Intrinsic/index.md +1 -1
- package/docs/Std.Logical/Xor.md +1 -1
- package/docs/Std.Logical/index.md +1 -1
- package/docs/Std.Math/AbsComplex.md +1 -1
- package/docs/Std.Math/AbsComplexPolar.md +1 -1
- package/docs/Std.Math/AbsD.md +1 -1
- package/docs/Std.Math/AbsI.md +1 -1
- package/docs/Std.Math/AbsL.md +1 -1
- package/docs/Std.Math/AbsSquaredComplex.md +1 -1
- package/docs/Std.Math/AbsSquaredComplexPolar.md +1 -1
- package/docs/Std.Math/ApproximateFactorial.md +1 -1
- package/docs/Std.Math/ArcCos.md +1 -1
- package/docs/Std.Math/ArcCosh.md +1 -1
- package/docs/Std.Math/ArcSin.md +1 -1
- package/docs/Std.Math/ArcSinh.md +1 -1
- package/docs/Std.Math/ArcTan.md +1 -1
- package/docs/Std.Math/ArcTan2.md +1 -1
- package/docs/Std.Math/ArcTanh.md +1 -1
- package/docs/Std.Math/ArgComplex.md +1 -1
- package/docs/Std.Math/ArgComplexPolar.md +1 -1
- package/docs/Std.Math/Binom.md +1 -1
- package/docs/Std.Math/BitSizeI.md +1 -1
- package/docs/Std.Math/BitSizeL.md +1 -1
- package/docs/Std.Math/Ceiling.md +1 -1
- package/docs/Std.Math/Complex.md +1 -1
- package/docs/Std.Math/ComplexPolar.md +1 -1
- package/docs/Std.Math/ContinuedFractionConvergentI.md +1 -1
- package/docs/Std.Math/ContinuedFractionConvergentL.md +1 -1
- package/docs/Std.Math/Cos.md +1 -1
- package/docs/Std.Math/Cosh.md +1 -1
- package/docs/Std.Math/DivRemI.md +1 -1
- package/docs/Std.Math/DivRemL.md +1 -1
- package/docs/Std.Math/DividedByC.md +1 -1
- package/docs/Std.Math/DividedByCP.md +1 -1
- package/docs/Std.Math/E.md +1 -1
- package/docs/Std.Math/ExpModI.md +1 -1
- package/docs/Std.Math/ExpModL.md +1 -1
- package/docs/Std.Math/ExtendedGreatestCommonDivisorI.md +1 -1
- package/docs/Std.Math/ExtendedGreatestCommonDivisorL.md +1 -1
- package/docs/Std.Math/FactorialI.md +1 -1
- package/docs/Std.Math/FactorialL.md +1 -1
- package/docs/Std.Math/Floor.md +1 -1
- package/docs/Std.Math/GreatestCommonDivisorI.md +1 -1
- package/docs/Std.Math/GreatestCommonDivisorL.md +1 -1
- package/docs/Std.Math/HammingWeightI.md +1 -1
- package/docs/Std.Math/InverseModI.md +1 -1
- package/docs/Std.Math/InverseModL.md +1 -1
- package/docs/Std.Math/IsCoprimeI.md +1 -1
- package/docs/Std.Math/IsCoprimeL.md +1 -1
- package/docs/Std.Math/IsInfinite.md +1 -1
- package/docs/Std.Math/IsNaN.md +1 -1
- package/docs/Std.Math/LargestFixedPoint.md +1 -1
- package/docs/Std.Math/Lg.md +1 -1
- package/docs/Std.Math/Log.md +1 -1
- package/docs/Std.Math/Log10.md +1 -1
- package/docs/Std.Math/LogFactorialD.md +1 -1
- package/docs/Std.Math/LogGammaD.md +1 -1
- package/docs/Std.Math/LogOf2.md +1 -1
- package/docs/Std.Math/Max.md +1 -1
- package/docs/Std.Math/MaxD.md +1 -1
- package/docs/Std.Math/MaxI.md +1 -1
- package/docs/Std.Math/MaxL.md +1 -1
- package/docs/Std.Math/Min.md +1 -1
- package/docs/Std.Math/MinD.md +1 -1
- package/docs/Std.Math/MinI.md +1 -1
- package/docs/Std.Math/MinL.md +1 -1
- package/docs/Std.Math/MinusC.md +1 -1
- package/docs/Std.Math/MinusCP.md +1 -1
- package/docs/Std.Math/ModulusI.md +1 -1
- package/docs/Std.Math/ModulusL.md +1 -1
- package/docs/Std.Math/NegationC.md +1 -1
- package/docs/Std.Math/NegationCP.md +1 -1
- package/docs/Std.Math/PI.md +1 -1
- package/docs/Std.Math/PNorm.md +1 -1
- package/docs/Std.Math/PNormalized.md +1 -1
- package/docs/Std.Math/PlusC.md +1 -1
- package/docs/Std.Math/PlusCP.md +1 -1
- package/docs/Std.Math/PowC.md +1 -1
- package/docs/Std.Math/PowCP.md +1 -1
- package/docs/Std.Math/RealMod.md +1 -1
- package/docs/Std.Math/Round.md +1 -1
- package/docs/Std.Math/RoundHalfAwayFromZero.md +1 -1
- package/docs/Std.Math/SignD.md +1 -1
- package/docs/Std.Math/SignI.md +1 -1
- package/docs/Std.Math/SignL.md +1 -1
- package/docs/Std.Math/Sin.md +1 -1
- package/docs/Std.Math/Sinh.md +1 -1
- package/docs/Std.Math/SmallestFixedPoint.md +1 -1
- package/docs/Std.Math/Sqrt.md +1 -1
- package/docs/Std.Math/SquaredNorm.md +1 -1
- package/docs/Std.Math/Tan.md +1 -1
- package/docs/Std.Math/Tanh.md +1 -1
- package/docs/Std.Math/TimesC.md +1 -1
- package/docs/Std.Math/TimesCP.md +1 -1
- package/docs/Std.Math/TrailingZeroCountI.md +1 -1
- package/docs/Std.Math/TrailingZeroCountL.md +1 -1
- package/docs/Std.Math/Truncate.md +1 -1
- package/docs/Std.Math/index.md +1 -1
- package/docs/Std.Measurement/IsLossResult.md +1 -1
- package/docs/Std.Measurement/MResetEachZ.md +1 -1
- package/docs/Std.Measurement/MResetX.md +1 -1
- package/docs/Std.Measurement/MResetY.md +1 -1
- package/docs/Std.Measurement/MResetZ.md +1 -1
- package/docs/Std.Measurement/MResetZChecked.md +1 -1
- package/docs/Std.Measurement/MeasureAllZ.md +1 -1
- package/docs/Std.Measurement/MeasureEachZ.md +1 -1
- package/docs/Std.Measurement/MeasureInteger.md +1 -1
- package/docs/Std.Measurement/index.md +1 -1
- package/docs/Std.Random/DrawRandomBool.md +1 -1
- package/docs/Std.Random/DrawRandomDouble.md +1 -1
- package/docs/Std.Random/DrawRandomInt.md +1 -1
- package/docs/Std.Random/index.md +1 -1
- package/docs/Std.Range/IsRangeEmpty.md +1 -1
- package/docs/Std.Range/RangeEnd.md +1 -1
- package/docs/Std.Range/RangeReverse.md +1 -1
- package/docs/Std.Range/RangeStart.md +1 -1
- package/docs/Std.Range/RangeStep.md +1 -1
- package/docs/Std.Range/index.md +1 -1
- package/docs/Std.ResourceEstimation/AccountForEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/AuxQubitCount.md +1 -1
- package/docs/Std.ResourceEstimation/BeginEstimateCaching.md +1 -1
- package/docs/Std.ResourceEstimation/BeginRepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/CczCount.md +1 -1
- package/docs/Std.ResourceEstimation/EnableMemoryComputeArchitecture.md +1 -1
- package/docs/Std.ResourceEstimation/EndEstimateCaching.md +1 -1
- package/docs/Std.ResourceEstimation/EndRepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/LeastFrequentlyUsed.md +1 -1
- package/docs/Std.ResourceEstimation/LeastRecentlyUsed.md +1 -1
- package/docs/Std.ResourceEstimation/MeasurementCount.md +1 -1
- package/docs/Std.ResourceEstimation/PSSPCLayout.md +1 -1
- package/docs/Std.ResourceEstimation/RepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/RotationCount.md +1 -1
- package/docs/Std.ResourceEstimation/RotationDepth.md +1 -1
- package/docs/Std.ResourceEstimation/SingleVariant.md +1 -1
- package/docs/Std.ResourceEstimation/TCount.md +1 -1
- package/docs/Std.ResourceEstimation/index.md +1 -1
- package/docs/Std.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
- package/docs/Std.StatePreparation/PreparePureStateD.md +1 -1
- package/docs/Std.StatePreparation/PrepareUniformSuperposition.md +1 -1
- package/docs/Std.StatePreparation/index.md +1 -1
- package/docs/Std.TableLookup/Select.md +1 -1
- package/docs/Std.TableLookup/index.md +1 -1
- package/docs/index.md +1 -1
- package/lib/nodejs/qsc_wasm.cjs +2 -2
- package/lib/nodejs/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.js +2 -2
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/ux/atoms/index.css +28 -72
- package/ux/atoms/layout.ts +264 -56
- package/ux/chem/index.tsx +10 -18
- package/ux/chem/style.css +2 -2
- package/ux/circuit.tsx +2 -2
- package/ux/histogram.tsx +11 -5
- package/ux/qdk-theme.css +18 -1
- package/ux/qsharp-ux.css +0 -174
package/ux/atoms/layout.ts
CHANGED
|
@@ -4,17 +4,73 @@
|
|
|
4
4
|
import { appendChildren, createSvgElements, setAttributes } from "./utils.js";
|
|
5
5
|
|
|
6
6
|
// Zones will be rendered from top to bottom in array order
|
|
7
|
+
// Supports both old format (rows count) and new format (rowStart/rowEnd)
|
|
8
|
+
type ZoneDataInput = {
|
|
9
|
+
title: string;
|
|
10
|
+
kind: "register" | "interaction" | "measurement";
|
|
11
|
+
} & (
|
|
12
|
+
| { rows: number; rowStart?: never; rowEnd?: never }
|
|
13
|
+
| { rowStart: number; rowEnd: number; skipRows?: number[]; rows?: never }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// Normalized internal format always uses rowStart/rowEnd
|
|
7
17
|
type ZoneData = {
|
|
8
18
|
title: string;
|
|
9
|
-
|
|
19
|
+
rowStart: number;
|
|
20
|
+
rowEnd: number;
|
|
21
|
+
skipRows?: number[];
|
|
10
22
|
kind: "register" | "interaction" | "measurement";
|
|
11
23
|
};
|
|
12
24
|
|
|
13
25
|
export type ZoneLayout = {
|
|
14
26
|
cols: number;
|
|
15
|
-
zones:
|
|
27
|
+
zones: ZoneDataInput[];
|
|
28
|
+
// The instructions may assume certain columns are missing, but we don't render that visually.
|
|
29
|
+
// e.g. if `skipCols: [0,9]` was provided, then a `move(0,1)` would actually move to visual column 0,
|
|
30
|
+
// and a `move(1,10)` would move to visual column 8.
|
|
31
|
+
skipCols?: number[];
|
|
32
|
+
// If renumber is true, then all rows and columns will be renumbered in the visualization to be sequential starting from 0
|
|
33
|
+
renumber?: boolean;
|
|
16
34
|
};
|
|
17
35
|
|
|
36
|
+
const TWO_QUBIT_GATES = ["CX", "CY", "CZ", "RXX", "RYY", "RZZ", "SWAP"];
|
|
37
|
+
|
|
38
|
+
// Normalize zone data to always use rowStart/rowEnd format
|
|
39
|
+
function normalizeZones(zones: ZoneDataInput[]): ZoneData[] {
|
|
40
|
+
let nextRowStart = 0;
|
|
41
|
+
return zones.map((zone) => {
|
|
42
|
+
if ("rowStart" in zone && zone.rowStart !== undefined) {
|
|
43
|
+
// Verify if skipRows are within the rowStart and rowEnd range
|
|
44
|
+
if (zone.skipRows) {
|
|
45
|
+
if (
|
|
46
|
+
!zone.skipRows.every((r) => r >= zone.rowStart && r <= zone.rowEnd)
|
|
47
|
+
) {
|
|
48
|
+
throw `Invalid skipRows in zone "${zone.title}": all skipRows must be between rowStart and rowEnd`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// New format with explicit rowStart/rowEnd
|
|
52
|
+
return {
|
|
53
|
+
title: zone.title,
|
|
54
|
+
rowStart: zone.rowStart,
|
|
55
|
+
rowEnd: zone.rowEnd,
|
|
56
|
+
skipRows: zone.skipRows,
|
|
57
|
+
kind: zone.kind,
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
// Old format with rows count - convert to rowStart/rowEnd
|
|
61
|
+
const rowStart = nextRowStart;
|
|
62
|
+
const rowEnd = nextRowStart + zone.rows - 1;
|
|
63
|
+
nextRowStart = rowEnd + 1;
|
|
64
|
+
return {
|
|
65
|
+
title: zone.title,
|
|
66
|
+
rowStart,
|
|
67
|
+
rowEnd,
|
|
68
|
+
kind: zone.kind,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
18
74
|
export type TraceData = {
|
|
19
75
|
metadata: any;
|
|
20
76
|
qubits: Array<[number, number]>;
|
|
@@ -51,25 +107,41 @@ export function fillQubitLocations(
|
|
|
51
107
|
layout: ZoneLayout,
|
|
52
108
|
): Array<[number, number]> {
|
|
53
109
|
const qubits: Array<[number, number]> = [];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
110
|
+
const normalizedZones = normalizeZones(layout.zones);
|
|
111
|
+
normalizedZones.forEach((zone) => {
|
|
112
|
+
if (zone.kind === "register") {
|
|
113
|
+
for (let row = zone.rowStart; row <= zone.rowEnd; ++row) {
|
|
114
|
+
if (zone.skipRows && zone.skipRows.includes(row)) continue;
|
|
58
115
|
for (let col = 0; col < layout.cols; ++col) {
|
|
59
|
-
qubits.push([
|
|
116
|
+
qubits.push([row, col]);
|
|
60
117
|
}
|
|
61
118
|
}
|
|
62
|
-
++currRow;
|
|
63
119
|
}
|
|
64
120
|
});
|
|
65
121
|
|
|
66
122
|
return qubits;
|
|
67
123
|
}
|
|
68
124
|
|
|
69
|
-
|
|
70
|
-
|
|
125
|
+
// Maps an instruction column to a visual column by accounting for skipped columns.
|
|
126
|
+
// For each column in skipCols that is less than the instruction column, we subtract 1.
|
|
127
|
+
function mapColumn(col: number, skipCols?: number[]): number {
|
|
128
|
+
if (!skipCols || skipCols.length === 0) {
|
|
129
|
+
return col;
|
|
130
|
+
}
|
|
131
|
+
const skippedBefore = skipCols.filter((c) => c < col).length;
|
|
132
|
+
return col - skippedBefore;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function parseMove(
|
|
136
|
+
op: string,
|
|
137
|
+
skipCols?: number[],
|
|
138
|
+
): { qubit: number; to: Location } | undefined {
|
|
139
|
+
const match = op.match(/move?\((\d+), (\d+)\) (\d+)/);
|
|
71
140
|
if (match) {
|
|
72
|
-
const to: Location = [
|
|
141
|
+
const to: Location = [
|
|
142
|
+
parseInt(match[1]),
|
|
143
|
+
mapColumn(parseInt(match[2]), skipCols),
|
|
144
|
+
];
|
|
73
145
|
return { qubit: parseInt(match[3]), to };
|
|
74
146
|
}
|
|
75
147
|
return undefined;
|
|
@@ -77,24 +149,51 @@ function parseMove(op: string): { qubit: number; to: Location } | undefined {
|
|
|
77
149
|
|
|
78
150
|
function parseGate(
|
|
79
151
|
op: string,
|
|
80
|
-
): { gate: string;
|
|
81
|
-
const match = op.match(/(\w+)\s*(\(.*\))? (\d+)/);
|
|
152
|
+
): { gate: string; qubits: number[]; arg?: string } | undefined {
|
|
153
|
+
const match = op.match(/(\w+)\s*(\(.*\))? ([\d,\s]+)/);
|
|
82
154
|
if (match) {
|
|
83
155
|
const gate = match[1];
|
|
84
|
-
const
|
|
156
|
+
const qubits = match[3].split(",").map((s) => parseInt(s.trim()));
|
|
85
157
|
const arg = match[2]
|
|
86
158
|
? match[2].substring(1, match[2].length - 2)
|
|
87
159
|
: undefined;
|
|
88
|
-
return { gate,
|
|
160
|
+
return { gate, qubits, arg };
|
|
89
161
|
}
|
|
90
162
|
}
|
|
91
163
|
|
|
164
|
+
function parseZoneOp(
|
|
165
|
+
op: string,
|
|
166
|
+
layout: ZoneLayout,
|
|
167
|
+
): { op: "zone_cz" | "zone_mresetz"; zoneIndex: number } | undefined {
|
|
168
|
+
// If we get a naked 'cz' or 'mresetz', treat it as a zone op for the first zone of the matching type
|
|
169
|
+
if (op === "cz") {
|
|
170
|
+
return {
|
|
171
|
+
op: "zone_cz",
|
|
172
|
+
zoneIndex: layout.zones.findIndex((z) => z.kind === "interaction"),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (op === "mresetz") {
|
|
176
|
+
return {
|
|
177
|
+
op: "zone_mresetz",
|
|
178
|
+
zoneIndex: layout.zones.findIndex((z) => z.kind === "measurement"),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const match = op.match(/^(zone_cz|zone_mresetz)\s+(\d+)$/);
|
|
182
|
+
if (match) {
|
|
183
|
+
return {
|
|
184
|
+
op: match[1] as "zone_cz" | "zone_mresetz",
|
|
185
|
+
zoneIndex: parseInt(match[2]),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
92
191
|
/*
|
|
93
192
|
We want to build up a cache of the qubit location at each 'n' steps so that scrubbing is fast.
|
|
94
193
|
Storing for each step is too large for the number of steps we want to handle. Also, the building
|
|
95
194
|
of the cache can take a long time, so we want to chunk it up to avoid blocking the UI thread.
|
|
96
195
|
*/
|
|
97
|
-
function TraceToGetLayoutFn(trace: TraceData) {
|
|
196
|
+
function TraceToGetLayoutFn(trace: TraceData, skipCols?: number[]) {
|
|
98
197
|
const STEP_SIZE = 100; // How many steps between each cache entry
|
|
99
198
|
|
|
100
199
|
const cacheEntries = Math.ceil(trace.steps.length / STEP_SIZE);
|
|
@@ -116,7 +215,7 @@ function TraceToGetLayoutFn(trace: TraceData) {
|
|
|
116
215
|
}
|
|
117
216
|
// Extract the move operations in the prior step, to apply to the prior layout
|
|
118
217
|
const moves = trace.steps[stepIndex - 1].ops
|
|
119
|
-
.map(parseMove)
|
|
218
|
+
.map((op) => parseMove(op, skipCols))
|
|
120
219
|
.filter((x) => x != undefined);
|
|
121
220
|
|
|
122
221
|
// Then apply them to the layout
|
|
@@ -221,7 +320,9 @@ export class Layout {
|
|
|
221
320
|
height: number;
|
|
222
321
|
scale: number = initialScale;
|
|
223
322
|
qubits: Location[];
|
|
224
|
-
|
|
323
|
+
rowOffsetMap: Map<number, number>; // Maps absolute row numbers to visual Y offsets
|
|
324
|
+
normalizedZones: ZoneData[];
|
|
325
|
+
effectiveCols: number; // Visual column count after accounting for skipCols
|
|
225
326
|
currentStep = 0;
|
|
226
327
|
trackParent: SVGGElement;
|
|
227
328
|
activeGates: SVGElement[] = [];
|
|
@@ -237,9 +338,15 @@ export class Layout {
|
|
|
237
338
|
) {
|
|
238
339
|
if (!trace.qubits?.length) {
|
|
239
340
|
trace.qubits = fillQubitLocations(layout);
|
|
341
|
+
} else if (layout.skipCols?.length) {
|
|
342
|
+
// Map the initial qubit column positions if skipCols is provided
|
|
343
|
+
trace.qubits = trace.qubits.map(([row, col]) => [
|
|
344
|
+
row,
|
|
345
|
+
mapColumn(col, layout.skipCols),
|
|
346
|
+
]);
|
|
240
347
|
}
|
|
241
348
|
this.trace = trace;
|
|
242
|
-
this.getStepLayout = TraceToGetLayoutFn(trace);
|
|
349
|
+
this.getStepLayout = TraceToGetLayoutFn(trace, layout.skipCols);
|
|
243
350
|
|
|
244
351
|
this.qubits = structuredClone(trace.qubits);
|
|
245
352
|
|
|
@@ -248,11 +355,21 @@ export class Layout {
|
|
|
248
355
|
"svg",
|
|
249
356
|
);
|
|
250
357
|
|
|
251
|
-
|
|
358
|
+
// Normalize zones to always use rowStart/rowEnd format
|
|
359
|
+
this.normalizedZones = normalizeZones(layout.zones);
|
|
360
|
+
|
|
361
|
+
// Calculate effective columns (visual count after skipping)
|
|
362
|
+
this.effectiveCols = layout.cols - (layout.skipCols?.length ?? 0);
|
|
363
|
+
|
|
364
|
+
const totalRows = this.normalizedZones.reduce(
|
|
365
|
+
(prev, curr) =>
|
|
366
|
+
prev + (curr.rowEnd - curr.rowStart + 1) - (curr.skipRows?.length ?? 0),
|
|
367
|
+
0,
|
|
368
|
+
);
|
|
252
369
|
|
|
253
370
|
this.height =
|
|
254
371
|
totalRows * qubitSize + zoneSpacing * (layout.zones.length + 1);
|
|
255
|
-
this.width =
|
|
372
|
+
this.width = this.effectiveCols * qubitSize + colPadding;
|
|
256
373
|
|
|
257
374
|
setAttributes(this.container, {
|
|
258
375
|
viewBox: `-5 0 ${this.width} ${this.height}`,
|
|
@@ -261,21 +378,23 @@ export class Layout {
|
|
|
261
378
|
});
|
|
262
379
|
|
|
263
380
|
// Loop through the zones, calculating the row offsets, and rendering the zones
|
|
264
|
-
|
|
381
|
+
// Maps absolute row numbers to visual Y offsets
|
|
382
|
+
this.rowOffsetMap = new Map();
|
|
265
383
|
let nextOffset = zoneSpacing;
|
|
266
|
-
let
|
|
267
|
-
|
|
268
|
-
this.renderZone(index, nextOffset,
|
|
269
|
-
for (let
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
384
|
+
let globalRowIndex = 0;
|
|
385
|
+
this.normalizedZones.forEach((zone, index) => {
|
|
386
|
+
globalRowIndex = this.renderZone(index, nextOffset, globalRowIndex);
|
|
387
|
+
for (let row = zone.rowStart; row <= zone.rowEnd; ++row) {
|
|
388
|
+
if (!zone.skipRows?.includes(row)) {
|
|
389
|
+
this.rowOffsetMap.set(row, nextOffset);
|
|
390
|
+
nextOffset += qubitSize;
|
|
391
|
+
}
|
|
273
392
|
}
|
|
274
393
|
nextOffset += zoneSpacing; // Add spacing after each zone
|
|
275
394
|
});
|
|
276
395
|
|
|
277
396
|
const colNumOffset = nextOffset - 8;
|
|
278
|
-
this.renderColNums(
|
|
397
|
+
this.renderColNums(this.effectiveCols, colNumOffset);
|
|
279
398
|
|
|
280
399
|
// Put the track parent before the qubits, so the qubits render on top
|
|
281
400
|
this.trackParent = createSvgElements("g")[0] as SVGGElement;
|
|
@@ -319,8 +438,17 @@ export class Layout {
|
|
|
319
438
|
return this.trace.steps[step].ops;
|
|
320
439
|
}
|
|
321
440
|
|
|
322
|
-
private renderZone(
|
|
323
|
-
|
|
441
|
+
private renderZone(
|
|
442
|
+
zoneIndex: number,
|
|
443
|
+
offset: number,
|
|
444
|
+
globalRowIndex: number,
|
|
445
|
+
): number {
|
|
446
|
+
const zoneData = this.normalizedZones[zoneIndex];
|
|
447
|
+
const zoneRows =
|
|
448
|
+
zoneData.rowEnd -
|
|
449
|
+
zoneData.rowStart +
|
|
450
|
+
1 -
|
|
451
|
+
(zoneData.skipRows?.length ?? 0);
|
|
324
452
|
const g = createSvgElements("g")[0];
|
|
325
453
|
setAttributes(g, {
|
|
326
454
|
transform: `translate(0 ${offset})`,
|
|
@@ -333,32 +461,32 @@ export class Layout {
|
|
|
333
461
|
setAttributes(rect, {
|
|
334
462
|
x: "0",
|
|
335
463
|
y: "0",
|
|
336
|
-
width: `${this.
|
|
337
|
-
height: `${
|
|
464
|
+
width: `${this.effectiveCols * qubitSize}`,
|
|
465
|
+
height: `${zoneRows * qubitSize}`,
|
|
338
466
|
rx: `${zoneBoxCornerRadius}`,
|
|
339
467
|
});
|
|
340
468
|
appendChildren(g, [rect]);
|
|
341
469
|
|
|
342
470
|
// Draw the lines between the rows
|
|
343
|
-
for (let i = 1; i <
|
|
471
|
+
for (let i = 1; i < zoneRows; i++) {
|
|
344
472
|
const path = createSvgElements("path")[0];
|
|
345
473
|
setAttributes(path, {
|
|
346
|
-
d: `M 0,${i * qubitSize} h${this.
|
|
474
|
+
d: `M 0,${i * qubitSize} h${this.effectiveCols * qubitSize}`,
|
|
347
475
|
});
|
|
348
476
|
appendChildren(g, [path]);
|
|
349
477
|
}
|
|
350
478
|
// Draw the lines between the columns
|
|
351
|
-
for (let i = 1; i < this.
|
|
479
|
+
for (let i = 1; i < this.effectiveCols; i++) {
|
|
352
480
|
const path = createSvgElements("path")[0];
|
|
353
481
|
setAttributes(path, {
|
|
354
|
-
d: `M ${i * qubitSize},0 v${
|
|
482
|
+
d: `M ${i * qubitSize},0 v${zoneRows * qubitSize}`,
|
|
355
483
|
});
|
|
356
484
|
appendChildren(g, [path]);
|
|
357
485
|
}
|
|
358
486
|
} else {
|
|
359
487
|
// For the interaction zone draw each doublon
|
|
360
|
-
for (let row = 0; row <
|
|
361
|
-
for (let i = 0; i < this.
|
|
488
|
+
for (let row = 0; row < zoneRows; ++row) {
|
|
489
|
+
for (let i = 0; i < this.effectiveCols; i += 2) {
|
|
362
490
|
const rect = createSvgElements("rect")[0];
|
|
363
491
|
setAttributes(rect, {
|
|
364
492
|
x: `${i * qubitSize}`,
|
|
@@ -376,17 +504,20 @@ export class Layout {
|
|
|
376
504
|
}
|
|
377
505
|
}
|
|
378
506
|
|
|
379
|
-
// Number the rows
|
|
380
|
-
|
|
381
|
-
|
|
507
|
+
// Number the rows using the absolute row numbers from rowStart to rowEnd
|
|
508
|
+
let i = 0;
|
|
509
|
+
for (let rowNum = zoneData.rowStart; rowNum <= zoneData.rowEnd; ++rowNum) {
|
|
510
|
+
if (zoneData.skipRows && zoneData.skipRows.includes(rowNum)) continue;
|
|
382
511
|
const label = createSvgElements("text")[0];
|
|
383
512
|
setAttributes(label, {
|
|
384
|
-
x: `${this.
|
|
513
|
+
x: `${this.effectiveCols * qubitSize + 5}`,
|
|
385
514
|
y: `${i * qubitSize + 5}`,
|
|
386
515
|
class: "qs-atoms-label",
|
|
387
516
|
});
|
|
388
|
-
label.textContent = `${rowNum}`;
|
|
517
|
+
label.textContent = `${this.layout.renumber ? globalRowIndex : rowNum}`;
|
|
389
518
|
appendChildren(g, [label]);
|
|
519
|
+
++i;
|
|
520
|
+
++globalRowIndex;
|
|
390
521
|
}
|
|
391
522
|
|
|
392
523
|
// Draw the title
|
|
@@ -400,6 +531,7 @@ export class Layout {
|
|
|
400
531
|
|
|
401
532
|
appendChildren(g, [text]);
|
|
402
533
|
appendChildren(this.container, [g]);
|
|
534
|
+
return globalRowIndex;
|
|
403
535
|
}
|
|
404
536
|
|
|
405
537
|
private renderQubits() {
|
|
@@ -435,16 +567,20 @@ export class Layout {
|
|
|
435
567
|
setAttributes(g, {
|
|
436
568
|
transform: `translate(0 ${offset})`,
|
|
437
569
|
});
|
|
438
|
-
// Number the columns
|
|
439
|
-
|
|
570
|
+
// Number the columns, showing original column numbers (skipping those in skipCols)
|
|
571
|
+
const skipCols = this.layout.skipCols ?? [];
|
|
572
|
+
let visualCol = 0;
|
|
573
|
+
for (let origCol = 0; visualCol < cols; ++origCol) {
|
|
574
|
+
if (skipCols.includes(origCol)) continue;
|
|
440
575
|
const label = createSvgElements("text")[0];
|
|
441
576
|
setAttributes(label, {
|
|
442
|
-
x: `${
|
|
577
|
+
x: `${visualCol * qubitSize + 5}`,
|
|
443
578
|
y: `5`,
|
|
444
579
|
class: "qs-atoms-label",
|
|
445
580
|
});
|
|
446
|
-
label.textContent = `${
|
|
581
|
+
label.textContent = `${this.layout.renumber ? visualCol : origCol}`;
|
|
447
582
|
appendChildren(g, [label]);
|
|
583
|
+
++visualCol;
|
|
448
584
|
}
|
|
449
585
|
appendChildren(this.container, [g]);
|
|
450
586
|
}
|
|
@@ -588,7 +724,27 @@ export class Layout {
|
|
|
588
724
|
}
|
|
589
725
|
|
|
590
726
|
getQubitRowOffset(row: number) {
|
|
591
|
-
|
|
727
|
+
const offset = this.rowOffsetMap.get(row);
|
|
728
|
+
if (offset === undefined) {
|
|
729
|
+
throw `Row ${row} not found in layout`;
|
|
730
|
+
}
|
|
731
|
+
return offset;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Returns array of qubit indices that are currently in the specified zone
|
|
735
|
+
getQubitsInZone(zoneIndex: number): number[] {
|
|
736
|
+
const zone = this.normalizedZones[zoneIndex];
|
|
737
|
+
if (!zone) {
|
|
738
|
+
throw `Zone ${zoneIndex} not found`;
|
|
739
|
+
}
|
|
740
|
+
const qubitsInZone: number[] = [];
|
|
741
|
+
for (let i = 0; i < this.qubits.length; i++) {
|
|
742
|
+
const [row] = this.qubits[i];
|
|
743
|
+
if (row >= zone.rowStart && row <= zone.rowEnd) {
|
|
744
|
+
qubitsInZone.push(i);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return qubitsInZone;
|
|
592
748
|
}
|
|
593
749
|
|
|
594
750
|
getLocationCenter(row: number, col: number): [number, number] {
|
|
@@ -645,7 +801,7 @@ export class Layout {
|
|
|
645
801
|
const ops = this.getOpsAtStep(qubitLocationIndex);
|
|
646
802
|
let trailId = 0;
|
|
647
803
|
ops.forEach((op) => {
|
|
648
|
-
const move = parseMove(op);
|
|
804
|
+
const move = parseMove(op, this.layout.skipCols);
|
|
649
805
|
if (move) {
|
|
650
806
|
// Apply the move animation
|
|
651
807
|
const [oldX, oldY] = this.getQubitCenter(move.qubit);
|
|
@@ -718,11 +874,63 @@ export class Layout {
|
|
|
718
874
|
});
|
|
719
875
|
// TODO: Check if you can/should cancel when scrubbing
|
|
720
876
|
} else {
|
|
721
|
-
//
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
|
|
725
|
-
|
|
877
|
+
// Check if it's a zone operation
|
|
878
|
+
const zoneOp = parseZoneOp(op, this.layout);
|
|
879
|
+
if (zoneOp) {
|
|
880
|
+
const qubitsInZone = this.getQubitsInZone(zoneOp.zoneIndex);
|
|
881
|
+
if (zoneOp.op === "zone_cz") {
|
|
882
|
+
// For zone_cz, render CZ gates on pairs of qubits in doublons
|
|
883
|
+
// Group qubits by their row, then pair adjacent columns
|
|
884
|
+
const qubitsByRow = new Map<number, number[]>();
|
|
885
|
+
for (const qubitIdx of qubitsInZone) {
|
|
886
|
+
const [row] = this.qubits[qubitIdx];
|
|
887
|
+
if (!qubitsByRow.has(row)) {
|
|
888
|
+
qubitsByRow.set(row, []);
|
|
889
|
+
}
|
|
890
|
+
qubitsByRow.get(row)!.push(qubitIdx);
|
|
891
|
+
}
|
|
892
|
+
// For each row, find pairs in doublons (col 0-1, 2-3, 4-5, etc.)
|
|
893
|
+
for (const [, qubitsInRow] of qubitsByRow) {
|
|
894
|
+
// Sort by column
|
|
895
|
+
qubitsInRow.sort(
|
|
896
|
+
(a, b) => this.qubits[a][1] - this.qubits[b][1],
|
|
897
|
+
);
|
|
898
|
+
for (let i = 0; i < qubitsInRow.length - 1; i++) {
|
|
899
|
+
const q1 = qubitsInRow[i];
|
|
900
|
+
const q2 = qubitsInRow[i + 1];
|
|
901
|
+
const col1 = this.qubits[q1][1];
|
|
902
|
+
const col2 = this.qubits[q2][1];
|
|
903
|
+
// Check if they're in the same doublon (even-odd pair)
|
|
904
|
+
if (Math.floor(col1 / 2) === Math.floor(col2 / 2)) {
|
|
905
|
+
this.renderGateOnQubit(q1, "CZ");
|
|
906
|
+
i++; // Skip the next qubit since we've paired it
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
} else if (zoneOp.op === "zone_mresetz") {
|
|
911
|
+
// For zone_mresetz, render MZ gate on all qubits in the zone
|
|
912
|
+
for (const qubitIdx of qubitsInZone) {
|
|
913
|
+
this.renderGateOnQubit(qubitIdx, "MZ");
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
} else {
|
|
917
|
+
// Wasn't a move or zone op, so render the gate
|
|
918
|
+
const gate = parseGate(op);
|
|
919
|
+
if (!gate) throw `Invalid gate: ${op}`;
|
|
920
|
+
const arg = gate.arg ? gate.arg.substring(0, 4) : undefined;
|
|
921
|
+
const isTwoQubitGate = TWO_QUBIT_GATES.includes(
|
|
922
|
+
gate.gate.toUpperCase(),
|
|
923
|
+
);
|
|
924
|
+
// Handle the case where an op is a list of qubits to apply the same op to
|
|
925
|
+
for (let i = 0; i < gate.qubits.length; i++) {
|
|
926
|
+
if (isTwoQubitGate && i % 2 !== 0) continue;
|
|
927
|
+
this.renderGateOnQubit(
|
|
928
|
+
gate.qubits[i],
|
|
929
|
+
gate.gate.toUpperCase(),
|
|
930
|
+
arg,
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
726
934
|
}
|
|
727
935
|
});
|
|
728
936
|
}
|
package/ux/chem/index.tsx
CHANGED
|
@@ -5,8 +5,7 @@ import { useRef, useEffect, useState } from "preact/hooks";
|
|
|
5
5
|
import { createViewer, GLViewer } from "3dmol";
|
|
6
6
|
|
|
7
7
|
import "./style.css";
|
|
8
|
-
|
|
9
|
-
const themeAttribute = "data-vscode-theme-kind";
|
|
8
|
+
import { detectThemeChange } from "../themeObserver.js";
|
|
10
9
|
|
|
11
10
|
export function MoleculeViewer(props: {
|
|
12
11
|
moleculeData: string;
|
|
@@ -29,7 +28,7 @@ export function MoleculeViewer(props: {
|
|
|
29
28
|
viewer.current ??
|
|
30
29
|
createViewer(viewerRef.current, {
|
|
31
30
|
backgroundColor: getComputedStyle(document.body).getPropertyValue(
|
|
32
|
-
"--
|
|
31
|
+
"--qdk-host-background",
|
|
33
32
|
),
|
|
34
33
|
});
|
|
35
34
|
try {
|
|
@@ -44,22 +43,15 @@ export function MoleculeViewer(props: {
|
|
|
44
43
|
viewer.current.zoomTo();
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (viewer.current) {
|
|
55
|
-
viewer.current.setBackgroundColor(newBackgroundColor, 1.0);
|
|
56
|
-
viewer.current.render();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
46
|
+
detectThemeChange(document.body, () => {
|
|
47
|
+
const newBackgroundColor = getComputedStyle(
|
|
48
|
+
document.body,
|
|
49
|
+
).getPropertyValue("--qdk-host-background");
|
|
50
|
+
if (viewer.current) {
|
|
51
|
+
viewer.current.setBackgroundColor(newBackgroundColor, 1.0);
|
|
52
|
+
viewer.current.render();
|
|
59
53
|
}
|
|
60
|
-
};
|
|
61
|
-
const observer = new MutationObserver(callback);
|
|
62
|
-
observer.observe(document.body, { attributeFilter: [themeAttribute] });
|
|
54
|
+
});
|
|
63
55
|
}, [props.moleculeData]);
|
|
64
56
|
|
|
65
57
|
useEffect(() => {
|
package/ux/chem/style.css
CHANGED
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
|
|
48
48
|
.view-option select,
|
|
49
49
|
.view-option input[type="range"] {
|
|
50
|
-
color: var(--
|
|
51
|
-
background-color: var(--
|
|
50
|
+
color: var(--qdk-host-foreground);
|
|
51
|
+
background-color: var(--qdk-host-background);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
#cube-dropdown-container {
|
package/ux/circuit.tsx
CHANGED
|
@@ -23,7 +23,7 @@ export function Circuit(props: {
|
|
|
23
23
|
isEditable: boolean;
|
|
24
24
|
editCallback?: (fileData: qviz.CircuitGroup) => void;
|
|
25
25
|
runCallback?: () => void;
|
|
26
|
-
renderLocations
|
|
26
|
+
renderLocations?: (s: SourceLocation[]) => { title: string; href: string };
|
|
27
27
|
}) {
|
|
28
28
|
let unrenderable = false;
|
|
29
29
|
let qubits = 0;
|
|
@@ -68,7 +68,7 @@ function ZoomableCircuit(props: {
|
|
|
68
68
|
isEditable: boolean;
|
|
69
69
|
editCallback?: (fileData: qviz.CircuitGroup) => void;
|
|
70
70
|
runCallback?: () => void;
|
|
71
|
-
renderLocations
|
|
71
|
+
renderLocations?: (s: SourceLocation[]) => { title: string; href: string };
|
|
72
72
|
}) {
|
|
73
73
|
const circuitDiv = useRef<HTMLDivElement>(null);
|
|
74
74
|
const [zoomLevel, setZoomLevel] = useState(100);
|
package/ux/histogram.tsx
CHANGED
|
@@ -67,17 +67,23 @@ function getDefaultMenuSelection(
|
|
|
67
67
|
return selection;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const reKetResult =
|
|
70
|
+
const reKetResult =
|
|
71
|
+
/^\[(?:(Zero|One|Loss|0|1|2|-), *)*(Zero|One|Loss|0|1|2|-)\]$/;
|
|
71
72
|
function resultToKet(result: string): string {
|
|
72
73
|
if (typeof result !== "string") return "ERROR";
|
|
73
74
|
|
|
74
75
|
if (reKetResult.test(result)) {
|
|
75
|
-
// The result
|
|
76
|
-
|
|
77
|
-
const matches = result.match(/(One|Zero|Loss)/g);
|
|
76
|
+
// The result fits our expected pattern, so we can convert it to a ket. If not, just return the raw result.
|
|
77
|
+
const matches = result.match(/(One|Zero|Loss|0|1|2|-)/g);
|
|
78
78
|
let ket = "|";
|
|
79
79
|
matches?.forEach(
|
|
80
|
-
(digit) =>
|
|
80
|
+
(digit) =>
|
|
81
|
+
(ket +=
|
|
82
|
+
digit == "One" || digit == "1"
|
|
83
|
+
? "1"
|
|
84
|
+
: digit == "Zero" || digit == "0"
|
|
85
|
+
? "0"
|
|
86
|
+
: "-"),
|
|
81
87
|
);
|
|
82
88
|
ket += "⟩";
|
|
83
89
|
return ket;
|
package/ux/qdk-theme.css
CHANGED
|
@@ -68,6 +68,7 @@ body[data-jp-theme-light="true"],
|
|
|
68
68
|
body[data-vscode-theme-kind="vscode-light"],
|
|
69
69
|
body[data-vscode-theme-kind="vscode-high-contrast-light"] {
|
|
70
70
|
/* Set any non-theme specific values here only */
|
|
71
|
+
--qdk-font-family: system-ui, "Segoe UI", "Roboto", sans-serif;
|
|
71
72
|
--qdk-font-family-monospace: var(
|
|
72
73
|
--vscode-editor-font-family,
|
|
73
74
|
"Consolas",
|
|
@@ -88,6 +89,7 @@ body[data-vscode-theme-kind="vscode-high-contrast-light"] {
|
|
|
88
89
|
var(--jp-widgets-color, #222)
|
|
89
90
|
);
|
|
90
91
|
--qdk-background-accent: #ddd;
|
|
92
|
+
--qdk-foreground-muted: #aaa;
|
|
91
93
|
|
|
92
94
|
/* Used for text that must stand out on various backgrounds */
|
|
93
95
|
--qdk-text-high-contrast: #000;
|
|
@@ -96,7 +98,7 @@ body[data-vscode-theme-kind="vscode-high-contrast-light"] {
|
|
|
96
98
|
--qdk-widget-outline: #ccc;
|
|
97
99
|
|
|
98
100
|
/* Use for menus */
|
|
99
|
-
--qdk-menu-fill: #
|
|
101
|
+
--qdk-menu-fill: #c4dbeb;
|
|
100
102
|
--qdk-menu-fill-hover: #9cf;
|
|
101
103
|
--qdk-menu-fill-selected: #7af;
|
|
102
104
|
|
|
@@ -105,6 +107,13 @@ body[data-vscode-theme-kind="vscode-high-contrast-light"] {
|
|
|
105
107
|
--qdk-shape-fill-selected: #b5c5f2;
|
|
106
108
|
--qdk-shape-stroke-selected: #587ddd;
|
|
107
109
|
--qdk-shape-stroke-hover: #6b6b6b;
|
|
110
|
+
|
|
111
|
+
--qdk-gate-generic: #66d;
|
|
112
|
+
--qdk-gate-pair: #eae753;
|
|
113
|
+
--qdk-gate-measure: #822;
|
|
114
|
+
--qdk-gate-reset: #282;
|
|
115
|
+
--qdk-atom-fill: #0078d4;
|
|
116
|
+
--qdk-atom-trail: #fa0;
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
/* Set these variables on the body element if attributes indicate a dark theme choice */
|
|
@@ -122,6 +131,7 @@ body[data-vscode-theme-kind="vscode-high-contrast"] {
|
|
|
122
131
|
var(--jp-widgets-color, #eee)
|
|
123
132
|
);
|
|
124
133
|
--qdk-background-accent: #333;
|
|
134
|
+
--qdk-foreground-muted: #666;
|
|
125
135
|
|
|
126
136
|
/* Used for text that must stand out on various backgrounds */
|
|
127
137
|
--qdk-text-high-contrast: #fff;
|
|
@@ -139,4 +149,11 @@ body[data-vscode-theme-kind="vscode-high-contrast"] {
|
|
|
139
149
|
--qdk-shape-fill-selected: #ffd54f;
|
|
140
150
|
--qdk-shape-stroke-selected: #ffecb3;
|
|
141
151
|
--qdk-shape-stroke-hover: #c5c5c5;
|
|
152
|
+
|
|
153
|
+
--qdk-gate-generic: #ccf;
|
|
154
|
+
--qdk-gate-pair: #b91;
|
|
155
|
+
--qdk-gate-measure: #e88;
|
|
156
|
+
--qdk-gate-reset: #8e8;
|
|
157
|
+
--qdk-atom-fill: #9df;
|
|
158
|
+
--qdk-atom-trail: #fa0;
|
|
142
159
|
}
|