Quantum emulator of the IBM Quantum experience
IBM research released a quantum computer accessable in the cloud. MiniQbt is a emulator for the IBM quantum experience, with a generic amount of qubits and classical bits. To contribute to MiniQbt please refer to contributing
The best way of installation is to compile the program from source. For this you need to install the following dependencies. Please consult the individual tools for help.
For the Python wrapper your need:
For the Java wrapper you need:
When done create a new build folder and let Cmake unpack everything there. MiniQbt comes with the following options:
Build Option | Effect |
---|---|
ENABLE_EMSCRIPTEN | Instead of compiling to native code, use Webassembly (Requires emc++ ) |
ENABLE_TESTS | Execute Unit tests |
ENABLE_JAVA | Build the Java wrapper |
ENABLE_PYTHON | Build the Python Wrapper |
# Clone the project.
git clone [email protected]:valvy/miniqubit.git
cd miniqubit
# Create a build directory.
mkdir build
cd build
# Build with only unit tests.
cmake .. -DENABLE_EMSCRIPTEN=OFF -DENABLE_TESTS=ON -DENABLE_JAVA=OFF -DENABLE_PYTHON=OFF
make
#include <miniqbt/MiniQbt.hpp>
#include <iostream>
#include <vector>
int main(int argc, char** argv){
using namespace MiniQbt;
const char* src =
"OPENQASM 2.0; \n"
"include \"qelib1.inc\"; \n"
"qreg q[1]; creg c[1]; \n"
"h q[0]; \n"
"measure q[0] -> c[0]; \n";
QasmAsyncInterpreter interpreter;
interpreter.interpret(std::string(src));
while(interpreter.hasErrors()){
std::cout << interpreter.getError() << "\n";
}
QuantumResult result = interpreter.readClassicResult("c");
std::cout << "result of the algorithm: " << result.dataToString();
std::cout << "\n";
}
from PyMiniQbt import QasmAsyncInterpreter
source = "OPENQASM 2.0; include \"qelib1.inc\"; qreg q[1]; creg c[1]; h q[0]; measure q[0] -> c[0];"
interpreter = QasmAsyncInterpreter()
interpreter.interpret(source)
result = interpreter.readClassicResult("c")
while interpreter.hasErrors():
print(interpreter.getError())
print("result of the algorithm: ")
print(result.dataToString())
"use strict";
const miniqbt = require('./MiniQbt')
// Make sure MiniQbt is properly loaded.
setTimeout(() => {
console.log("Using : " + miniqbt.NAME + " version "+ miniqbt.VERSION)
let vm = new miniqbt.QasmAsyncInterpreter()
vm.interpret("creg cregister[5]; qreg qregister[5];")
vm.interpret("h qregister;")
vm.interpret("measure qregister -> cregister;")
const result = vm.readClassicResult('cregister')
console.log(result.getName() + " resulted in " + result.dataToString() )
},1000)
import nl.hvanderheijden.miniqbt.Globals;
import nl.hvanderheijden.miniqbt.QasmAsyncInterpreter;
public class Main {
public static void main(String[] args) {
System.out.println(
String.format("%s version %s",
Globals.getName(),
Globals.getVersion()
)
);
QasmAsyncInterpreter interpreter = new QasmAsyncInterpreter();
interpreter.interpret("qreg a[5];");
interpreter.interpret("creg b[5];");
interpreter.interpret("h a;");
interpreter.interpret("measure a -> b;");
while(interpreter.hasErrors()) {
System.out.println(interpreter.getError());
}
for (String i : interpreter.getRegisters()) {
QuantumResult result = interpreter.readClassicResult(i);
System.out.println(result.dataToString());
}
}
}