]> foleosoft.com Git - QAnsel.git/commitdiff
Wed Aug 14 08:41:07 PM EDT 2024
authormiha-q <>
Thu, 15 Aug 2024 00:41:07 +0000 (20:41 -0400)
committermiha-q <>
Thu, 15 Aug 2024 00:41:07 +0000 (20:41 -0400)
src/bytecode.h
src/imports/welcome.png [new file with mode: 0644]
src/index.html
src/src.zip

index 71af0f28ad2d56470d93491c7162cae97490b865..50b0ee7bb443b4d82477cdaef26e9470f64616b2 100644 (file)
@@ -26,6 +26,24 @@ typedef struct
        int use_ifop;
 } QBytecode;
 
+/*
+       IMPORTANT NOTE
+
+       (AB)^T = (A^T)(B^T)
+       
+       In quantum mechanics, if the relative state is S, then evolving
+       the relative state by a logic gate A requires computing AS.
+
+       This is inefficient as S is a column vector and it is more
+       efficient in terms of caching to use a row vector. Hence, the
+       simulator does not store S but only S^T. To apply the logic
+       gate A, it is not AS that needs to be computed but instead
+       (S^T)(A^T).
+
+       This means all the logic gates stored below are represented
+       as their transposed equivalents.
+*/
+
 static float Identity[] = 
 {
     1, 0,    0, 0,
diff --git a/src/imports/welcome.png b/src/imports/welcome.png
new file mode 100644 (file)
index 0000000..85e112e
Binary files /dev/null and b/src/imports/welcome.png differ
index 17936d246fa09d9abdfc619cc064dfa897dda27b..24bba2b8576f971526a8bca7383539cb6096755d 100644 (file)
@@ -72,7 +72,7 @@
                <tr>
                        <td colspan="2">
                                <table style="width: 100%; text-align: center;" class="top-button-row">
-                                       <tr>
+                                       <tr oncontextmenu="return false;">
                                                <td onclick="menu('open');">๐Ÿ“‚</td>
                                                <td onclick="menu('clear');">๐Ÿงน</td>
                                                <td onclick="menu('save');">๐Ÿ’พ</td>
@@ -80,7 +80,7 @@
                                                <td onclick="menu('chart');">๐Ÿ“Š</td>
                                                <td style="color: green;" id="run">โ–ถ</td>
                                                <td onclick="menu('screenshot');">๐Ÿ“ท</td>
-                                               <td onclick="menu('sphere')">๐ŸŒ</td>
+                                               <td onmouseup="menu('sphere', event)">๐ŸŒ</td>
                                                <td>โ“</td>
                                                <td onclick="menu('settings');" style="color: lightgray">โš™</td>
                                        </tr>
                                        }
                                        
                                }
+                               if (ProgramTrack.STATE[0].length == 0)
+                               {
+                                       ret = "qreg q[" + (ProgramTrack.STATE.length - 1) + "];\n";
+                                       ret += "sample q;\n";
+                               }
                                return ret;
                        },
                        drag: (e, erase, evt, dodrag) =>
                $("#run")[0].addEventListener("click", () =>
                {
                        $("[onclick*=screenshot]")[0].style.pointerEvents = "none";
-                       if (ProgramTrack.STATE[0].length == 0)
+                       if (IstinaEditor.getText().trim().length == 0)
                        {
-                               errorModal("You must place at least one logic gate.");
+                               errorModal("There must be code in the code editor in order to execute the program.");
                                return;
                        }
                        createBlocker();
                        $(".modal__container")[0].style.backgroundColor = "";
                        $(".modal__footer")[0].style.display = "";
                }
-               function menu(cmd)
+               function menu(cmd, evt)
                {
                        resetDialog();
                        $(".program-instr")[0].style.display = "none";
                                        $(".modal__container")[0].style.height = sh + "px";
                                        $(".modal__container")[0].style.paddingBottom = "0px";
                                        $(".modal__container")[0].style.maxWidth = sw + "px";
-                                       $(".modal__container")[0].style.backgroundColor = window.blochPictureMode ? "" : "black";
+                                       var blochPictureMode = evt.button == 2;
+                                       $(".modal__container")[0].style.backgroundColor = blochPictureMode ? "" : "black";
                                        $(".modal__footer")[0].style.display = "none";
                                        $("#modal-main-title")[0].innerHTML = "Bloch Sphere Visualizer";
-                                       var h = "<iframe src='imports/bloch-sphere.html" + (window.blochPictureMode ? "?picturemode=true" : "") + "' style='border: 0; width: 100%; height: " + (sh - 130) + "px'></iframe>";
+                                       var h = "<iframe src='imports/bloch-sphere.html" + (blochPictureMode ? "?picturemode=true" : "") + "' style='border: 0; width: 100%; height: " + (sh - 130) + "px'></iframe>";
                                        $("#modal-main-content")[0].innerHTML = h;
                                        $("#modal-main-confirm")[0].style.display = "";
                                        $("#modal-main-cancel")[0].style.display = "none";
                }, 100);
                if (!ismobile)
                {
-                       window.onresize = function()
+                       window.doResize = function()
                        {
                                var resize =
                                {
                                };
                                localStorage.setItem("resize", JSON.stringify(resize));
                                window.location.reload();
+                       };
+                       window.isActive = true;
+                       window.queuedResize = false;
+                       window.onblur = function() { window.isActive = false; }
+                       window.onfocus = function() { window.isActive = true; if (window.queuedResize) window.doResize(); }
+                       window.onresize = function()
+                       {
+                               if (window.isActive)
+                               {
+                                       window.doResize();
+                               }
+                               else
+                               {
+                                       window.queuedResize = true;
+                               }
                        }
                        var resizeData = localStorage.getItem("resize");
                        if (resizeData != undefined && resizeData != null)
index e62a1c3864ddd3c5197683c29e44da11e9f4a33e..618ef9ddf54b02b6f858e6bda874ce7bb9246b92 100644 (file)
Binary files a/src/src.zip and b/src/src.zip differ