qasm

command module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

qasm

PkgGoDev tests

A quantum computing simulator for OpenQASM.

Installation

go install github.com/itsubaki/qasm@latest
% qasm -help
Usage of qasm:
  -f string
        filepath
  -lex
        Lex the input into a sequence of tokens
  -max-qubits int
        Maximum number of qubits (0 or less for unlimited)
  -parse
        Parse the input and convert it into an AST (abstract syntax tree)
  -repl
        REPL(read-eval-print loop) mode
  -svg
        Render the circuit as an SVG
  -theme string
        SVG theme (paper/cyber) (default "paper")
  -top int
        top results (default -1)
  -validate
        Validate the input without executing it
  -verbose
        Enable verbose output

Examples

% qasm < testdata/bell.qasm
[00] ( 0.7071 0.0000i): 0.5000
[11] ( 0.7071 0.0000i): 0.5000
% qasm -repl
qasm> OPENQASM 3.0;
qasm> 
qasm> qubit[2] q;
qasm> U(pi/2, 0, pi) q[0];
qasm> gphase(-pi/4);
qasm> 
qasm> ctrl @ U(pi, 0, pi) q[0], q[1];
qasm> ctrl @ gphase(-pi/2) q[0];
qasm> 
qasm> :print
--- STATE ---
[00] ( 0.7071 0.0000i): 0.5000
[11] ( 0.7071 0.0000i): 0.5000
--- ENVIRONMENT ---
const     : map[]
variable  : map[]
bit       : map[]
bit[]     : map[]
qubit     : map[]
qubit[]   : map[q:[0 1]]
gate      : []
subroutine: []
% qasm -repl
qasm> OPENQASM 3.0;
qasm> 
qasm> const float ratio = pi;
qasm> int n = 2;
qasm> if (n > 0) { n = n*ratio; }
qasm> 
qasm> :print
--- STATE ---
--- ENVIRONMENT ---
const     : map[ratio:3.141592653589793]
variable  : map[n:6.283185307179586]
bit       : map[]
bit[]     : map[]
qubit     : map[]
qubit[]   : map[]
gate      : []
subroutine: []
% qasm -svg --theme cyber < testdata/svg/shor15.qasm > testdata/svg/shor15.svg

circuit

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址