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
  -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
>> OPENQASM 3.0;
>> 
>> qubit[2] q;
[00] ( 1.0000 0.0000i): 1.0000
>> U(pi/2, 0, pi) q[0];
[00] ( 0.7071 0.0000i): 0.5000
[10] ( 0.7071 0.0000i): 0.5000
>> ctrl @ U(pi, 0, pi) q[0], q[1];
[00] ( 0.7071 0.0000i): 0.5000
[11] ( 0.7071 0.0000i): 0.5000
% qasm -repl
>> OPENQASM 3.0;
>> 
>> const float ratio = pi;
>> 
>> int n = 2;
>> if (n > 0) { n = n*ratio; }
>>
>> print;
const     : map[ratio:3.141592653589793]
variable  : map[n:6.283185307179586]
bit       : map[]
qubit     : map[]
gate      : []
subroutine: []

About

Quantum computing simulator for OpenQASM

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors