Code Monkey home page Code Monkey logo

qua-c's Introduction

Qua-C

Qua-C (pronounced as /'kwɑ-si/) is a domain specific programming language for simulating Quantum Computing Algorithms.

Qua-C is a language under development to make the process of coding a Quantum Algorithm easy and in a visual syntax format.

Qua-C has a different ideology from conventional programming languages, which have a sequential syntax format to apply functions and gates to data. Instead of a sequential construct, Qua-C executes code column-wise manner for a set of qubits in the quregister.

The Qua-C Transpiler is developed completely in 'C' language currently.

Also see the 'Examples' folder to know more about the functionality. The 'Examples' folder contains various examples like:-

  1. Basic Example
  2. Grover search for 2 qubits
  3. Hadamard Gate mania
  4. Shor's period finding algorithm
  5. Grover Search for 5 qubits with custom gates

Quantum Registers

This feature allows the use to make registers consisting of multiple qubits at a time.

To make the coding of these gates easier, a functionality of short-hand gates is provided. The gates can be applied to the register as follows:-

### example.qc ###

gate MyOwnGate[2] {
	[H, H]
}

func test {
    [X, X] Pa()
	[Z, Y] Pa()
	[H, H] Pa()
	[X, Z] Pa()
	[Y, X] Pa()
	[MyOwnGate]
}

#### Initialize ####
quReg a = new quReg[2] => 'myqureg1'
a.setPrecision(6)

#### Simulate ####
a.Pnz()
a.test()
a.Pnz()

OUTPUT:

./quacc example.qc

[+] Parsing Successful...!!!

Executing program...
myqureg1 = 	
[0] =>	{1.000000 + 0.000000 i} |00>	100.000000 %


myqureg1 = 	
[0] =>	{0.000000 + 0.000000 i} |00>	0.000000 %
[1] =>	{0.000000 + 0.000000 i} |01>	0.000000 %
[2] =>	{0.000000 + 0.000000 i} |10>	0.000000 %
[3] =>	{1.000000 + 0.000000 i} |11>	100.000000 %


myqureg1 = 	
[0] =>	{0.000000 + 0.000000 i} |00>	0.000000 %
[1] =>	{-0.000000 + 1.000000 i} |01>	100.000000 %
[2] =>	{-0.000000 + 0.000000 i} |10>	0.000000 %
[3] =>	{0.000000 + 0.000000 i} |11>	0.000000 %


myqureg1 = 	
[0] =>	{0.000000 + 0.500000 i} |00>	25.000000 %
[1] =>	{0.000000 - 0.500000 i} |01>	25.000000 %
[2] =>	{0.000000 + 0.500000 i} |10>	25.000000 %
[3] =>	{0.000000 - 0.500000 i} |11>	25.000000 %


myqureg1 = 	
[0] =>	{0.000000 - 0.500000 i} |00>	25.000000 %
[1] =>	{0.000000 + 0.500000 i} |01>	25.000000 %
[2] =>	{-0.000000 + 0.500000 i} |10>	25.000000 %
[3] =>	{-0.000000 - 0.500000 i} |11>	25.000000 %


myqureg1 = 	
[0] =>	{-0.500000 + 0.000000 i} |00>	25.000000 %
[1] =>	{-0.500000 + 0.000000 i} |01>	25.000000 %
[2] =>	{0.500000 + 0.000000 i} |10>	25.000000 %
[3] =>	{0.500000 + 0.000000 i} |11>	25.000000 %


myqureg1 = 	
[2] =>	{-1.000000 + 0.000000 i} |10>	100.000000 %


Time taken: 0 min, 0.000124 sec

The above code segment has the following meaning:-

  • Initialize a new quRegister.
  • Display text for the quRegister is "quReg1".
  • Pnz() -> Print only non-zero magnitude values of the 2 qubit quRegister.
  • Pauli gate 'X' is applied to [qubit[0], qubit[1]] respectively.
  • Print all states in the quRegister.
  • Pauli gate 'Z' is applied to qubit[0] and 'Y' to qubit[1] respectively, and so on.
  • Pnz() -> Print only non-zero magnitude values.

List of short-hand gates

  • Hadamard Gate: H

  • Phase Gate: S

  • Rotation Gate: R(k)

      k: rotation angle (in degree)
    
  • Control gate: @

  • Inverse Control gate: o

  • Identity Gate: -

  • Pauli Gates

    • Pauli X gate: X
    • Pauli Y gate: Y
    • Pauli Z gate: Z
  • Swap Gate: x

  • Quantum Fourier Transform (QFT) Gate: ~

For more info, see the examples: https://github.com/AbeerVaishnav13/qua-C/tree/master/Examples

Currently, the language supports registers upto 29-qubits with 8GB of memory.

Installation Instructions

Dependncies

The dependencies for QuaC language is the gcc compiler and cmake.

(i) For Ubuntu/Linux platform

sudo apt-get install gcc cmake

(ii) For MacOS platform - With HomeBrew installed

sudo brew install gcc cmake

(iii) For Windows platform - install MINGW GCC for windows or even better, install any Linux distribution of your choice :)

Install the compiler

Go to the installations directory:-

cd /path/to/download/location/qua-C-master

Run the following command after installing all the dependencies

make

Run the basic example file

./quacc ./Examples/basic.qc

More stuff on the way... Enjoy! :)

Regards

Abeer Vaishnav

qua-c's People

Contributors

abeervaishnav13 avatar

Stargazers

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

Watchers

 avatar

qua-c's Issues

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.