Code Monkey home page Code Monkey logo

qasm's Introduction

qasm

PkgGoDev Go Report Card tests codecov

Install

go install github.com/itsubaki/qasm@latest

Example

$ cat testdata/bell.qasm
OPENQASM 3.0;
include "testdata/stdgates.qasm";

qubit[2] q;
reset q;

h q[0];
cx q[0], q[1];
$ qasm -f testdata/bell.qasm
[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000

REPL

$ qasm repl
>> OPENQASM 3.0;
>>
>> gate h q { U(pi/2.0, 0.0, pi) q; }
>> gate x q { U(pi, 0, pi) q; }
>> gate cx q, p { ctrl @ x q, p; }
>>
>> qubit[2] q;
[00][  0]( 1.0000 0.0000i): 1.0000
>> h q[0];
[00][  0]( 0.7071 0.0000i): 0.5000
[10][  2]( 0.7071 0.0000i): 0.5000
>> cx q[0], q[1];
[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000

built-in

  • U, X, Y, Z, H, S, T
  • QFT, IQFT, CMODEXP2
  • print

qasm's People

Contributors

itsubaki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qasm's Issues

ctrl @ gate is not implemented

gate specification is

gate cx a, b { ctrl @ x a, b; }
qubit[2] q;
qubit r;

x q;
cx q, r;

// for j ← 0, 1 do
//  cx q[j], r;

[11 0] -> [11 1] -> [11 0]

But, ctrl specification is

qubit[2] q;
qubit r;

x q;
ctrl(2) @ x q, r;

[11 0] -> [11 1]

So,

cx q, r; != ctrl(2) @ x q, r;

It's confusing.

`ctrl @ x q, p;` isn't working

OPENQASM 3.0;
gate x q { U(pi, 0, pi) q; }

qubit q;
qubit p;

x q;
ctrl @ x q, p;
[0 0][  0   0]( 1.0000 0.0000i): 1.0000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.