Skip to content

Instantly share code, notes, and snippets.

View nelimee's full-sized avatar

Adrien Suau nelimee

View GitHub Profile
@nelimee
nelimee / qiskit_gate_idea.py
Created March 30, 2018 08:02
An implementation idea for the Gate hierarchy of QISKit
# Base class for each gate
class Gate:
def __init__(self, name: str, qubits):
self._name = name
if isinstance(qubits, list):
self._qubits = qubits
else:
self._qubits = [qubits]
def qasm(self) -> str:
@nelimee
nelimee / 4x4.qasm
Created June 22, 2018 13:56
A quantum circuit that illustrate an issue in QISKit
// ======================================================================
// Copyright CERFACS (February 2018)
// Contributor: Adrien Suau (suau@cerfacs.fr)
//
// This software is governed by the CeCILL-B license under French law and
// abiding by the rules of distribution of free software. You can use,
// modify and/or redistribute the software under the terms of the
// CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
// URL "http://www.cecill.info".
//
@nelimee
nelimee / QISKit_issue_593.py
Created June 22, 2018 13:59
A script to illustrate the issue 593 of QISKit
# ======================================================================
# Copyright CERFACS (February 2018)
# Contributor: Adrien Suau (suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the
# CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
# URL "http://www.cecill.info".
#
// Quantum circuit to illustrate issue #1
// of https://github.com/nelimeee/qasm2error
OPENQASM 2.0;
include "qelib1.inc";
// A quantum gate that applies 10 times non-simplifiable
// gates to the given qubit
gate g10 q {
y q;
@nelimee
nelimee / measurement_error_validation.py
Created June 25, 2018 08:41
A quantum program to validate the provided errors with an experiment on the real backend.
import Qconfig
import qiskit
import numpy as np
qiskit.register(Qconfig.APItoken, Qconfig.config["url"])
ibmqx4 = qiskit.get_backend('ibmqx4')
qubit_number = ibmqx4.configuration['n_qubits']
shot_number = 8192
import numpy as np
import scipy.linalg as la
A = .25 * np.array([[15, 9, 5, -3],
[9, 15, 3, -5],
[5, 3, 15, -9],
[-3, -5, -9, 15]])
t0 = 2 * np.pi
Traceback (most recent call last):
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 652, in _run_async2
result = yield f
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
new_f = coroutine.send(None)
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 595, in _run_async
self._redraw()
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 444, in _redraw
self.renderer.render(self, self.layout)
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/renderer.py", line 590, in render
@nelimee
nelimee / crzz.py
Created January 10, 2019 14:21
Implementation of a controlled Rzz gate in qiskit<0.7
# ======================================================================
# Copyright CERFACS (November 2018)
# Contributor: Adrien Suau (suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the
# CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
# URL "http://www.cecill.info".
#
@nelimee
nelimee / crzz.py
Created January 10, 2019 14:22
Implementation of a controlled Rzz gate in qiskit<0.7
# ======================================================================
# Copyright CERFACS (November 2018)
# Contributor: Adrien Suau (suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the
# CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
# URL "http://www.cecill.info".
#
@nelimee
nelimee / two_qubit_kak_error.py
Created January 11, 2019 16:06
Matrix raising an exception in qiskit.mapper._compiling.two_qubit_kak
import numpy
from qiskit.mapper._compiling import two_qubit_kak
A = numpy.array([[15, 9, 5, -3], [9, 15, 3, -5], [5, 3, 15, -9], [-3, -5, -9, 15]], dtype=numpy.complex) / 4
two_qubit_kak(A)