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,
<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>
<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)