qsharp-lang 1.15.2-dev → 1.15.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.
Files changed (330) hide show
  1. package/dist/katas-content.generated.js +5 -5
  2. package/dist/katas-content.generated.md.js +5 -5
  3. package/dist/samples.generated.js +6 -0
  4. package/dist/shared/legacyCircuitUpdate.js +1 -0
  5. package/dist/shared/register.d.ts +5 -5
  6. package/docs/Microsoft.Quantum.Core/Length.md +1 -1
  7. package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
  8. package/docs/Microsoft.Quantum.Core/index.md +1 -1
  9. package/docs/Std.Arithmetic/AddLE.md +1 -1
  10. package/docs/Std.Arithmetic/ApplyIfEqualL.md +1 -1
  11. package/docs/Std.Arithmetic/ApplyIfEqualLE.md +1 -1
  12. package/docs/Std.Arithmetic/ApplyIfGreaterL.md +1 -1
  13. package/docs/Std.Arithmetic/ApplyIfGreaterLE.md +1 -1
  14. package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
  15. package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
  16. package/docs/Std.Arithmetic/ApplyIfLessL.md +1 -1
  17. package/docs/Std.Arithmetic/ApplyIfLessLE.md +1 -1
  18. package/docs/Std.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
  19. package/docs/Std.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
  20. package/docs/Std.Arithmetic/FourierTDIncByLE.md +1 -1
  21. package/docs/Std.Arithmetic/IncByI.md +1 -1
  22. package/docs/Std.Arithmetic/IncByIUsingIncByLE.md +1 -1
  23. package/docs/Std.Arithmetic/IncByL.md +1 -1
  24. package/docs/Std.Arithmetic/IncByLE.md +1 -1
  25. package/docs/Std.Arithmetic/IncByLEUsingAddLE.md +1 -1
  26. package/docs/Std.Arithmetic/IncByLUsingIncByLE.md +1 -1
  27. package/docs/Std.Arithmetic/LookAheadDKRSAddLE.md +1 -1
  28. package/docs/Std.Arithmetic/MAJ.md +1 -1
  29. package/docs/Std.Arithmetic/ReflectAboutInteger.md +1 -1
  30. package/docs/Std.Arithmetic/RippleCarryCGAddLE.md +1 -1
  31. package/docs/Std.Arithmetic/RippleCarryCGIncByLE.md +1 -1
  32. package/docs/Std.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
  33. package/docs/Std.Arithmetic/index.md +1 -1
  34. package/docs/Std.Arrays/All.md +1 -1
  35. package/docs/Std.Arrays/Any.md +1 -1
  36. package/docs/Std.Arrays/Chunks.md +1 -1
  37. package/docs/Std.Arrays/CircularlyShifted.md +1 -1
  38. package/docs/Std.Arrays/ColumnAt.md +1 -1
  39. package/docs/Std.Arrays/Count.md +1 -1
  40. package/docs/Std.Arrays/Diagonal.md +1 -1
  41. package/docs/Std.Arrays/DrawMany.md +1 -1
  42. package/docs/Std.Arrays/Enumerated.md +1 -1
  43. package/docs/Std.Arrays/Excluding.md +1 -1
  44. package/docs/Std.Arrays/Filtered.md +1 -1
  45. package/docs/Std.Arrays/FlatMapped.md +1 -1
  46. package/docs/Std.Arrays/Flattened.md +1 -1
  47. package/docs/Std.Arrays/Fold.md +1 -1
  48. package/docs/Std.Arrays/ForEach.md +1 -1
  49. package/docs/Std.Arrays/Head.md +1 -1
  50. package/docs/Std.Arrays/HeadAndRest.md +1 -1
  51. package/docs/Std.Arrays/IndexOf.md +1 -1
  52. package/docs/Std.Arrays/IndexRange.md +1 -1
  53. package/docs/Std.Arrays/Interleaved.md +1 -1
  54. package/docs/Std.Arrays/IsEmpty.md +1 -1
  55. package/docs/Std.Arrays/IsRectangularArray.md +1 -1
  56. package/docs/Std.Arrays/IsSorted.md +1 -1
  57. package/docs/Std.Arrays/IsSquareArray.md +1 -1
  58. package/docs/Std.Arrays/Mapped.md +1 -1
  59. package/docs/Std.Arrays/MappedByIndex.md +1 -1
  60. package/docs/Std.Arrays/MappedOverRange.md +1 -1
  61. package/docs/Std.Arrays/Most.md +1 -1
  62. package/docs/Std.Arrays/MostAndTail.md +1 -1
  63. package/docs/Std.Arrays/Padded.md +1 -1
  64. package/docs/Std.Arrays/Partitioned.md +1 -1
  65. package/docs/Std.Arrays/Rest.md +1 -1
  66. package/docs/Std.Arrays/Reversed.md +1 -1
  67. package/docs/Std.Arrays/SequenceI.md +1 -1
  68. package/docs/Std.Arrays/SequenceL.md +1 -1
  69. package/docs/Std.Arrays/Sorted.md +1 -1
  70. package/docs/Std.Arrays/Subarray.md +1 -1
  71. package/docs/Std.Arrays/Swapped.md +1 -1
  72. package/docs/Std.Arrays/Tail.md +1 -1
  73. package/docs/Std.Arrays/Transposed.md +1 -1
  74. package/docs/Std.Arrays/Unzipped.md +1 -1
  75. package/docs/Std.Arrays/Where.md +1 -1
  76. package/docs/Std.Arrays/Windows.md +1 -1
  77. package/docs/Std.Arrays/Zipped.md +1 -1
  78. package/docs/Std.Arrays/index.md +1 -1
  79. package/docs/Std.Canon/ApplyCNOTChain.md +1 -1
  80. package/docs/Std.Canon/ApplyControlledOnBitString.md +1 -1
  81. package/docs/Std.Canon/ApplyControlledOnInt.md +1 -1
  82. package/docs/Std.Canon/ApplyOperationPowerA.md +25 -0
  83. package/docs/Std.Canon/ApplyP.md +1 -1
  84. package/docs/Std.Canon/ApplyPauli.md +1 -1
  85. package/docs/Std.Canon/ApplyPauliFromBitString.md +1 -1
  86. package/docs/Std.Canon/ApplyPauliFromInt.md +1 -1
  87. package/docs/Std.Canon/ApplyQFT.md +1 -1
  88. package/docs/Std.Canon/ApplyToEach.md +1 -1
  89. package/docs/Std.Canon/ApplyToEachA.md +1 -1
  90. package/docs/Std.Canon/ApplyToEachC.md +1 -1
  91. package/docs/Std.Canon/ApplyToEachCA.md +1 -1
  92. package/docs/Std.Canon/ApplyXorInPlace.md +1 -1
  93. package/docs/Std.Canon/ApplyXorInPlaceL.md +1 -1
  94. package/docs/Std.Canon/CX.md +1 -1
  95. package/docs/Std.Canon/CY.md +1 -1
  96. package/docs/Std.Canon/CZ.md +1 -1
  97. package/docs/Std.Canon/Fst.md +1 -1
  98. package/docs/Std.Canon/Relabel.md +1 -1
  99. package/docs/Std.Canon/Snd.md +1 -1
  100. package/docs/Std.Canon/SwapReverseRegister.md +1 -1
  101. package/docs/Std.Canon/index.md +2 -1
  102. package/docs/Std.Convert/BigIntAsBoolArray.md +1 -1
  103. package/docs/Std.Convert/BigIntAsInt.md +30 -0
  104. package/docs/Std.Convert/BoolArrayAsBigInt.md +1 -1
  105. package/docs/Std.Convert/BoolArrayAsInt.md +1 -1
  106. package/docs/Std.Convert/BoolArrayAsResultArray.md +1 -1
  107. package/docs/Std.Convert/BoolAsResult.md +1 -1
  108. package/docs/Std.Convert/ComplexAsComplexPolar.md +1 -1
  109. package/docs/Std.Convert/ComplexPolarAsComplex.md +1 -1
  110. package/docs/Std.Convert/DoubleAsStringWithPrecision.md +1 -1
  111. package/docs/Std.Convert/IntAsBigInt.md +1 -1
  112. package/docs/Std.Convert/IntAsBoolArray.md +1 -1
  113. package/docs/Std.Convert/IntAsDouble.md +1 -1
  114. package/docs/Std.Convert/ResultArrayAsBoolArray.md +1 -1
  115. package/docs/Std.Convert/ResultArrayAsInt.md +1 -1
  116. package/docs/Std.Convert/ResultAsBool.md +1 -1
  117. package/docs/Std.Convert/index.md +2 -1
  118. package/docs/Std.Core/Length.md +1 -1
  119. package/docs/Std.Core/Repeated.md +1 -1
  120. package/docs/Std.Core/index.md +1 -1
  121. package/docs/Std.Diagnostics/ApplyIdleNoise.md +1 -1
  122. package/docs/Std.Diagnostics/BitFlipNoise.md +1 -1
  123. package/docs/Std.Diagnostics/CheckAllZero.md +1 -1
  124. package/docs/Std.Diagnostics/CheckOperationsAreEqual.md +1 -1
  125. package/docs/Std.Diagnostics/CheckZero.md +1 -1
  126. package/docs/Std.Diagnostics/ConfigurePauliNoise.md +1 -1
  127. package/docs/Std.Diagnostics/DepolarizingNoise.md +1 -1
  128. package/docs/Std.Diagnostics/DumpMachine.md +1 -1
  129. package/docs/Std.Diagnostics/DumpOperation.md +1 -1
  130. package/docs/Std.Diagnostics/DumpRegister.md +1 -1
  131. package/docs/Std.Diagnostics/Fact.md +1 -1
  132. package/docs/Std.Diagnostics/NoNoise.md +1 -1
  133. package/docs/Std.Diagnostics/PhaseFlipNoise.md +1 -1
  134. package/docs/Std.Diagnostics/StartCountingFunction.md +1 -1
  135. package/docs/Std.Diagnostics/StartCountingOperation.md +1 -1
  136. package/docs/Std.Diagnostics/StartCountingQubits.md +1 -1
  137. package/docs/Std.Diagnostics/StopCountingFunction.md +1 -1
  138. package/docs/Std.Diagnostics/StopCountingOperation.md +1 -1
  139. package/docs/Std.Diagnostics/StopCountingQubits.md +1 -1
  140. package/docs/Std.Diagnostics/index.md +1 -1
  141. package/docs/Std.Intrinsic/AND.md +1 -1
  142. package/docs/Std.Intrinsic/ApplyUnitary.md +1 -1
  143. package/docs/Std.Intrinsic/CCNOT.md +1 -1
  144. package/docs/Std.Intrinsic/CNOT.md +1 -1
  145. package/docs/Std.Intrinsic/Exp.md +1 -1
  146. package/docs/Std.Intrinsic/H.md +1 -1
  147. package/docs/Std.Intrinsic/I.md +1 -1
  148. package/docs/Std.Intrinsic/M.md +1 -1
  149. package/docs/Std.Intrinsic/Measure.md +1 -1
  150. package/docs/Std.Intrinsic/Message.md +1 -1
  151. package/docs/Std.Intrinsic/R.md +1 -1
  152. package/docs/Std.Intrinsic/R1.md +1 -1
  153. package/docs/Std.Intrinsic/R1Frac.md +1 -1
  154. package/docs/Std.Intrinsic/RFrac.md +1 -1
  155. package/docs/Std.Intrinsic/Reset.md +1 -1
  156. package/docs/Std.Intrinsic/ResetAll.md +1 -1
  157. package/docs/Std.Intrinsic/Rx.md +1 -1
  158. package/docs/Std.Intrinsic/Rxx.md +1 -1
  159. package/docs/Std.Intrinsic/Ry.md +1 -1
  160. package/docs/Std.Intrinsic/Ryy.md +1 -1
  161. package/docs/Std.Intrinsic/Rz.md +1 -1
  162. package/docs/Std.Intrinsic/Rzz.md +1 -1
  163. package/docs/Std.Intrinsic/S.md +1 -1
  164. package/docs/Std.Intrinsic/SWAP.md +1 -1
  165. package/docs/Std.Intrinsic/T.md +1 -1
  166. package/docs/Std.Intrinsic/X.md +1 -1
  167. package/docs/Std.Intrinsic/Y.md +1 -1
  168. package/docs/Std.Intrinsic/Z.md +1 -1
  169. package/docs/Std.Intrinsic/index.md +1 -1
  170. package/docs/Std.Logical/Xor.md +1 -1
  171. package/docs/Std.Logical/index.md +1 -1
  172. package/docs/Std.Math/AbsComplex.md +1 -1
  173. package/docs/Std.Math/AbsComplexPolar.md +1 -1
  174. package/docs/Std.Math/AbsD.md +1 -1
  175. package/docs/Std.Math/AbsI.md +1 -1
  176. package/docs/Std.Math/AbsL.md +1 -1
  177. package/docs/Std.Math/AbsSquaredComplex.md +1 -1
  178. package/docs/Std.Math/AbsSquaredComplexPolar.md +1 -1
  179. package/docs/Std.Math/ApproximateFactorial.md +1 -1
  180. package/docs/Std.Math/ArcCos.md +1 -1
  181. package/docs/Std.Math/ArcCosh.md +1 -1
  182. package/docs/Std.Math/ArcSin.md +1 -1
  183. package/docs/Std.Math/ArcSinh.md +1 -1
  184. package/docs/Std.Math/ArcTan.md +1 -1
  185. package/docs/Std.Math/ArcTan2.md +1 -1
  186. package/docs/Std.Math/ArcTanh.md +1 -1
  187. package/docs/Std.Math/ArgComplex.md +1 -1
  188. package/docs/Std.Math/ArgComplexPolar.md +1 -1
  189. package/docs/Std.Math/Binom.md +1 -1
  190. package/docs/Std.Math/BitSizeI.md +1 -1
  191. package/docs/Std.Math/BitSizeL.md +1 -1
  192. package/docs/Std.Math/Ceiling.md +1 -1
  193. package/docs/Std.Math/Complex.md +1 -1
  194. package/docs/Std.Math/ComplexPolar.md +1 -1
  195. package/docs/Std.Math/ContinuedFractionConvergentI.md +1 -1
  196. package/docs/Std.Math/ContinuedFractionConvergentL.md +1 -1
  197. package/docs/Std.Math/Cos.md +1 -1
  198. package/docs/Std.Math/Cosh.md +1 -1
  199. package/docs/Std.Math/DivRemI.md +1 -1
  200. package/docs/Std.Math/DivRemL.md +1 -1
  201. package/docs/Std.Math/DividedByC.md +1 -1
  202. package/docs/Std.Math/DividedByCP.md +1 -1
  203. package/docs/Std.Math/E.md +1 -1
  204. package/docs/Std.Math/ExpModI.md +1 -1
  205. package/docs/Std.Math/ExpModL.md +1 -1
  206. package/docs/Std.Math/ExtendedGreatestCommonDivisorI.md +1 -1
  207. package/docs/Std.Math/ExtendedGreatestCommonDivisorL.md +1 -1
  208. package/docs/Std.Math/FactorialI.md +1 -1
  209. package/docs/Std.Math/FactorialL.md +1 -1
  210. package/docs/Std.Math/Floor.md +1 -1
  211. package/docs/Std.Math/GreatestCommonDivisorI.md +1 -1
  212. package/docs/Std.Math/GreatestCommonDivisorL.md +1 -1
  213. package/docs/Std.Math/HammingWeightI.md +1 -1
  214. package/docs/Std.Math/InverseModI.md +1 -1
  215. package/docs/Std.Math/InverseModL.md +1 -1
  216. package/docs/Std.Math/IsCoprimeI.md +1 -1
  217. package/docs/Std.Math/IsCoprimeL.md +1 -1
  218. package/docs/Std.Math/IsInfinite.md +1 -1
  219. package/docs/Std.Math/IsNaN.md +1 -1
  220. package/docs/Std.Math/LargestFixedPoint.md +1 -1
  221. package/docs/Std.Math/Lg.md +1 -1
  222. package/docs/Std.Math/Log.md +1 -1
  223. package/docs/Std.Math/Log10.md +1 -1
  224. package/docs/Std.Math/LogFactorialD.md +1 -1
  225. package/docs/Std.Math/LogGammaD.md +1 -1
  226. package/docs/Std.Math/LogOf2.md +1 -1
  227. package/docs/Std.Math/Max.md +1 -1
  228. package/docs/Std.Math/MaxD.md +1 -1
  229. package/docs/Std.Math/MaxI.md +1 -1
  230. package/docs/Std.Math/MaxL.md +1 -1
  231. package/docs/Std.Math/Min.md +1 -1
  232. package/docs/Std.Math/MinD.md +1 -1
  233. package/docs/Std.Math/MinI.md +1 -1
  234. package/docs/Std.Math/MinL.md +1 -1
  235. package/docs/Std.Math/MinusC.md +1 -1
  236. package/docs/Std.Math/MinusCP.md +1 -1
  237. package/docs/Std.Math/ModulusI.md +1 -1
  238. package/docs/Std.Math/ModulusL.md +1 -1
  239. package/docs/Std.Math/NegationC.md +1 -1
  240. package/docs/Std.Math/NegationCP.md +1 -1
  241. package/docs/Std.Math/PI.md +1 -1
  242. package/docs/Std.Math/PNorm.md +1 -1
  243. package/docs/Std.Math/PNormalized.md +1 -1
  244. package/docs/Std.Math/PlusC.md +1 -1
  245. package/docs/Std.Math/PlusCP.md +1 -1
  246. package/docs/Std.Math/PowC.md +1 -1
  247. package/docs/Std.Math/PowCP.md +1 -1
  248. package/docs/Std.Math/RealMod.md +1 -1
  249. package/docs/Std.Math/Round.md +8 -5
  250. package/docs/Std.Math/RoundHalfAwayFromZero.md +27 -0
  251. package/docs/Std.Math/SignD.md +1 -1
  252. package/docs/Std.Math/SignI.md +1 -1
  253. package/docs/Std.Math/SignL.md +1 -1
  254. package/docs/Std.Math/Sin.md +1 -1
  255. package/docs/Std.Math/Sinh.md +1 -1
  256. package/docs/Std.Math/SmallestFixedPoint.md +1 -1
  257. package/docs/Std.Math/Sqrt.md +1 -1
  258. package/docs/Std.Math/SquaredNorm.md +1 -1
  259. package/docs/Std.Math/Tan.md +1 -1
  260. package/docs/Std.Math/Tanh.md +1 -1
  261. package/docs/Std.Math/TimesC.md +1 -1
  262. package/docs/Std.Math/TimesCP.md +1 -1
  263. package/docs/Std.Math/TrailingZeroCountI.md +1 -1
  264. package/docs/Std.Math/TrailingZeroCountL.md +1 -1
  265. package/docs/Std.Math/Truncate.md +1 -1
  266. package/docs/Std.Math/index.md +3 -2
  267. package/docs/Std.Measurement/MResetEachZ.md +1 -1
  268. package/docs/Std.Measurement/MResetX.md +1 -1
  269. package/docs/Std.Measurement/MResetY.md +1 -1
  270. package/docs/Std.Measurement/MResetZ.md +1 -1
  271. package/docs/Std.Measurement/MeasureAllZ.md +1 -1
  272. package/docs/Std.Measurement/MeasureEachZ.md +1 -1
  273. package/docs/Std.Measurement/MeasureInteger.md +1 -1
  274. package/docs/Std.Measurement/index.md +1 -1
  275. package/docs/Std.Random/DrawRandomBool.md +1 -1
  276. package/docs/Std.Random/DrawRandomDouble.md +1 -1
  277. package/docs/Std.Random/DrawRandomInt.md +1 -1
  278. package/docs/Std.Random/index.md +1 -1
  279. package/docs/Std.Range/IsRangeEmpty.md +1 -1
  280. package/docs/Std.Range/RangeEnd.md +1 -1
  281. package/docs/Std.Range/RangeReverse.md +1 -1
  282. package/docs/Std.Range/RangeStart.md +1 -1
  283. package/docs/Std.Range/RangeStep.md +1 -1
  284. package/docs/Std.Range/index.md +1 -1
  285. package/docs/Std.ResourceEstimation/AccountForEstimates.md +1 -1
  286. package/docs/Std.ResourceEstimation/AuxQubitCount.md +1 -1
  287. package/docs/Std.ResourceEstimation/BeginEstimateCaching.md +1 -1
  288. package/docs/Std.ResourceEstimation/BeginRepeatEstimates.md +1 -1
  289. package/docs/Std.ResourceEstimation/CczCount.md +1 -1
  290. package/docs/Std.ResourceEstimation/EndEstimateCaching.md +1 -1
  291. package/docs/Std.ResourceEstimation/EndRepeatEstimates.md +1 -1
  292. package/docs/Std.ResourceEstimation/MeasurementCount.md +1 -1
  293. package/docs/Std.ResourceEstimation/PSSPCLayout.md +1 -1
  294. package/docs/Std.ResourceEstimation/RepeatEstimates.md +1 -1
  295. package/docs/Std.ResourceEstimation/RotationCount.md +1 -1
  296. package/docs/Std.ResourceEstimation/RotationDepth.md +1 -1
  297. package/docs/Std.ResourceEstimation/SingleVariant.md +1 -1
  298. package/docs/Std.ResourceEstimation/TCount.md +1 -1
  299. package/docs/Std.ResourceEstimation/index.md +1 -1
  300. package/docs/Std.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
  301. package/docs/Std.StatePreparation/PreparePureStateD.md +1 -1
  302. package/docs/Std.StatePreparation/PrepareUniformSuperposition.md +1 -1
  303. package/docs/Std.StatePreparation/index.md +1 -1
  304. package/docs/Std.TableLookup/Select.md +1 -1
  305. package/docs/Std.TableLookup/index.md +1 -1
  306. package/docs/index.md +1 -1
  307. package/docs/toc.yml +3 -0
  308. package/lib/node/qsc_wasm.cjs +2 -2
  309. package/lib/node/qsc_wasm.d.cts +3 -6
  310. package/lib/node/qsc_wasm_bg.wasm +0 -0
  311. package/lib/web/qsc_wasm.d.ts +3 -6
  312. package/lib/web/qsc_wasm.js +2 -2
  313. package/lib/web/qsc_wasm_bg.wasm +0 -0
  314. package/package.json +1 -1
  315. package/ux/circuit-vis/circuitManipulation.ts +31 -9
  316. package/ux/circuit-vis/contextMenu.ts +42 -18
  317. package/ux/circuit-vis/draggable.ts +3 -3
  318. package/ux/circuit-vis/events.ts +21 -6
  319. package/ux/circuit-vis/formatters/formatUtils.ts +3 -3
  320. package/ux/circuit-vis/formatters/gateFormatter.ts +106 -65
  321. package/ux/circuit-vis/formatters/inputFormatter.ts +9 -31
  322. package/ux/circuit-vis/formatters/registerFormatter.ts +4 -4
  323. package/ux/circuit-vis/{metadata.ts → gateRenderData.ts} +4 -4
  324. package/ux/circuit-vis/panel.ts +31 -32
  325. package/ux/circuit-vis/process.ts +114 -106
  326. package/ux/circuit-vis/register.ts +1 -1
  327. package/ux/circuit-vis/sqore.ts +14 -10
  328. package/ux/circuit-vis/utils.ts +56 -4
  329. package/ux/circuit.tsx +7 -1
  330. package/ux/qsharp-circuit.css +353 -334
@@ -9,26 +9,26 @@ import {
9
9
  groupBoxPadding,
10
10
  } from "./constants";
11
11
  import { ComponentGrid, Operation, ConditionalRender } from "./circuit";
12
- import { Metadata, GateType } from "./metadata";
12
+ import { GateRenderData, GateType } from "./gateRenderData";
13
13
  import { Register, RegisterMap } from "./register";
14
14
  import { getGateWidth } from "./utils";
15
15
 
16
16
  /**
17
- * Takes in a component grid and maps the operations to `metadata` objects which
17
+ * Takes in a component grid and maps the operations to `GateRenderData` objects which
18
18
  * contains information for formatting the corresponding SVG.
19
19
  *
20
20
  * @param componentGrid Grid of circuit components.
21
- * @param registers Mapping from qubit IDs to register metadata.
21
+ * @param registers Mapping from qubit IDs to register render data.
22
22
  *
23
- * @returns An object containing `metadataArray` (2D Array of Metadata objects) and
23
+ * @returns An object containing `renderDataArray` (2D Array of GateRenderData objects) and
24
24
  * `svgWidth` which is the width of the entire SVG.
25
25
  */
26
26
  const processOperations = (
27
27
  componentGrid: ComponentGrid,
28
28
  registers: RegisterMap,
29
- ): { metadataArray: Metadata[][]; svgWidth: number } => {
29
+ ): { renderDataArray: GateRenderData[][]; svgWidth: number } => {
30
30
  if (componentGrid.length === 0)
31
- return { metadataArray: [], svgWidth: startX };
31
+ return { renderDataArray: [], svgWidth: startX };
32
32
  const numColumns: number = componentGrid.length;
33
33
  const columnsWidths: number[] = new Array(numColumns).fill(minGateWidth);
34
34
 
@@ -36,68 +36,73 @@ const processOperations = (
36
36
  const classicalRegs: [number, Register][] =
37
37
  _getClassicalRegStart(componentGrid);
38
38
 
39
- // Map operation index to gate metadata for formatting later
40
- const opsMetadata: Metadata[][] = componentGrid.map((col, colIndex) =>
41
- col.components.map((op) => {
42
- const metadata: Metadata = _opToMetadata(op, registers);
43
-
44
- if (
45
- op != null &&
46
- [GateType.Unitary, GateType.Ket, GateType.ControlledUnitary].includes(
47
- metadata.type,
48
- )
49
- ) {
50
- // If gate is a unitary type, split targetsY into groups if there
51
- // is a classical register between them for rendering
52
-
53
- // Get y coordinates of classical registers in the same column as this operation
54
- const classicalRegY: number[] = classicalRegs
55
- .filter(([regCol]) => regCol <= colIndex)
56
- .map(([, reg]) => {
57
- if (reg.result == null)
58
- throw new Error("Could not find cId for classical register.");
59
- const { children } = registers[reg.qubit];
60
- if (children == null)
61
- throw new Error(
62
- `Failed to find classical registers for qubit ID ${reg.qubit}.`,
63
- );
64
- return children[reg.result].y;
65
- });
66
-
67
- let qubits: Register[];
68
- switch (op.kind) {
69
- case "unitary":
70
- qubits = op.targets;
71
- break;
72
- case "measurement":
73
- qubits = op.qubits;
74
- break;
75
- case "ket":
76
- qubits = op.targets;
77
- break;
78
- }
39
+ // Map operation index to gate render data for formatting later
40
+ const renderDataArray: GateRenderData[][] = componentGrid.map(
41
+ (col, colIndex) =>
42
+ col.components.map((op) => {
43
+ const renderData: GateRenderData = _opToRenderData(op, registers);
44
+
45
+ if (
46
+ op != null &&
47
+ [GateType.Unitary, GateType.Ket, GateType.ControlledUnitary].includes(
48
+ renderData.type,
49
+ )
50
+ ) {
51
+ // If gate is a unitary type, split targetsY into groups if there
52
+ // is a classical register between them for rendering
53
+
54
+ // Get y coordinates of classical registers in the same column as this operation
55
+ const classicalRegY: number[] = classicalRegs
56
+ .filter(([regCol]) => regCol <= colIndex)
57
+ .map(([, reg]) => {
58
+ if (reg.result == null)
59
+ throw new Error("Could not find cId for classical register.");
60
+ const { children } = registers[reg.qubit];
61
+ if (children == null)
62
+ throw new Error(
63
+ `Failed to find classical registers for qubit ID ${reg.qubit}.`,
64
+ );
65
+ return children[reg.result].y;
66
+ });
67
+
68
+ let qubits: Register[];
69
+ switch (op.kind) {
70
+ case "unitary":
71
+ qubits = op.targets;
72
+ break;
73
+ case "measurement":
74
+ qubits = op.qubits;
75
+ break;
76
+ case "ket":
77
+ qubits = op.targets;
78
+ break;
79
+ }
79
80
 
80
- metadata.targetsY = _splitTargetsY(qubits, classicalRegY, registers);
81
- }
81
+ renderData.targetsY = _splitTargetsY(
82
+ qubits,
83
+ classicalRegY,
84
+ registers,
85
+ );
86
+ }
82
87
 
83
- // Expand column size, if needed
84
- if (metadata.width > columnsWidths[colIndex]) {
85
- columnsWidths[colIndex] = metadata.width;
86
- }
88
+ // Expand column size, if needed
89
+ if (renderData.width > columnsWidths[colIndex]) {
90
+ columnsWidths[colIndex] = renderData.width;
91
+ }
87
92
 
88
- return metadata;
89
- }),
93
+ return renderData;
94
+ }),
90
95
  );
91
96
 
92
97
  // Filter out invalid gates
93
- const metadataArray: Metadata[][] = opsMetadata
98
+ const filteredArray: GateRenderData[][] = renderDataArray
94
99
  .map((col) => col.filter(({ type }) => type != GateType.Invalid))
95
100
  .filter((col) => col.length > 0);
96
101
 
97
102
  // Fill in x coord of each gate
98
- const endX: number = _fillMetadataX(metadataArray, columnsWidths);
103
+ const endX: number = _fillRenderDataX(filteredArray, columnsWidths);
99
104
 
100
- return { metadataArray, svgWidth: endX };
105
+ return { renderDataArray: filteredArray, svgWidth: endX };
101
106
  };
102
107
 
103
108
  /**
@@ -125,19 +130,19 @@ const _getClassicalRegStart = (
125
130
  };
126
131
 
127
132
  /**
128
- * Maps operation to metadata (e.g. gate type, position, dimensions, text)
133
+ * Maps operation to render data (e.g. gate type, position, dimensions, text)
129
134
  * required to render the image.
130
135
  *
131
- * @param op Operation to be mapped into metadata format.
136
+ * @param op Operation to be mapped into render data.
132
137
  * @param registers Array of registers.
133
138
  *
134
- * @returns Metadata representation of given operation.
139
+ * @returns GateRenderData representation of given operation.
135
140
  */
136
- const _opToMetadata = (
141
+ const _opToRenderData = (
137
142
  op: Operation | null,
138
143
  registers: RegisterMap,
139
- ): Metadata => {
140
- const metadata: Metadata = {
144
+ ): GateRenderData => {
145
+ const renderData: GateRenderData = {
141
146
  type: GateType.Invalid,
142
147
  x: 0,
143
148
  controlsY: [],
@@ -146,7 +151,7 @@ const _opToMetadata = (
146
151
  width: -1,
147
152
  };
148
153
 
149
- if (op == null) return metadata;
154
+ if (op == null) return renderData;
150
155
 
151
156
  let isAdjoint: boolean;
152
157
  let controls: Register[] | undefined;
@@ -179,8 +184,8 @@ const _opToMetadata = (
179
184
  } = op;
180
185
 
181
186
  // Set y coords
182
- metadata.controlsY = controls?.map((reg) => _getRegY(reg, registers)) || [];
183
- metadata.targetsY = targets.map((reg) => _getRegY(reg, registers));
187
+ renderData.controlsY = controls?.map((reg) => _getRegY(reg, registers)) || [];
188
+ renderData.targetsY = targets.map((reg) => _getRegY(reg, registers));
184
189
 
185
190
  if (isConditional) {
186
191
  // Classically-controlled operations
@@ -198,7 +203,7 @@ const _opToMetadata = (
198
203
  }))
199
204
  .filter((col) => col.components.length > 0);
200
205
  let childrenInstrs = processOperations(onZeroOps, registers);
201
- const zeroGates: Metadata[][] = childrenInstrs.metadataArray;
206
+ const zeroGates: GateRenderData[][] = childrenInstrs.renderDataArray;
202
207
  const zeroChildWidth: number = childrenInstrs.svgWidth;
203
208
 
204
209
  // Gates to display when classical bit is 1.
@@ -210,77 +215,80 @@ const _opToMetadata = (
210
215
  }))
211
216
  .filter((col) => col.components.length > 0);
212
217
  childrenInstrs = processOperations(onOneOps, registers);
213
- const oneGates: Metadata[][] = childrenInstrs.metadataArray;
218
+ const oneGates: GateRenderData[][] = childrenInstrs.renderDataArray;
214
219
  const oneChildWidth: number = childrenInstrs.svgWidth;
215
220
 
216
221
  // Subtract startX (left-side) and 2*gatePadding (right-side) from nested child gates width
217
222
  const width: number =
218
223
  Math.max(zeroChildWidth, oneChildWidth) - startX - gatePadding * 2;
219
224
 
220
- metadata.type = GateType.ClassicalControlled;
221
- metadata.children = [zeroGates, oneGates];
225
+ renderData.type = GateType.ClassicalControlled;
226
+ renderData.children = [zeroGates, oneGates];
222
227
  // Add additional width from control button and inner box padding for dashed box
223
- metadata.width = width + controlBtnOffset + groupBoxPadding * 2;
228
+ renderData.width = width + controlBtnOffset + groupBoxPadding * 2;
224
229
 
225
230
  // Set targets to first and last quantum registers so we can render the surrounding box
226
231
  // around all quantum registers.
227
232
  const qubitsY: number[] = Object.values(registers).map(({ y }) => y);
228
233
  if (qubitsY.length > 0)
229
- metadata.targetsY = [Math.min(...qubitsY), Math.max(...qubitsY)];
234
+ renderData.targetsY = [Math.min(...qubitsY), Math.max(...qubitsY)];
230
235
  } else if (
231
236
  conditionalRender == ConditionalRender.AsGroup &&
232
237
  (children?.length || 0) > 0
233
238
  ) {
234
239
  const childrenInstrs = processOperations(children!, registers);
235
- metadata.type = GateType.Group;
236
- metadata.children = childrenInstrs.metadataArray;
240
+ renderData.type = GateType.Group;
241
+ renderData.children = childrenInstrs.renderDataArray;
237
242
  // _zoomButton function in gateFormatter.ts relies on
238
243
  // 'expanded' attribute to render zoom button
239
- metadata.dataAttributes = { expanded: "true" };
244
+ renderData.dataAttributes = { expanded: "true" };
240
245
  // Subtract startX (left-side) and add inner box padding (minus nested gate padding) for dashed box
241
- metadata.width =
246
+ renderData.width =
242
247
  childrenInstrs.svgWidth - startX + (groupBoxPadding - gatePadding) * 2;
243
248
  } else if (op.kind === "measurement") {
244
- metadata.type = GateType.Measure;
249
+ renderData.type = GateType.Measure;
245
250
  } else if (op.kind === "ket") {
246
- metadata.type = GateType.Ket;
247
- metadata.label = gate;
251
+ renderData.type = GateType.Ket;
252
+ renderData.label = gate;
248
253
  } else if (gate === "SWAP") {
249
- metadata.type = GateType.Swap;
254
+ renderData.type = GateType.Swap;
250
255
  } else if (controls && controls.length > 0) {
251
- metadata.type = gate === "X" ? GateType.Cnot : GateType.ControlledUnitary;
252
- metadata.label = gate;
256
+ renderData.type = gate === "X" ? GateType.Cnot : GateType.ControlledUnitary;
257
+ renderData.label = gate;
253
258
  } else if (gate === "X") {
254
- metadata.type = GateType.X;
255
- metadata.label = gate;
259
+ renderData.type = GateType.X;
260
+ renderData.label = gate;
256
261
  } else {
257
262
  // Any other gate treated as a simple unitary gate
258
- metadata.type = GateType.Unitary;
259
- metadata.label = gate;
263
+ renderData.type = GateType.Unitary;
264
+ renderData.label = gate;
260
265
  }
261
266
 
262
267
  // If adjoint, add ' to the end of gate label
263
- if (isAdjoint && metadata.label.length > 0) metadata.label += "'";
268
+ if (isAdjoint && renderData.label.length > 0) renderData.label += "'";
264
269
 
265
270
  // If gate has extra arguments, display them
266
271
  // For now, we only display the first argument
267
- if (args !== undefined && args.length > 0) metadata.displayArgs = args[0];
272
+ if (args !== undefined && args.length > 0) renderData.displayArgs = args[0];
268
273
 
269
274
  // Set gate width
270
- metadata.width = getGateWidth(metadata);
275
+ renderData.width = getGateWidth(renderData);
271
276
 
272
277
  // Extend existing data attributes with user-provided data attributes
273
278
  if (dataAttributes != null)
274
- metadata.dataAttributes = { ...metadata.dataAttributes, ...dataAttributes };
279
+ renderData.dataAttributes = {
280
+ ...renderData.dataAttributes,
281
+ ...dataAttributes,
282
+ };
275
283
 
276
- return metadata;
284
+ return renderData;
277
285
  };
278
286
 
279
287
  /**
280
288
  * Compute the y coord of a given register.
281
289
  *
282
290
  * @param reg Register to compute y coord of.
283
- * @param registers Map of qubit IDs to RegisterMetadata.
291
+ * @param registers Map of qubit IDs to RegisterRenderData.
284
292
  *
285
293
  * @returns The y coord of give register.
286
294
  */
@@ -309,7 +317,7 @@ const _getRegY = (reg: Register, registers: RegisterMap): number => {
309
317
  *
310
318
  * @param targets Target qubit registers.
311
319
  * @param classicalRegY y coords of classical registers overlapping current column.
312
- * @param registers Mapping from register qubit IDs to register metadata.
320
+ * @param registers Mapping from register qubit IDs to register render data.
313
321
  *
314
322
  * @returns Groups of target qubit y coords.
315
323
  */
@@ -368,15 +376,15 @@ const _splitTargetsY = (
368
376
  };
369
377
 
370
378
  /**
371
- * Updates the x coord of each metadata in the given 2D array of metadata and returns rightmost x coord.
379
+ * Updates the x coord of each render data object in the given 2D array and returns rightmost x coord.
372
380
  *
373
- * @param opsMetadata 2D array of metadata.
381
+ * @param renderDataArray 2D array of render data.
374
382
  * @param columnWidths Array of column widths.
375
383
  *
376
384
  * @returns Rightmost x coord.
377
385
  */
378
- const _fillMetadataX = (
379
- opsMetadata: Metadata[][],
386
+ const _fillRenderDataX = (
387
+ renderDataArray: GateRenderData[][],
380
388
  columnWidths: number[],
381
389
  ): number => {
382
390
  let endX: number = startX;
@@ -387,29 +395,29 @@ const _fillMetadataX = (
387
395
  return x;
388
396
  });
389
397
 
390
- opsMetadata.forEach((col, colIndex) =>
391
- col.forEach((metadata) => {
398
+ renderDataArray.forEach((col, colIndex) =>
399
+ col.forEach((renderData) => {
392
400
  const x = colStartX[colIndex];
393
- switch (metadata.type) {
401
+ switch (renderData.type) {
394
402
  case GateType.ClassicalControlled:
395
403
  case GateType.Group:
396
404
  {
397
405
  // Subtract startX offset from nested gates and add offset and padding
398
406
  let offset: number = x - startX + groupBoxPadding;
399
- if (metadata.type === GateType.ClassicalControlled)
407
+ if (renderData.type === GateType.ClassicalControlled)
400
408
  offset += controlBtnOffset;
401
409
 
402
410
  // Offset each x coord in children gates
403
- _offsetChildrenX(metadata.children, offset);
411
+ _offsetChildrenX(renderData.children, offset);
404
412
 
405
413
  // We don't use the centre x coord because we only care about the rightmost x for
406
414
  // rendering the box around the group of nested gates
407
- metadata.x = x;
415
+ renderData.x = x;
408
416
  }
409
417
  break;
410
418
 
411
419
  default:
412
- metadata.x = x + columnWidths[colIndex] / 2;
420
+ renderData.x = x + columnWidths[colIndex] / 2;
413
421
  break;
414
422
  }
415
423
  }),
@@ -421,11 +429,11 @@ const _fillMetadataX = (
421
429
  /**
422
430
  * Offset x coords of nested children operations.
423
431
  *
424
- * @param children 2D or 3D array of children metadata.
432
+ * @param children 2D or 3D array of children GateRenderData.
425
433
  * @param offset x coord offset.
426
434
  */
427
435
  const _offsetChildrenX = (
428
- children: Metadata[][] | Metadata[][][] | undefined,
436
+ children: GateRenderData[][] | GateRenderData[][][] | undefined,
429
437
  offset: number,
430
438
  ): void => {
431
439
  if (children == null) return;
@@ -5,5 +5,5 @@ export {
5
5
  RegisterType,
6
6
  type Register,
7
7
  type RegisterMap,
8
- type RegisterMetadata,
8
+ type RegisterRenderData,
9
9
  } from "../../src/shared/register";
@@ -13,7 +13,7 @@ import {
13
13
  Operation,
14
14
  Column,
15
15
  } from "./circuit";
16
- import { Metadata, GateType } from "./metadata";
16
+ import { GateRenderData, GateType } from "./gateRenderData";
17
17
  import { createUUID } from "./utils";
18
18
  import { gateHeight, minGateWidth, minToolboxHeight, svgNS } from "./constants";
19
19
  import { createDragzones } from "./draggable";
@@ -21,7 +21,7 @@ import { enableEvents } from "./events";
21
21
  import { createPanel } from "./panel";
22
22
 
23
23
  /**
24
- * Contains metadata for visualization.
24
+ * Contains render data for visualization.
25
25
  */
26
26
  interface ComposedSqore {
27
27
  /** Width of visualization. */
@@ -171,10 +171,13 @@ export class Sqore {
171
171
  *
172
172
  * @param circuit Circuit to be visualized.
173
173
  *
174
- * @returns `ComposedSqore` object containing metadata for visualization.
174
+ * @returns `ComposedSqore` object containing render data for visualization.
175
175
  */
176
176
  private compose(circuit: Circuit): ComposedSqore {
177
- const add = (acc: Metadata[], gate: Metadata | Metadata[]): void => {
177
+ const add = (
178
+ acc: GateRenderData[],
179
+ gate: GateRenderData | GateRenderData[],
180
+ ): void => {
178
181
  if (Array.isArray(gate)) {
179
182
  gate.forEach((g) => add(acc, g));
180
183
  } else {
@@ -183,20 +186,20 @@ export class Sqore {
183
186
  }
184
187
  };
185
188
 
186
- const flatten = (metadata: Metadata[][]): Metadata[] => {
187
- const result: Metadata[] = [];
188
- metadata.forEach((col) => col.forEach((g) => add(result, g)));
189
+ const flatten = (renderData: GateRenderData[][]): GateRenderData[] => {
190
+ const result: GateRenderData[] = [];
191
+ renderData.forEach((col) => col.forEach((g) => add(result, g)));
189
192
  return result;
190
193
  };
191
194
 
192
195
  const { qubits, componentGrid } = circuit;
193
196
  const { qubitWires, registers, svgHeight } = formatInputs(qubits);
194
- const { metadataArray, svgWidth } = processOperations(
197
+ const { renderDataArray, svgWidth } = processOperations(
195
198
  componentGrid,
196
199
  registers,
197
200
  );
198
- const formattedGates: SVGElement = formatGates(metadataArray);
199
- const measureGates: Metadata[] = flatten(metadataArray).filter(
201
+ const formattedGates: SVGElement = formatGates(renderDataArray);
202
+ const measureGates: GateRenderData[] = flatten(renderDataArray).filter(
200
203
  ({ type }) => type === GateType.Measure,
201
204
  );
202
205
  const formattedRegs: SVGElement = formatRegisters(
@@ -468,6 +471,7 @@ export class Sqore {
468
471
 
469
472
  // Minimize the circuits in a circuit group to remove dataAttributes
470
473
  minimizeCircuits(circuitGroup: CircuitGroup): CircuitGroup {
474
+ // Create a deep copy of the circuit group
471
475
  const minimizedCircuits: CircuitGroup = JSON.parse(
472
476
  JSON.stringify(circuitGroup),
473
477
  );
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
 
4
- import { Metadata, GateType } from "./metadata";
4
+ import { GateRenderData, GateType } from "./gateRenderData";
5
5
  import {
6
6
  minGateWidth,
7
7
  labelPadding,
@@ -11,6 +11,44 @@ import {
11
11
  import { ComponentGrid, Operation } from "./circuit";
12
12
  import { Register } from "./register";
13
13
 
14
+ /**
15
+ * Performs a deep equality check between two objects or arrays.
16
+ * @param obj1 - The first object or array to compare.
17
+ * @param obj2 - The second object or array to compare.
18
+ * @returns True if the objects are deeply equal, false otherwise.
19
+ */
20
+ export const deepEqual = (obj1: unknown, obj2: unknown): boolean => {
21
+ if (obj1 === obj2) return true;
22
+
23
+ if (
24
+ obj1 === null ||
25
+ obj2 === null ||
26
+ typeof obj1 !== "object" ||
27
+ typeof obj2 !== "object"
28
+ ) {
29
+ return false;
30
+ }
31
+
32
+ const keys1 = Object.keys(obj1);
33
+ const keys2 = Object.keys(obj2);
34
+
35
+ if (keys1.length !== keys2.length) return false;
36
+
37
+ for (const key of keys1) {
38
+ if (
39
+ !keys2.includes(key) ||
40
+ !deepEqual(
41
+ (obj1 as Record<string, unknown>)[key],
42
+ (obj2 as Record<string, unknown>)[key],
43
+ )
44
+ ) {
45
+ return false;
46
+ }
47
+ }
48
+
49
+ return true;
50
+ };
51
+
14
52
  /**
15
53
  * Generate a UUID using `Math.random`.
16
54
  * Note: this implementation came from https://stackoverflow.com/questions/105034/how-to-create-guid-uuid
@@ -26,9 +64,9 @@ const createUUID = (): string =>
26
64
  });
27
65
 
28
66
  /**
29
- * Calculate the width of a gate, given its metadata.
67
+ * Calculate the width of a gate, given its render data.
30
68
  *
31
- * @param metadata Metadata of a given gate.
69
+ * @param renderData - The rendering data of the gate, including its type, label, display arguments, and width.
32
70
  *
33
71
  * @returns Width of given gate (in pixels).
34
72
  */
@@ -37,7 +75,7 @@ const getGateWidth = ({
37
75
  label,
38
76
  displayArgs,
39
77
  width,
40
- }: Metadata): number => {
78
+ }: GateRenderData): number => {
41
79
  if (width > 0) return width;
42
80
 
43
81
  switch (type) {
@@ -327,6 +365,19 @@ const getGateElems = (container: HTMLElement): SVGGraphicsElement[] => {
327
365
  : [];
328
366
  };
329
367
 
368
+ // Non-ASCII chars are fraught with danger. Copy/paste these when possible.
369
+ // Use the following regex in VS Code to find invalid unicode chars
370
+ // [^\x20-\x7e\u{03b8}-\u{03c8}\u{2020}\u{27e8}\u{27e9}]
371
+
372
+ const mathChars = {
373
+ theta: "θ", // \u{03b8}
374
+ pi: "π", // \u{03c0}
375
+ psi: "ψ", // \u{03c8}
376
+ dagger: "†", // \u{2020}
377
+ langle: "⟨", // \u{27e8}
378
+ rangle: "⟩", // \u{27e9}
379
+ };
380
+
330
381
  export {
331
382
  createUUID,
332
383
  getGateWidth,
@@ -342,4 +393,5 @@ export {
342
393
  getToolboxElems,
343
394
  getHostElems,
344
395
  getGateElems,
396
+ mathChars,
345
397
  };
package/ux/circuit.tsx CHANGED
@@ -270,7 +270,13 @@ export function CircuitPanel(props: CircuitProps) {
270
270
  )}
271
271
  <p>
272
272
  Learn more at{" "}
273
- <a href="https://aka.ms/qdk.circuits">https://aka.ms/qdk.circuits</a>
273
+ {props.isEditable ? (
274
+ <a href="https://aka.ms/qdk.circuit-editor">
275
+ https://aka.ms/qdk.circuit-editor
276
+ </a>
277
+ ) : (
278
+ <a href="https://aka.ms/qdk.circuits">https://aka.ms/qdk.circuits</a>
279
+ )}
274
280
  </p>
275
281
  {props.calculating ? (
276
282
  <div>