Skip to content

Commit

Permalink
Translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed May 29, 2024
1 parent fff6dda commit 37f4663
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
13 changes: 10 additions & 3 deletions glue/crumble/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ button (now labelled "Hide Import/Export") again.
- `ctrl+c`: Copy selection to clipboard (or entire layer if nothing selected).
- `ctrl+v`: Past clipboard contents at current selection (or entire layer if nothing selected).
- `ctrl+x`: Cut selection to clipboard (or entire layer if nothing selected).
- `t`: Rotate circuit 45 degrees clockwise.
- `shift+t`: Rotate circuit 45 degrees counter-clockwise.
- `f`: Flip qubit order of selected operations (e.g. flip the control-to-target direction of a CNOT).
- `home`: Jump to the first layer of the circuit.
- `end`: Jump to the last layer of the circuit.
- `t`: Rotate circuit 45 degrees clockwise.
- `shift+t`: Rotate circuit 45 degrees counter-clockwise.
- `v`: Translate circuit down one step.
- `^`: Translate circuit up one step.
- `>`: Translate circuit right one step.
- `<`: Translate circuit left one step.
- `.`: Translate circuit down and right by a half step.

**Single Qubit Gates**

Expand All @@ -143,10 +149,11 @@ Note: use `shift` to get the inverse of a gate.
- `m+r+x`: Overwrite selection with `MRX` gate
- `m+r+y`: Overwrite selection with `MRY` gate
- `m+r`: Overwrite selection with `MR` gate
- `f`: Overwrite selection with `C_XYZ` gate
- `c+t`: Overwrite selection with `C_XYZ` gate
- `j+x`: Overwrite selection with **j**ust a Pauli `X` gate
- `j+y`: Overwrite selection with **j**ust a Pauli `Y` gate
- `j+z`: Overwrite selection with **j**ust a Pauli `Z` gate
- `shift+c+t`: Overwrite selection with `C_ZYX` gate

**Two Qubit Gates**

Expand Down
26 changes: 25 additions & 1 deletion glue/crumble/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@ function makeChordHandlers() {
res.set('m+p+x', preview => editorState.writeGateToFocus(preview, make_mpp_gate("X".repeat(editorState.focusedSet.size)), []));
res.set('m+p+y', preview => editorState.writeGateToFocus(preview, make_mpp_gate("Y".repeat(editorState.focusedSet.size)), []));
res.set('m+p+z', preview => editorState.writeGateToFocus(preview, make_mpp_gate("Z".repeat(editorState.focusedSet.size)), []));
res.set('f', preview => {
let newCircuit = editorState.copyOfCurCircuit();
let layer = newCircuit.layers[editorState.curLayer];
let flipped_op_first_targets = new Set();
for (let q of editorState.focusedSet.keys()) {
let op = layer.id_ops.get(newCircuit.coordToQubitMap().get(q));
if (op !== undefined && ['CX', 'XCZ', 'CY', 'XCY', 'YCX', 'YCZ', 'CXSWAP', 'SWAPCX'].indexOf(op.gate.name) !== -1) {
flipped_op_first_targets.add(op.id_targets[0]);
}
}
for (let q of flipped_op_first_targets) {
layer.id_ops.get(q).id_targets.reverse();
}
editorState.commit_or_preview(newCircuit, preview);
});
res.set('shift+>', preview => editorState.applyCoordinateTransform((x, y) => [x + 1, y], preview));
res.set('shift+<', preview => editorState.applyCoordinateTransform((x, y) => [x - 1, y], preview));
res.set('shift+v', preview => editorState.applyCoordinateTransform((x, y) => [x, y + 1], preview));
res.set('shift+^', preview => editorState.applyCoordinateTransform((x, y) => [x, y - 1], preview));
res.set('>', preview => editorState.applyCoordinateTransform((x, y) => [x + 1, y], preview));
res.set('<', preview => editorState.applyCoordinateTransform((x, y) => [x - 1, y], preview));
res.set('v', preview => editorState.applyCoordinateTransform((x, y) => [x, y + 1], preview));
res.set('^', preview => editorState.applyCoordinateTransform((x, y) => [x, y - 1], preview));
res.set('.', preview => editorState.applyCoordinateTransform((x, y) => [x + 0.5, y + 0.5], preview));

/**
* @param {!Array<!string>} chords
Expand Down Expand Up @@ -292,7 +316,7 @@ function makeChordHandlers() {
addGateChords(['c+w+z'], "CZSWAP", undefined);
addGateChords(['c+w'], "CZSWAP", undefined);

addGateChords(['f'], "C_XYZ", "C_ZYX");
addGateChords(['c+t'], "C_XYZ", "C_ZYX");
addGateChords(['c+s+x'], "SQRT_XX", "SQRT_XX_DAG");
addGateChords(['c+s+y'], "SQRT_YY", "SQRT_YY_DAG");
addGateChords(['c+s+z'], "SQRT_ZZ", "SQRT_ZZ_DAG");
Expand Down

0 comments on commit 37f4663

Please sign in to comment.