Skip to content

itsubaki/qasm

Repository files navigation

qasm

PkgGoDev Go Report Card tests codecov

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
  -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
  -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> ctrl @ U(pi, 0, pi) q[0], q[1];
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[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> :print
--- STATE ---
--- ENVIRONMENT ---
const     : map[ratio:3.141592653589793]
variable  : map[n:6.283185307179586]
bit       : map[]
qubit     : map[]
gate      : []
subroutine: []
% qasm -svg < testdata/svg/shor15.qasm > testdata/svg/shor15.svg

circuit

About

Quantum computing simulator for OpenQASM

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors