LaTeXStrings
Here we define methods which converts QuantumCircuit object into quantikz LaTeX source code. When you want Quantikz Picture directly, refer quantikz page.
Documents
GroverAlgorithm.controlled_gate_target — Method
controlled_gate_target(gate_type::Symbol) -> StringGiven a gate type symbol, return the appropriate LaTeX string for the target part of a controlled gate in a quantum circuit diagram.
- For
:X,:CNOT,:CX, it returns\targ{}. - For
:Z,:CZ, it returns\ctrl{0}. - For
:Y,:CY, it returns\gate{Y}. - For
:CPHASE,:Cphase, it returns\ctrl{0}. - For other gate types, it returns
\gate{<LaTeX representation of the gate>}using thegate_to_latexfunction.
GroverAlgorithm.format_param — Method
format_param(θ::Real) -> StringConvert a rotation angle θ (in radians) to a LaTeX-friendly string representation.
- If θ is a multiple of π, it returns a string like "π", "2π", "-π", etc.
- If θ is a rational multiple of π (e.g., π/2, π/4), it returns a string like "π/2", "π/4", etc.
- For other values, it returns a decimal representation rounded to 3 decimal places.
GroverAlgorithm.gate_to_latex — Method
gate_to_latex(gate_type::Symbol, params::AbstractVector{<:Real}) -> StringConvert a parameterized gate type symbol and its parameters to a LaTeX string representation for visualization in quantum circuit diagrams. Supported parameterized gate types include:
- Single-qubit rotation gates:
:Rx,:Ry,:Rz,:Rn - Controlled rotation gates:
:CRx,:CRy,:CRz,:CRn - Two-qubit rotation gates:
:Rxx,:Ryy,:Rzz - Phase gates:
:Phase,:P,:S
If the gate type is not recognized, it returns the string representation of the symbol along with its parameters in parentheses.
GroverAlgorithm.gate_to_latex — Method
gate_to_latex(gate_type::Symbol) -> StringConvert a gate type symbol to its corresponding LaTeX string representation for visualization in quantum circuit diagrams. Supported gate types include:
- Single-qubit gates:
:X,:Y,:Z,:H,:T,:S,:Phase,:P,:Proj0,:Proj1, etc. - Two-qubit gates:
:CNOT,:CY,:CZ,:CPHASE,:SWAP,:iSWAP, etc. - Three-qubit gates:
:Toffoli,:Fredkin, etc. - Four-qubit gates:
:CCCNOT, etc.
If the gate type is not recognized, it returns the string representation of the symbol itself.