]> foleosoft.com Git - QAnsel.git/commitdiff
Sun Aug 4 10:01:12 PM EDT 2024
authormiha-q <>
Mon, 5 Aug 2024 02:01:12 +0000 (22:01 -0400)
committermiha-q <>
Mon, 5 Aug 2024 02:01:12 +0000 (22:01 -0400)
examples/deutsch_jozsa.txt [new file with mode: 0644]
examples/ghz.txt
src/index.html
src/src.zip

diff --git a/examples/deutsch_jozsa.txt b/examples/deutsch_jozsa.txt
new file mode 100644 (file)
index 0000000..4ef1564
--- /dev/null
@@ -0,0 +1,57 @@
+qreg q[2];
+creg c[4];
+//======================================
+//Four oracles enclosed in comments
+// They are constant zero, constant one, balanced same, and balanced inverted.
+// The actual logic of the function as input (x)(y) and output (x)(y xor f(x))
+//======================================
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+//<constant-zero>
+//</constant-zero>
+h q[0];
+h q[1];
+measure q[0] -> c[0];
+//======================================
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+//<constant-one>
+x q[1];
+//</constant-one>
+h q[0];
+h q[1];
+measure q[0] -> c[1];
+//======================================
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+//<balanced-same>
+cx q[0], q[1];
+//</balanced-same>
+h q[0];
+h q[1];
+measure q[0] -> c[2];
+//======================================
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+//<balanced-invert>
+x q[0];
+cx q[0], q[1];
+x q[0];
+//</balanced-invert>
+h q[0];
+h q[1];
+measure q[0] -> c[3];
+//======================================
+sample c;
index 7cc4b47fb33c0e293181ec5947011b0356166f95..b37fad8254bef3e2f251254d4d34db437ccfa8e7 100644 (file)
@@ -1,3 +1,40 @@
-qreg q[1];
-rx(1/3pi) q[0];
-sample q;
\ No newline at end of file
+qreg q[2];
+creg c[4];
+x q[1];
+h q[0];
+h q[1];
+swap q[0], q[1];
+cx q[0], q[1];
+h q[0];
+measure q[0] -> c[0];
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+swap q[1], q[0];
+x q[0];
+cx q[0], q[1];
+h q[0];
+measure q[0] -> c[1];
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+cx q[0], q[1];
+cx q[1], q[0];
+h q[0];
+measure q[0] -> c[2];
+reset q[0];
+reset q[1];
+x q[1];
+h q[0];
+h q[1];
+x q[0];
+cx q[0], q[1];
+x q[0];
+cx q[1], q[0];
+h q[0];
+measure q[0] -> c[3];
+sample c;
\ No newline at end of file
index b1cf8e5dd4c16c859300beed79f6bbc379dddd99..257c19a26993bf0f48df556b4a3def993f61f248 100644 (file)
                                                if (instr.includes("=1") || instr.includes("=0") || instr.includes("🔍"))
                                                {
                                                        var a = parseInt(ProgramTrack.STATE[s[0]][s[1]].split("<sub>")[1]) - 1;
-                                                       a = (a + 1) % (ProgramTrack.STATE.length - 1);
+                                                       a = (a + 1) % 14;
                                                        ProgramTrack.STATE[s[0]][s[1]] = instr + "<sub>" + (a + 1) + "</sub>";
                                                }
                                                ProgramTrack.draw();
                                if (str) {} else {str = ""};
                                if (str.includes(",") && (trackerElem.innerHTML == "..." || trackerElem.innerHTML == ""))
                                {
-                                       ProgramTrack.DRAGELEM = trackerElem;
+                                       $(".program-instr")[0].style.display = "";
+                                       var w = Math.floor($(".program-instr")[0].getBoundingClientRect().width);
                                        $(".program-instr")[0].style.display = "none";
+                                       ProgramTrack.DRAGELEM = trackerElem;
                                        $(".program-instr")[0].className = $(".program-instr")[0].className.replace("menu-hidden", "").trim();
                                        $(".program-instr")[0].className += " menu-reveal";
                                        $(".program-instr")[0].style.position = "fixed";
                                        $(".program-instr")[0].style.top = e.clientY + "px";
-                                       $(".program-instr")[0].style.left = e.clientX + "px";
+                                       console.log(window.innerWidth + ", " + e.clientX + ", " + w);
+                                       if (window.innerWidth - e.clientX > w) $(".program-instr")[0].style.left = e.clientX + "px";
+                                       else $(".program-instr")[0].style.left = (window.innerWidth - w) + "px";
                                        $(".program-instr")[0].style.animation = "animation-reveal 0.2s forwards";
                                        $(".program-instr")[0].style.display = "";
                                }
                                                $(".program-track")[0].cellSpacing,
                                                $(".istina-linecounter")[0].style.height,
                                                $(".istina-overlay")[0].style.height,
-                                               $(".istina-basis")[0].style.height
+                                               $(".istina-basis")[0].style.height,
+                                               $(".program-track-container")[0].style.width,
+                                               resultsChart.canvas.getAttribute("style")
                                        ];
                                        $(".program-track-container")[0].style.height = "100%";
+                                       $(".program-track-container")[0].style.width = "100%";
                                        document.body.style.backgroundColor = "rgba(0, 0, 0, 0)";
                                        $(".main-table tr")[0].style.display = "none";
                                        $("istina-editor div")[0].style.backgroundColor = "rgba(0, 0, 0, 0)";
                                                a.click();
                                                a.remove();
                                                $(".program-track-container")[0].style.height = backups[5];
+                                               $(".program-track-container")[0].style.width = backups[13];
                                                $(".main-table")[0].border = 1;
                                                document.body.style.backgroundColor = "";
                                                $(".main-table tr")[0].style.display = "";
                                                resultsChart.config.options.scales.y.ticks.color = backups[3];
                                                resultsChart.config.options.scales.x.ticks.color = backups[4];
                                                Chart.defaults.font.weight = null;
+                                               resultsChart.canvas.setAttribute("style", backups[14]);
                                                resultsChart.update();
                                                resultsChart.options.animation.duration = backups[2];
                                                for (var i = 0; i < $(".program-track td").length; i++)
index 9e9c6b02640433157bc30d8bbda538c805a06722..e8775f37089bd0427ea18072ee997eab04355e7a 100644 (file)
Binary files a/src/src.zip and b/src/src.zip differ