repo stringclasses 885
values | file stringclasses 741
values | content stringlengths 4 215k |
|---|---|---|
https://github.com/mmetcalf14/Hamiltonian_Downfolding_IBM | mmetcalf14 | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.... |
https://github.com/CynthiaRios/quantum_orchestra | CynthiaRios | #pip install music21
#pip install RISE
from qiskit import QuantumCircuit, execute
from qiskit import Aer
from qiskit.visualization import plot_histogram
from qiskit import IBMQ
import qiskit.tools.jupyter
%qiskit_job_watcher
from IPython.display import Audio
import wave
import numpy as np
#start for the ... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/tula3and/random-question-generator | tula3and | from qiskit import *
# from qiskit import IBMQ
# IBMQ.save_account('<API Token>')
# provider = IBMQ.load_account()
# backend = IBMQ.get_provider(hub='ibm-q-kaist', group='internal', project='default').backends.ibmq_manhattan
backend = Aer.get_backend('qasm_simulator')
q = QuantumRegister(48)
c = ClassicalReg... |
https://github.com/qiskit-community/qiskit-dell-runtime | qiskit-community | from dell_runtime import DellRuntimeProvider
from qiskit import QuantumCircuit
import logging
import requests
import time
RUNTIME_PROGRAM = """
# This code is part of qiskit-runtime.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this... |
https://github.com/carstenblank/dc-qiskit-stochastics | carstenblank | # Copyright 2018-2022 Carsten Blank
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
https://github.com/bartubisgin/QSVTinQiskit-2021-Europe-Hackathon-Winning-Project- | bartubisgin | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
#... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAuckland
backend = FakeAuckland()
ghz = QuantumCircuit(15)
ghz.h(0)
ghz.cx(0, range(1, 15))
depths = []
for _ in range(100):
depths.append(
transpile(
ghz,
... |
https://github.com/mnp-club/Quantum_Computing_Workshop_2020 | mnp-club | from qiskit import *
from qiskit.compiler import *
from qiskit.tools.jupyter import *
from qiskit.visualization import *
import matplotlib.pyplot as plotter
import scipy
import numpy as np
from IPython.display import display, Math, Latex
import qiskit.quantum_info as qi
%matplotlib inline
# Loading your IBM Q... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/Qottmann/Quantum-anomaly-detection | Qottmann | from matplotlib import pyplot as plt
import numpy as np
import matplotlib.gridspec as gridspec
path = "data/BH_phase-diagrams-and-loss/data_rike/"
x = np.load(path + "x.npy")
y = np.load(path + "y.npy")
es = np.load(path + "es.npy")
dd = np.load(path + "dd.npy")
cost0 = np.load(path + "cost_bh_L12_trash2_d4... |
https://github.com/xtophe388/QISKIT | xtophe388 | from math import pi
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer, qx_color_scheme
# We recommend the following options for Jupter notebook
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
# Create... |
https://github.com/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | %run init.ipynb
from qiskit import *
nshots = 8192
IBMQ.load_account()
provider = IBMQ.get_provider(hub = 'ibm-q-research-2', group = 'federal-uni-sant-1', project = 'main')
simulator = Aer.get_backend('qasm_simulator')
device = provider.get_backend('ibm_nairobi')
from qiskit.tools.visualization import plot_hi... |
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources | aryashah2k | #
# A quantum circuit is composed by quantum and classical bits in Qiskit.
#
# here are the objects that we use to create a quantum circuit in qiskit
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
# we use a quantum register to keep our quantum bits.
q = QuantumRegister(1,"qreg") # in... |
https://github.com/swe-train/qiskit__qiskit | swe-train | import sys
import os
current_dir = os.getcwd()
sys.path.append(current_dir)
from quantum_circuit import QuantumCircuit
# import qiskit.providers.fake_provider
from qiskit.transpiler import CouplingMap
import qiskit_ibm_runtime.fake_provider
from Backend.backend import Backend
class FakeBackend(Backend):
... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
#... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, execute
from qiskit.visualization import plot_error_map
from qiskit.providers.fake_provider import FakeVigoV2
backend = FakeVigoV2()
plot_error_map(backend) |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/jaykomarraju/Quantum-Optimization-for-Solar-Farm | jaykomarraju | import numpy as np
import networkx as nx
from qiskit import Aer
from qiskit.algorithms import QAOA, NumPyMinimumEigensolver
from qiskit.algorithms.optimizers import COBYLA
from qiskit.utils import QuantumInstance
from qiskit_optimization import QuadraticProgram
from qiskit_optimization.algorithms import MinimumE... |
https://github.com/VedDharkar/IBM_QISKIT_EXAM_C1000-112 | VedDharkar | import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
from qiskit import *
# Loading your IBM Q account(s)
#provider = IBMQ.load_account()
q = Qua... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/ElePT/qiskit-algorithms-test | ElePT | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/TheGupta2012/QPE-Algorithms | TheGupta2012 | from qiskit import QuantumCircuit
from qiskit import execute, Aer
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display
from qiskit.tools.monitor import job_monitor
from qiskit.extensions import UnitaryGate
from qiskit.circuit import Gate
class IQPE:
"""Implements the i... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.transpiler.passes import RemoveBarriers
circuit = QuantumCircuit(1)
circuit.x(0)
circuit.barrier()
circuit.h(0)
circuit = RemoveBarriers()(circuit)
circuit.draw('mpl') |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
#... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit_nature.mappers.second_quantization import LogarithmicMapper
mapper = LogarithmicMapper(2)
from qiskit_nature.second_q.mappers import LogarithmicMapper
mapper = LogarithmicMapper(2)
from qiskit_nature.second_q.mappers import LogarithmicMapper
mapper = LogarithmicMapper(padding=2)
from qiski... |
https://github.com/xtophe388/QISKIT | xtophe388 | import sys, getpass
try:
sys.path.append("../../") # go to parent dir
import Qconfig
qx_config = {
"APItoken": Qconfig.APItoken,
"url": Qconfig.config['url']}
print('Qconfig loaded from %s.' % Qconfig.__file__)
except:
APItoken = getpass.getpass('Please input your token and ... |
https://github.com/peiyong-addwater/Hackathon-QNLP | peiyong-addwater | import collections
import pickle
import warnings
warnings.filterwarnings("ignore")
import os
from random import shuffle
import random
from discopy.tensor import Tensor
from discopy import Word
from discopy.rigid import Functor
from discopy import grammar
import seaborn as sns
import pandas as pd
import mat... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector
qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
# You can reverse the order of the qubits.
from qiskit.quantum_info import DensityMatrix
qc = QuantumCircuit(2)
qc.h([0, 1])
qc.t... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0,0)
qc.x(0).c_if(0, 0)
qc.draw(output='mpl')
from qiskit import QuantumRegister, ClassicalRegister
q = QuantumRegister(3, 'q')
c = ClassicalRegister(3, 'c')
qc = QuantumCircuit(q, c)
qc.h([0, 1, 2])
qc.barrier()
qc.measu... |
https://github.com/abhishekchak52/quantum-computing-course | abhishekchak52 | # %pip install numpy==1.19 qiskit==0.20 pylatexenc # Please uncomment this line if you are running on Google Colab
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, execute
from qiskit.providers.aer import QasmSimulator
... |
https://github.com/Z-928/Bugs4Q | Z-928 | from qiskit.circuit import Parameter
from qiskit import pulse
from qiskit.test.mock.backends.almaden import *
phase = Parameter('phase')
with pulse.build(FakeAlmaden()) as phase_test_sched:
pulse.shift_phase(phase, pulse.drive_channel(0))
phase_test_sched.instructions # ()
|
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | #Jupyter notebook to check if imports work correctly
%matplotlib inline
import sys
sys.path.append('./src')
import HubbardEvolutionChain as hc
import ClassicalHubbardEvolutionChain as chc
from qiskit import QuantumCircuit, execute, Aer, IBMQ, BasicAer, QuantumRegister, ClassicalRegister
from qiskit.compiler impo... |
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | #Jupyter notebook to check if imports work correctly
%matplotlib inline
import sys
sys.path.append('./src')
import HubbardEvolutionChain as hc
import ClassicalHubbardEvolutionChain as chc
import FullClassicalHubbardEvolutionChain as fhc
from qiskit import QuantumCircuit, execute, Aer, IBMQ, BasicAer, QuantumRegi... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
from qiskit import QuantumCircuit
from qiskit.providers.fake_provider import FakeVigoV2
backend = FakeVigoV2()
qc = QuantumCircuit(2, 1)
qc.h(0)
qc.x(1)
qc.cp(np.pi/4, 0, 1)
qc.h(0)
qc.measure([0], [0])
qc.draw(output='mpl') |
https://github.com/nahumsa/volta | nahumsa | # This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, an... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
from qiskit_nature.second_q.hamiltonians import QuadraticHamiltonian
# create Hamiltonian
hermitian_part = np.array(
[
[1.0, 2.0, 0.0, 0.0],
[2.0, 1.0, 2.0, 0.0],
[0.0, 2.0, 1.0, 2.0],
[0.0, 0.0, 2.0, 1.0],
]
)
antisymmetric_part = np.array(
[... |
https://github.com/hephaex/Quantum-Computing-Awesome-List | hephaex | from qiskit import *
from math import pi
import numpy as np
from qiskit.visualization import plot_bloch_multivector, plot_histogram
qc = QuantumCircuit(3)
for qubit in range(3):
qc.h(qubit)
qc.draw()
backend = Aer.get_backend('statevector_simulator')
final_state = execute(qc, backend).result().get_stat... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" val... |
https://github.com/JouziP/MQITE | JouziP | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 8 18:22:28 2022
Created on Thu Oct 13 10:29:00 2022
@author: pej
"""
import numpy as np
import pandas as pd
from qiskit import QuantumCircuit
from MultiQubitGate.functions import multiqubit
from BasicFunctions.f... |
https://github.com/AnshDabkara/Qiskit_Algorithm | AnshDabkara | # initialization
import numpy as np
# importing Qiskit
from qiskit import IBMQ, Aer
from qiskit import QuantumCircuit, transpile
# import basic plot tools
from qiskit.visualization import plot_histogram
# set the length of the n-bit input string.
n = 3
# Constant Oracle
const_oracle = QuantumCircui... |
https://github.com/arnavdas88/QuGlassyIsing | arnavdas88 | !pip install qiskit
from qiskit.providers.aer import QasmSimulator
from qiskit.providers.aer import AerSimulator
from qiskit.circuit.library import TwoLocal
from qiskit.algorithms import VQE
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import EfficientSU2
# opflow is Qiskit's ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | p = 0.2
import numpy as np
from qiskit.circuit import QuantumCircuit
class BernoulliA(QuantumCircuit):
"""A circuit representing the Bernoulli A operator."""
def __init__(self, probability):
super().__init__(1) # circuit on 1 qubit
theta_p = 2 * np.arcsin(np.sqrt(probability))
... |
https://github.com/Advanced-Research-Centre/QPULBA | Advanced-Research-Centre | import numpy as np
import random
from qiskit import QuantumCircuit, Aer, execute
from math import log2, ceil, pi, sin
#=====================================================================================================================
simulator = Aer.get_backend('statevector_simulator')
def disp_isv(circ,... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
# Choose the drawer you like best:
from qiskit.tools.visualization import matplotlib_circuit_drawer as draw
#from qiskit.tools.visualization import circuit_drawer as draw
from qiskit import IBMQ
IBMQ.load_accounts... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/nagarx/Quantum-KNN-Classifier-using-Qiskit | nagarx | # Classical computing modules
import numpy as np
import pandas as pd
import seaborn as sns
from statistics import mode
# Dataset
from sklearn import datasets, preprocessing
from sklearn.model_selection import train_test_split
# Quantum computing modules
from qiskit import QuantumCircuit, QuantumRegister, Clas... |
https://github.com/strangequarkkk/BB84-Protocol-for-QKD | strangequarkkk | import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit, Aer, transpile, assemble
from qiskit.visualization import plot_histogram, plot_bloch_multivector
qc = QuantumCircuit(1,1)
# Alice prepares qubit in state |+>
qc.h(0)
qc.barrier()
# Alice now sends t... |
https://github.com/abbarreto/qiskit3 | abbarreto | %run init.ipynb
def pf(t,r):
f = (1-r**t)/(1-r) - t
return f
from mpl_toolkits import mplot3d
def pf_3d(th,ph):
import matplotlib
matplotlib.rcParams.update({'font.size':12});
#plt.figure(figsize = (6,4,4), dpi = 100)
x = np.linspace(0, 1, 20)
y = np.linspace(0, 1, 20)
X... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile
ghz = QuantumCircuit(15)
ghz.h(0)
ghz.cx(0, range(1, 15))
ghz.draw(output='mpl') |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
top = QuantumCircuit(1)
top.x(0);
bottom = QuantumCircuit(2)
bottom.cry(0.2, 0, 1);
tensored = bottom.tensor(top)
tensored.draw('mpl') |
https://github.com/Axect/QuantumAlgorithms | Axect | # initialization
import numpy as np
# importing Qiskit
from qiskit import IBMQ, Aer
from qiskit import QuantumCircuit, transpile
# import basic plot tools
from qiskit.visualization import plot_histogram
# set the length of the n-bit input string.
n = 3
# Constant Oracle
const_oracle = QuantumCircui... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, execute
from qiskit.providers.fake_provider import FakeVigoV2
from qiskit.visualization import plot_gate_map
backend = FakeVigoV2()
plot_gate_map(backend) |
https://github.com/BOBO1997/osp_solutions | BOBO1997 | import numpy as np
import matplotlib.pyplot as plt
import itertools
from pprint import pprint
import pickle
import time
import datetime
# Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z)
from qiskit.opflow import Zero, One, I, X, Y, Z
from qiskit import QuantumCircuit, QuantumRegis... |
https://github.com/Zhaoyilunnn/qdao | Zhaoyilunnn | """
Generate the walk-through example circuit
Pleas run in qcs root directory
"""
import sys
sys.path.append(".")
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit
from qdao.engine import Engine
if __name__ == "__main__":
# circ_path = "qdao/benchmarks/qasm/random_8_5_max_operands_... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.utils import algorithm_globals
algorithm_globals.random_seed = 42
from qiskit.circuit import Parameter
from qiskit import QuantumCircuit
params1 = [Parameter("input1"), Parameter("weight1")]
qc1 = QuantumCircuit(1)
qc1.h(0)
qc1.ry(params1[0], 0)
qc1.rx(params1[1], 0)
qc1.draw("mpl")
from q... |
https://github.com/LeanderThiessen/antisymmetrization-circuit | LeanderThiessen | #General Imports
import numpy as np
import matplotlib.pyplot as plt
import time
from itertools import product,permutations
from string import ascii_lowercase as asc
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
#Qiskit Imports
from qiskit import QuantumCircuit, QuantumRegist... |
https://github.com/suvoooo/Qubits-Qiskit | suvoooo | # !pip3 install qiskit
import qiskit as q
import matplotlib.pyplot as plt
from qiskit import IBMQ
qr = q.QuantumRegister(2)
cr = q.ClassicalRegister(2)
circuit = q.QuantumCircuit(qr, cr)
circuit.draw()
circuit.h(qr[0]) # apply hadamard gate on first qubit.
circuit.h(qr[1]) # apply hadamard gate on se... |
https://github.com/Interlin-q/diskit | Interlin-q | import numpy as np
from numpy import pi
# importing Qiskit
from qiskit import QuantumCircuit, transpile, assemble, Aer
from qiskit.visualization import plot_histogram, plot_bloch_multivector
qc = QuantumCircuit(3)
qc.h(2)
qc.cp(pi/2, 1, 2)
qc.cp(pi/4, 0, 2)
qc.h(1)
qc.cp(pi/2, 0, 1)
qc.h(0)
qc.swap(0, 2)
... |
https://github.com/Qiskit/feedback | Qiskit | from qiskit.circuit import QuantumCircuit
from qiskit.visualization import dag_drawer
from qiskit.converters import circuit_to_dag
# Create basic Bell circuit
qc = QuantumCircuit(2, 1)
qc.x(1)
qc.h(0)
qc.cx(0, 1)
display(qc.draw('mpl', cregbundle=False))
print(qc._data)
# Convert circuit to dag and di... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | # let's start with a zero matrix
A = [
[0,0,0],
[0,0,0],
[0,0,0]
]
# we will randomly construct 3 columns
from random import randrange
for j in range(3): # each column is iteratively constructed
total = 100 # we will start with 100 and randomly distribute it into three parties
for i in r... |
https://github.com/victor-onofre/Quantum_Algorithms | victor-onofre | import qutip as qt # I use QuTip for the tensor and trace function
import numpy as np
H = qt.Qobj(np.matrix([[1.0 , 0.0 , 0.0 , 0.0 ]
,[0.0 , 0.0 ,-1.0 , 0.0 ]
,[0.0 ,-1.0 , 0.0 , 0.0 ]
,[0.0 , 0.0 , 0.0 , 1.0 ]]))
H
Id = qt.qeye(2... |
https://github.com/duartefrazao/Quantum-Finance-Algorithms | duartefrazao | from qiskit import Aer
from qiskit.circuit.library import TwoLocal
from qiskit.aqua import QuantumInstance
from qiskit.optimization.applications.ising.common import sample_most_likely
from qiskit.aqua.algorithms import VQE, QAOA, NumPyMinimumEigensolver
from qiskit.aqua.components.optimizers import COBYLA
from .a... |
https://github.com/acfilok96/Quantum-Computation | acfilok96 | from qiskit import *
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
circuit = QuantumCircuit(qr, cr)
%matplotlib inline
circuit.draw(output='mpl')
circuit.h(qr[0])
circuit.draw(output = 'mpl')
circuit.cx(qr[0], qr[1])
circuit.draw(output='mpl')
circuit.measure(qr, cr)
circuit.draw(ou... |
https://github.com/Pitt-JonesLab/mirror-gates | Pitt-JonesLab | from qiskit.circuit.library import SwapGate, iSwapGate
from qiskit import QuantumCircuit
from qiskit.quantum_info import random_unitary
from weylchamber import g1g2g3, c1c2c3, WeylChamber
from qiskit.quantum_info import Operator
import matplotlib.pyplot as plt
N = 500
# generate (a,b,c) ->swap-> (a',b',c') pai... |
https://github.com/minnukota381/Quantum-Computing-Qiskit | minnukota381 | from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram
# Creat a Quantum Circuit with Single Qubit
# With default Initial State as [1,0] or |0>
qc=QuantumCircuit(1)
#Declare the Initial State as [0,1] or |1>
initial_state=[0,1]
qc.initialize(initial... |
https://github.com/adlrocha/cryptoq | adlrocha | from qiskit import execute, QuantumCircuit, QuantumRegister, ClassicalRegister, Aer
from qiskit.quantum_info.operators import Operator
from qiskit.quantum_info import process_fidelity
from qiskit.providers.aer import QasmSimulator
from qiskit.providers.aer.noise import NoiseModel, errors
from qiskit.aqua.component... |
https://github.com/mathelatics/QGSS-2023-From-Theory-to-Implementations | mathelatics | from IPython.display import YouTubeVideo
YouTubeVideo('BYKc2RnQMqo', width=858, height=540)
!pip install qiskit --quiet
!pip install qiskit-aer --quiet
!pip install pylatexenc --quiet
# @markdown ### **1. Import `Qiskit` and essential packages** { display-mode: "form" }
from qiskit import QuantumCircuit, tran... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | def calculate_energy(J, σ):
return sum(J_ij*σ[i]*σ[i+1] for i, J_ij in enumerate(J))
J = [1.0, -1.0]
σ = [+1, -1, +1]
calculate_energy(J, σ)
import itertools
for σ in itertools.product(*[{+1,-1} for _ in range(3)]):
print(calculate_energy(J, σ), σ)
import dimod
J = {(0, 1): 1.0, (1, 2): -1.0}... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import pulse
from qiskit.providers.fake_provider import FakeArmonk
backend = FakeArmonk()
with pulse.build(backend) as drive_sched:
d0 = pulse.drive_channel(0)
a0 = pulse.acquire_channel(0)
pulse.play(pulse.library.Constant(10, 1.0), d0)
pulse.delay(20, d0)
pulse.shift_phas... |
https://github.com/QuantumVic/discrete-time-quantum-walks | QuantumVic | from qiskit import *
import numpy as np
import matplotlib as mpl
from qiskit.tools.visualization import plot_histogram, plot_state_city
state_sim = Aer.get_backend('statevector_simulator')
qasm_sim = Aer.get_backend('qasm_simulator')
qiskit.__qiskit_version__ #developed in q0.14.0, q-terra0.11.0
# Defini... |
https://github.com/xijia-tao/comp3316-a4-code | xijia-tao | import matplotlib.pyplot as plt
import numpy as np
import math
# importing Qiskit
from qiskit import Aer, transpile, assemble
from qiskit import QuantumCircuit
from qiskit.visualization import plot_histogram
qpe = QuantumCircuit(4, 3)
qpe.x(3)
qpe.draw()
for qubit in range(3):
qpe.h(qubit)
qpe.dra... |
https://github.com/Simultonian/hamilutor-qiskit | Simultonian | from typing import Callable
from qiskit import QuantumCircuit
from ..grouping.grouper import Grouper
from ..trotter.simple import trotter_from_terms
from ..utils import circuit_constructor, get_el
def generic(
grouper_class: Callable[[set[str]], Grouper],
orderer: Callable[[set[str]], list[str]... |
https://github.com/qclib/qclib | qclib | # Copyright 2021 qclib project.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in w... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/alejomonbar/Quantum-Supply-Chain-Manager | alejomonbar | %load_ext autoreload
%autoreload 2
# pip install pennylane
import pennylane as qml
from pennylane import numpy as np
from pennylane.optimize import NesterovMomentumOptimizer
import tensorflow as tf
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from IPyt... |
https://github.com/sathayen/qiskit-docker | sathayen | # Creating quantum circuits
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister
from qiskit import execute, Aer
from qiskit.tools.visualization import circuit_drawer, plot_histogram
qr = QuantumRegister(5)
cr = ClassicalRegister(5)
qc = QuantumCircuit(qr, cr)
qc.x(qr[0])
qc.cx(qr[0], qr... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | # Checking the version of PYTHON; we only support > 3.5
import sys
if sys.version_info < (3,5):
raise Exception('Please use Python version 3.5 or greater.')
#Importing qiskit and math lib
from qiskit import QuantumProgram
import math
#import Qconfig
pi = math.pi
theta_list = [0.01, 0.02, 0.03, 0.0... |
https://github.com/arian-code/nptel_quantum_assignments | arian-code | import numpy as np
# Import Qiskit
from qiskit import QuantumCircuit
from qiskit import Aer, transpile
from qiskit.tools.visualization import plot_histogram, plot_state_city
from qiskit import *
from qiskit.tools.monitor import job_monitor
import qiskit.quantum_info as qi
Aer.backends()
simulator = Aer.g... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | #
# OUR SOLUTION
#
# initial case
# We assume that the probability of getting head is 1 at the beginning,
# because Asja will start with one euro.
prob_head = 1
prob_tail = 0
#
# first coin-flip
#
# if the last result was head
new_prob_head_from_head = prob_head * 0.6
new_prob_tail_from_head = p... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Import packages that will be used
import c2qa
import numpy as np... |
https://github.com/derek-wang-ibm/coding-with-qiskit | derek-wang-ibm | from qiskit import QuantumCircuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.draw(output='mpl')
from qiskit.quantum_info import Pauli
ZZ = Pauli('ZZ')
ZI = Pauli('ZI')
IZ = Pauli('IZ')
XX = Pauli('XX')
XI = Pauli('XI')
IX = Pauli('IX')
observables = [ZZ, ZI, IZ, XX, XI, IX]
from qiskit_aer... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.circuit.random import random_circuit
circuit = random_circuit(2, 2, seed=0).decompose(reps=1)
display(circuit.draw("mpl"))
from qiskit.quantum_info import SparsePauliOp
observable = SparsePauliOp("XZ")
print(f">>> Observable: {observable.paulis}")
from qiskit.primitives import Estimator
est... |
https://github.com/zeynepCankara/Introduction-Quantum-Programming | zeynepCankara | # This is a comment
# A comment is used for explanations/descriptions/etc.
# Comments do not affect the programs
# let's define an integer variable named a
a = 5
# let's print its value
print(a)
# let's define three integer variables named a, b, and c
a = 2
b = 4
c = a + b # summation of a and b
# le... |
https://github.com/Heisenbug-s-Dog/qnn_visualization | Heisenbug-s-Dog |
from google.colab import drive
drive.mount('/content/drive')
!pip install torch==1.3.1
!pip install torchvision==0.4.2
!pip install Pillow==6.2.1
!pip install pennylane==0.7.0
# OpenMP: number of parallel threads.
%env OMP_NUM_THREADS=1
# Plotting
%matplotlib inline
import matplotl... |
https://github.com/LauraGentini/QRL | LauraGentini | """
Python script containing functions definitions for the Quantum Deep-Q Learning approach,
used in the DQN-analysis Jupyter Notebook.
Prepared for Qiskit Hackathon Europe by:
Stefano, Paolo, Jani & Laura, 2021.
"""
# General imports
import numpy as np
import matplotlib.pyplot as plt
# Qiskit Circ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.pulse_v2 import draw, IQXDebugging
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc = transpile(qc, FakeBoeblingen(), layout_method='trivial')
sched = schedu... |
https://github.com/PabloMartinezAngerosa/QAOA-uniform-convergence | PabloMartinezAngerosa | import qiskit
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict
from operator import itemgetter
from scipy.optimize import minimize
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
from qiskit.aqua.algorithms import Nu... |
https://github.com/jcylim/QiskitProject | jcylim | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, QISKitError
from qiskit import available_backends, execute, register, get_backend
from qiskit.tools.visualization import circuit_drawer
from qiskit.tools.qi.qi import state_fidelity
# Useful additional packages
import matplotlib.pyplot as plt... |
https://github.com/Z-928/Bugs4Q | Z-928 | from qiskit import Aer, QuantumCircuit, transpile
from qiskit.circuit.library import PhaseEstimation
qc= QuantumCircuit(3,3)
# dummy unitary circuit
unitary_circuit = QuantumCircuit(1)
unitary_circuit.h(0)
# QPE
qc.append(PhaseEstimation(2, unitary_circuit), list(range(3)))
qc.measure(list(range(3)), list(range... |
https://github.com/iamr0b0tx/qiskit_practice | iamr0b0tx | import numpy as np
# import qiskit libs
from qiskit import IBMQ, BasicAer
from qiskit.providers.ibmq import least_busy
from qiskit import QuantumCircuit, execute
from qiskit.tools.jupyter import *
API_KEY = 'c6f6569ab6b6f9ec1a437d4d1187b7c7ea2ac4bd91679613e204e7bb9728efd9639af14a86f840cbb05e60b6a249e532e3168c... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.dagcircuit import DAGCircuit
from qiskit.converters import circuit_to_dag
from qiskit.circuit.library.standard_gates import CHGate, U2Gate, CXGate
from qiskit.converters import dag_to_circuit
q = QuantumRegister(3, 'q')
c = Classi... |
https://github.com/kazawai/shor_qiskit | kazawai | from numpy import pi, random
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit_aer import AerSimulator
backend = AerSimulator()
def bell_state():
q = QuantumRegister(2)
c = ClassicalRegister(2)
circuit = QuantumCircuit(q, c)
circuit.h(q[0])
circuit.cx... |
https://github.com/nahumsa/volta | nahumsa | import sys
sys.path.append('../../')
# Python imports
import numpy as np
import matplotlib.pyplot as plt
# Qiskit
from qiskit import BasicAer, Aer
from qiskit.aqua import QuantumInstance
from qiskit.aqua.components.optimizers import COBYLA, SPSA
from qiskit.circuit.library import TwoLocal
# VOLTA
from ... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | %matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ, BasicAer, QuantumRegister, ClassicalRegister
from qiskit.compiler import transpile, assemble
from qiskit.quantum_info import Operator
from qiskit.tools.monitor import job_monitor
... |
https://github.com/Quantum-Ducks/QuBayes | Quantum-Ducks | from itertools import product
import numpy as np
from network_setup_temp import *
def generate_cond_keys(child, ps):
##############################################
#THIS FUNCTION WILL GENERATE A LIST OF STRINGS TO USE AS KEYS FOR CONDITIONAL PROBABILITIES
### INPUT ###
# s_0 int number of... |
https://github.com/unif2/Quantum-Computing-Mentorship-Task-4-Code | unif2 | import numpy as np
from numpy import kron
import qiskit as qk
def decomposition(H):
"""Decompose any 4x4 Hermitian matrix into a sum of tensor products of two Pauli matrices
"""
identity = np.array([[1, 0],[ 0, 1]], dtype=np.complex128)
x = np.array([[0, 1], [ 1, 0]], dtype=np.complex128)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.