_Circ2Tikz
The Circ2Tikz class takes a circuit (list of lists of CircuitItem objects) and turns them into Latex/TikZ code.
It uses the settings dictionary for gate offsets, sizes, spacing, ...
Constructor Summary
Public Constructor | ||
public |
constructor(settings: Object, num_lines: number) |
Member Summary
Public Members | ||
public |
is_quantum: * |
|
public |
op_count: * |
|
public |
pos: * |
|
public |
settings: * |
Method Summary
Public Methods | ||
public |
Generate the TikZ code for one line of the circuit up to a certain gate. |
Private Methods | ||
private |
Return the TikZ code for an n-controlled Z-gate. |
|
private |
_gate_height(gate: *): number Return the height to use for this gate. |
|
private |
_gate_name(gate: BasicGate): string Return the string representation of the gate. |
|
private |
_gate_offset(gate: *): number Return the offset to use after placing this gate and, if no pre_offset is defined, the same offset is used in front of the gate. |
|
private |
_gate_pre_offset(gate: *): number Return the offset to use before placing this gate. |
|
private |
_gate_width(gate: *): number Return the gate width, using the settings (if available). |
|
private |
Connects p1 and p2, where p1 and p2 are either to qubit line indices, in which case the two most recent gates are connected, or two gate indices, in which case line denotes the line number and the two gates are connected on the given line. |
|
private |
Returns the gate name for placing a gate on a line. |
|
private |
Places a phase / control circle on a qubit line at a given position. |
|
private |
_regular_gate(gate: BasicGate, lines: number[], ctrl_lines: number[]): string Draw a regular gate. |
|
private |
_sqrtswap_gate(lines: number[], ctrl_lines: number[], daggered: boolean): * Return the TikZ code for a Square-root Swap-gate. |
|
private |
_swap_gate(lines: number[], ctrl_lines: number[]): * Return the TikZ code for a Swap-gate. |
|
private |
Return the TikZ code for a NOT-gate. |
Public Constructors
Public Members
public is_quantum: * source
public op_count: * source
public pos: * source
public settings: * source
Public Methods
public to_tikz(line: number, circuit: Array<CircuitItem[]>, end: number): string source
Generate the TikZ code for one line of the circuit up to a certain gate.
It modifies the circuit to include only the gates which have not been drawn. It automatically switches to other lines if the gates on those lines have to be drawn earlier.
Params:
Name | Type | Attribute | Description |
line | number | Line to generate the TikZ code for. |
|
circuit | Array<CircuitItem[]> | The circuit to draw. |
|
end | number | Gate index to stop at (for recursion). |
Return:
string | TikZ code representing the current qubit line and, if it was necessary to draw other lines, those lines as well. |
Private Methods
private _cz_gate(lines: number[]): * source
Return the TikZ code for an n-controlled Z-gate.
Params:
Name | Type | Attribute | Description |
lines | number[] | List of all qubits involved. |
Return:
* |
private _gate_height(gate: *): number source
Return the height to use for this gate.
Params:
Name | Type | Attribute | Description |
gate | * |
private _gate_name(gate: BasicGate): string source
Return the string representation of the gate. Tries to use gate.tex_str and, if that is not available, uses str(gate) instead.
Params:
Name | Type | Attribute | Description |
gate | BasicGate | Gate object of which to get the name / latex representation. |
private _gate_offset(gate: *): number source
Return the offset to use after placing this gate and, if no pre_offset is defined, the same offset is used in front of the gate.
Params:
Name | Type | Attribute | Description |
gate | * |
private _gate_pre_offset(gate: *): number source
Return the offset to use before placing this gate.
Params:
Name | Type | Attribute | Description |
gate | * |
private _gate_width(gate: *): number source
Return the gate width, using the settings (if available).
Params:
Name | Type | Attribute | Description |
gate | * |
private _line(p1: number, p2: number, line: number): string source
Connects p1 and p2, where p1 and p2 are either to qubit line indices, in which case the two most recent gates are connected, or two gate indices, in which case line denotes the line number and the two gates are connected on the given line.
private _op(line: number, op: number, offset: number): string source
Returns the gate name for placing a gate on a line.
private _phase(line: number, pos: number): string source
Places a phase / control circle on a qubit line at a given position.
private _regular_gate(gate: BasicGate, lines: number[], ctrl_lines: number[]): string source
Draw a regular gate.
private _sqrtswap_gate(lines: number[], ctrl_lines: number[], daggered: boolean): * source
Return the TikZ code for a Square-root Swap-gate.
Return:
* |