repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from sklearn.datasets import load_iris iris_data = load_iris() print(iris_data.DESCR) features = iris_data.data labels = iris_data.target from sklearn.preprocessing import MinMaxScaler features = MinMaxScaler().fit_transform(features) import pandas as pd import seaborn as sns df = pd.DataFrame(ir...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # 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/orpgol/quantum_algorithms_qiskit
orpgol
import numpy as np from qiskit import BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, execute from qiskit.visualization import plot_histogram from qiskit import IBMQ, assemble, transpile from qiskit.tools.monitor import job_monitor import argparse, sys import time p...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # 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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile, schedule from qiskit.visualization.timeline import draw, IQXSimple from qiskit.providers.fake_provider import FakeBoeblingen qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial') draw(qc,...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 2 qubits # The default initial state of qubits will be |0> or [1,0] BS1 = QuantumCircuit(2) #Applying the CNOT gate BS1.h(0) BS1.cx(0,1) #Draw the circuit # q...
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)) ghz.draw(output='mpl')
https://github.com/maximusron/qgss_2021_labs
maximusron
# General tools import numpy as np import matplotlib.pyplot as plt # Qiskit Circuit Functions from qiskit import execute,QuantumCircuit, QuantumRegister, ClassicalRegister, Aer, transpile import qiskit.quantum_info as qi # Tomography functions from qiskit.ignis.verification.tomography import process_tomogra...
https://github.com/qBraid/qBraid
qBraid
# 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/NesyaLab/qaoa
NesyaLab
import warnings warnings.filterwarnings('ignore') import os os.chdir('..') from functions import maxcut_utilities import networkx from classes import Problems G = networkx.Graph() G.add_edges_from([[0,3],[0,4],[1,3],[1,4],[2,3],[2,4]]) instance = Problems.Problems(G=G) maxcut = maxcut_utilities.compu...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# -*- coding: utf-8 -*- # 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....
https://github.com/benkoehlL/Qiskit_Playground
benkoehlL
''' This program implements Shor's algorithm which determines a number's prime factors. [unfinished] ''' from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit,\ execute, IBMQ, Aer from qiskit.visualization import circuit_drawer as drawer from qiskit.tools.visualization impo...
https://github.com/TheGupta2012/QPE-Algorithms
TheGupta2012
from qiskit import QuantumCircuit, execute, transpile, Aer from qiskit.extensions import UnitaryGate, Initialize from qiskit.providers.ibmq.managed import IBMQJobManager import numpy as np from sys import stdout from scipy.stats import unitary_group class bundled_changed_SPEA: def __init__(self, unitary,...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import FakeVigoV2 from qiskit.visualization import plot_circuit_layout from qiskit.tools.monitor import job_monitor from qiskit.providers.fake_provider import FakeVigoV2 import matplotlib.pyplot as plt ghz = Qua...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.tools.visualization import circuit_drawer q = QuantumRegister(1) c = ClassicalRegister(1) qc = QuantumCircuit(q, c) qc.h(q) qc.measure(q, c) circuit_drawer(qc, output='mpl', style={'backgroundcolor': '#EEEEEE'})
https://github.com/sooodos/Quantum-Computing-Learning-Gate
sooodos
from qiskit import IBMQ from qiskit import ( QuantumCircuit, execute, Aer) class HelloWorld: @classmethod def run(cls): with open('./credentials/token', 'r') as file: token = file.read() IBMQ.save_account(token, overwrite=True) # Use Aer's qasm_simu...
https://github.com/ElePT/qiskit-algorithms-test
ElePT
# 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
from qiskit.visualization.timeline import draw as timeline_draw from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import FakeBoeblingen backend = FakeBoeblingen() ghz = QuantumCircuit(5) ghz.h(0) ghz.cx(0,range(1,5)) circ = transpile(ghz, backend, scheduling_method="asap") ...
https://github.com/anpaschool/QC-School-Fall2020
anpaschool
#initialization import matplotlib.pyplot as plt import numpy as np # importing Qiskit from qiskit import IBMQ, Aer, QuantumCircuit, ClassicalRegister, QuantumRegister, execute from qiskit.providers.ibmq import least_busy from qiskit.quantum_info import Statevector # import basic plot tools from qiskit.visua...
https://github.com/lmarza/QuantumDeskCalculator
lmarza
import math from qiskit import * from utils import bcolors, executeQFT, evolveQFTStateSum, inverseQFT pie = math.pi def multiply(a, secondDec, result, qc): n = len(a) -1 # Compute the Fourier transform of register 'result' for i in range(n+1): executeQFT(qc, result, n-i, pie) ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# useful additional packages import matplotlib.pyplot as plt import numpy as np import networkx as nx from qiskit_aer import Aer from qiskit.tools.visualization import plot_histogram from qiskit.circuit.library import TwoLocal from qiskit_optimization.applications import Maxcut, Tsp from qiskit.algorithms.min...
https://github.com/Qiskit-Extensions/qiskit-ibm-experiment
Qiskit-Extensions
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # 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/abhik-99/Qiskit-Summer-School
abhik-99
from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector excited = Statevector.from_int(1, 2) plot_bloch_multivector(excited.data) from qiskit.tools.jupyter import * from qiskit import IBMQ IBMQ.load_account() provider = IBMQ.get_provider(hub='ibm-q', group='open',...
https://github.com/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience
PacktPublishing
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created Nov 2020 @author: hassi """ # Import core IPython display method from IPython.core.display import display # The core Grover functions def create_oracle(oracle_type,size): from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegiste...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import transpile 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_basis = transpile(qc, backend) qc_basis.draw(output='mpl')
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit from qiskit import execute from qiskit import BasicAer import numpy as np np.set_printoptions(precision=3, suppress=True) backend = BasicAer.get_backend('qasm_simulator') q = QuantumRegister(1) c = ClassicalRegister(1) circuit = Qua...
https://github.com/MariosTsatsos/4qubitGrover
MariosTsatsos
#initialization import matplotlib.pyplot as plt %matplotlib inline %config InlineBackend.figure_format = 'svg' # Makes the images look nice import numpy as np # importing Qiskit from qiskit import IBMQ, BasicAer, Aer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, ClassicalRegi...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.quantum_info import SparsePauliOp H2_op = SparsePauliOp.from_list( [ ("II", -1.052373245772859), ("IZ", 0.39793742484318045), ("ZI", -0.39793742484318045), ("ZZ", -0.01128010425623538), ("XX", 0.18093119978423156), ] ) from qiskit.circuit.library...
https://github.com/qiskit-community/qiskit-dell-runtime
qiskit-community
# 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/Rodri-rf/playing_with_quantum_computing
Rodri-rf
from qiskit.synthesis import QDrift from qiskit.circuit.library import PauliEvolutionGate from qiskit import QuantumCircuit from qiskit.quantum_info import Pauli # Define the Hamiltonian XX = Pauli('XX') YY = Pauli('YY') ZZ = Pauli('ZZ') a = 1 b = -1 c = 1 # A simple Hamiltonian: a XX + b YY + c ZZ. Use ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.problems import BaseProblem dummy_hamiltonian = None base_problem = BaseProblem(dummy_hamiltonian) print(base_problem.properties) from qiskit_nature.second_q.properties import AngularMomentum print("AngularMomentum is in problem.properties:", AngularMomentum in base_problem.prop...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile, schedule from qiskit.visualization.timeline import draw, IQXDebugging from qiskit.providers.fake_provider import FakeBoeblingen qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial') draw(...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
#initialization import matplotlib.pyplot as plt %matplotlib inline import numpy as np import math # importing Qiskit from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute # import basic plot tools 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/farhad-abdi/InSilicoQ
farhad-abdi
""" A collection of quantum graph based algorithms, the algorthms are mostly based on Grover Serach algorithm""" from qiskit import QuantumCircuit class MST: """ Mininum Spanning Tree Implementation """ def __init__(self, num_qubit): self.num_q = num_qubit ...
https://github.com/JayantiSingh/Quant_co_Qiskit
JayantiSingh
# X-gate the quantum equivalent of the NOT gate /bit-flip gate q = QuantumRegister (1) qc = QuantumCircuit (q) qc.x(q[0]) qc.draw(output='mpl') # Z-gate /Phase-shift gate q = QuantumRegister (1) qc = QuantumCircuit (q) qc.z(q[0]) qc.draw(output='mpl') # H-gate a measurement will have equal probabilit...
https://github.com/tanmaybisen31/Quantum-Teleportation
tanmaybisen31
import numpy as np # Importing standard Qiskit libraries from qiskit import QuantumCircuit,execute, transpile, Aer, IBMQ from qiskit.tools.jupyter import * from qiskit.visualization import * from ibm_quantum_widgets import * from qiskit.providers.aer import QasmSimulator # Loading your IBM Quantum account(s)...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
import numpy as np import pylab from qiskit import LegacySimulators from qiskit_chemistry import QiskitChemistry import time # Input dictionary to configure Qiskit Chemistry for the chemistry problem. qiskit_chemistry_dict = { 'driver': {'name': 'PYSCF'}, 'PYSCF': {'atom': '', 'basis': 'sto3g'}, ...
https://github.com/acfilok96/Quantum-Computation
acfilok96
import qiskit from qiskit import * print(qiskit.__version__) %matplotlib inline from qiskit.tools.visualization import plot_histogram from ibm_quantum_widgets import draw_circuit circuit = QuantumCircuit(2,2) circuit circuit.draw(output='mpl') circuit.x(0) circuit.draw(output='mpl') circuit.h(0) ...
https://github.com/abbarreto/qiskit2
abbarreto
import numpy as np import matplotlib from matplotlib import pyplot as plt import math th = np.arange(0, 2*math.pi, 0.1) prE3 = 2*(1-(math.sqrt(2)*(np.sin(th/2)**2))/(1+math.sqrt(2))) matplotlib.rcParams.update({'font.size':10}) plt.figure(figsize = (5,3), dpi = 100) plt.plot(th, prE3) plt.xlabel(r'$\theta$')...
https://github.com/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
# Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * from ibm_quantum_widgets import * # useful to have pi import math pi=math.pi # Loading your IBM Q...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from scipy.stats import kruskal, f_oneway import pandas as pd import numpy as np #if p value less than alpha reject qiskit_data = np.concatenate((np.full(245, 0.75), np.full(264, 0.5), np.full(243, 0.25), np.full(248, 0))) cirq_data = np.concatenate((np.full(259, 0.75), np.full(234, 0.5), np.full(249, 0.25), n...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 16 K = 4 NUM_SHOTS = 1024 NUM_ITERATIONS = 50 w = 0.5 approximated_energies = [] from qiskit import Aer from qiskit.utils import QuantumInstance,...
https://github.com/quantum-tokyo/qiskit-handson
quantum-tokyo
# Qiskitライブラリーを導入 from qiskit import * # 描画のためのライブラリーを導入 import matplotlib.pyplot as plt %matplotlib inline qiskit.__qiskit_version__ grover11=QuantumCircuit(2,2) grover11.draw(output='mpl') # 問題-1 上の回路図を作ってください。 # 正解 grover11.h([0,1]) # ← これが(一番記述が短い正解) grover11.draw(output='mpl') # 問題-2 上の回路図(問題...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 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 deriva...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver, QAOA, SamplingVQE from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import TwoLocal from qiskit.result import QuasiDistribution from qiskit_aer.primitives import Sampler from qiskit_finance.applications.optimizati...
https://github.com/mcoggins96/Quantum-Computing-UK-Repository
mcoggins96
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, execute,IBMQ from qiskit.circuit.library import Permutation from qiskit.tools.monitor import job_monitor IBMQ.enable_account('ENTER API Key HERE') provider = IBMQ.get_provider(hub='ibm-q') backend = provider.get_backend('...
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/hamburgerguy/Quantum-Algorithm-Implementations
hamburgerguy
"""Qiskit code for running Simon's algorithm on quantum hardware for 2 qubits and b = '11' """ # importing Qiskit from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, execute # import basic plot tools from qiskit.visualization import plot_histogram ...
https://github.com/hkhetawat/QArithmetic
hkhetawat
""" This file allows to test the various QFT implemented. The user must specify: 1) The number of qubits it wants the QFT to be implemented on 2) The kind of QFT want to implement, among the options: -> Normal QFT with SWAP gates at the end -> Normal QFT without SWAP gates at the end ...
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/WhenTheyCry96/qiskitHackathon2022
WhenTheyCry96
import os import warnings warnings.filterwarnings('ignore') ws_path = os.getcwd() import numpy as np from scipy.constants import c, h, pi, hbar, e from qiskit_metal.analyses.em.cpw_calculations import guided_wavelength # constants: phi0 = h/(2*e) varphi0 = phi0/(2*pi) # project target parameters f...
https://github.com/PabloMartinezAngerosa/QAOA-uniform-convergence
PabloMartinezAngerosa
from tsp_qaoa import test_solution from qiskit.visualization import plot_histogram import networkx as nx import numpy as np job_2, G, UNIFORM_CONVERGENCE_SAMPLE = test_solution() plot_histogram(job_2.result().get_counts(), color='midnightblue', title="New Histogram", figsize=(30, 5)) plot_histogram(job...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# You can show the phase of each state and use # degrees instead of radians from qiskit.quantum_info import DensityMatrix import numpy as np from qiskit import QuantumCircuit from qiskit.visualization import plot_state_qsphere qc = QuantumCircuit(2) qc.h([0, 1]) qc.cz(0,1) qc.ry(np.pi/3, 0) qc.rx(np.pi/5,...
https://github.com/JavaFXpert/qiskit4devs-workshop-notebooks
JavaFXpert
# !pip install qiskit==0.7.1 # Include the necessary imports for this program import numpy as np from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute # Create a Quantum Register with 2 qubits qr = QuantumRegister(2) # Create a Classical Register with 2 bits cr = ClassicalRegister(2)...
https://github.com/qiskit-community/qiskit-cold-atom
qiskit-community
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # 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/mmetcalf14/Hamiltonian_Downfolding_IBM
mmetcalf14
# -*- coding: utf-8 -*- # 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....
https://github.com/usamisaori/qLipschitz
usamisaori
from sklearn.datasets import load_iris import pennylane as qml import numpy as np from pennylane.optimize import AdamOptimizer import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') X, Y = load_iris(return_X_y=True) X_train_0 = X[0:30] X_train_1 = X[50:80] X_train = np.vstack(...
https://github.com/QuSTaR/kaleidoscope
QuSTaR
# -*- coding: utf-8 -*- # This code is part of Kaleidoscope. # # (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....
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from math import pi # the angles of rotations theta1 = pi/4 theta2 = pi/6 # the circuit with two qubits qreg = QuantumRegister(2) creg = ClassicalRegister(2) mycircuit = QuantumCircuit(qreg,creg) # when the second qu...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator
GIRISHBELANI
min_qubits=2 max_qubits=8 max_circuits=1 num_shots=1000 backend_id="qasm_simulator" #backend_id="statevector_simulator" hub="ibm-q"; group="open"; project="main" provider_backend = None exec_options = {} # # ========================== # # *** If using IBMQ hardware, run this once to authenticate # from...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import FakeVigoV2 from qiskit.visualization import plot_circuit_layout from qiskit.tools.monitor import job_monitor from qiskit.providers.fake_provider import FakeVigoV2 import matplotlib.pyplot as plt ghz = Qua...
https://github.com/VicentePerezSoloviev/QAOA_BNSL_IBM
VicentePerezSoloviev
# all libraries used by some part of the VQLS-implementation from qiskit import ( QuantumCircuit, QuantumRegister, ClassicalRegister, Aer, execute, transpile, assemble ) from qiskit.circuit import Gate, Instruction from qiskit.quantum_info.operators import Operator from qiskit.extensions import ZGate...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit q = QuantumRegister(1) c = ClassicalRegister(1) qc = QuantumCircuit(q, c) qc.h(q) qc.measure(q, c) qc.draw(output='mpl', style={'backgroundcolor': '#EEEEEE'})
https://github.com/mathelatics/QGSS-2023-From-Theory-to-Implementations
mathelatics
from qiskit import * import numpy as np from numpy import linalg as la from qiskit.tools.monitor import job_monitor import qiskit.tools.jupyter qc = QuantumCircuit(1) #### your code goes here # z measurement of qubit 0 measure_z = QuantumCircuit(1,1) measure_z.measure(0,0) # x measurement of qubit 0 ...
https://github.com/electricalgorithm/DeutschJozsaAlgorithm
electricalgorithm
""" This module implements the Deutsch-Jozsa algorithm using Qiskit. """ import numpy as np from qiskit import Aer from qiskit import QuantumCircuit, assemble, transpile from qiskit.circuit.instruction import Instruction class DJAlgorithm: """This class implements the Deutsch-Jozsa algorithm.""" ...
https://github.com/JavaFXpert/qiskit4devs-workshop-notebooks
JavaFXpert
# Do the necessary import for our program #!pip install qiskit-aqua from qiskit import BasicAer from qiskit.aqua.algorithms import Grover from qiskit.aqua.components.oracles import LogicalExpressionOracle from qiskit.tools.visualization import plot_histogram log_expr = '((A & B) | (C & D)) & ~(A & D)' algorith...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from math import pi import numpy as np import rustworkx as rx from qiskit_nature.second_q.hamiltonians.lattices import ( BoundaryCondition, HyperCubicLattice, Lattice, LatticeDrawStyle, LineLattice, SquareLattice, TriangularLattice, ) from qiskit_nature.second_q.hamiltonians im...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # 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/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # 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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(3, 'q') anc = QuantumRegister(1, 'ancilla') cr = ClassicalRegister(3, 'c') qc = QuantumCircuit(qr, anc, cr) qc.x(anc[0]) qc.h(anc[0]) qc.h(qr[0:3]) qc.cx(qr[0:3], anc[0]) qc.h(qr[0:3]) qc.barrier(qr) qc.measure(qr,...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# 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/PabloMartinezAngerosa/QAOA-uniform-convergence
PabloMartinezAngerosa
from tsp_qaoa import test_solution from qiskit.visualization import plot_histogram import networkx as nx import numpy as np import json import csv # Array of JSON Objects header = ['instance','p','distance', 'mean'] length_p = 3 length_instances = 2 with open('qaoa_multiple_p_distance.csv', 'w', encodin...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.drivers import GaussianForcesDriver # if you ran Gaussian elsewhere and already have the output file driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log") # if you want to run the Gaussian job from Qiskit # driver = GaussianForcesDriver( # ['#p B...
https://github.com/Qiskit/feedback
Qiskit
# a T1 circuit from qiskit.circuit import QuantumCircuit qc = QuantumCircuit(1, 1) qc.x(0) qc.delay(10, 0, unit="us") qc.measure(0, 0) qc.draw(output="mpl") from qiskit import IBMQ IBMQ.load_account() provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main') device_backend = provider.get_backe...
https://github.com/quantum-tokyo/qiskit-handson
quantum-tokyo
# Qiskitライブラリーを導入 from qiskit import * # 描画のためのライブラリーを導入 import matplotlib.pyplot as plt %matplotlib inline # Qiskitバージョンの確認 qiskit.__qiskit_version__ # 2量子ビット回路を用意 q1 = QuantumCircuit(2) # 回路を描画 q1.draw(output="mpl") # q0=0, q1=1の場合 q1.x(1) # q1を1にします。 q1.cx(0,1) # CNOTゲートの制御ゲートをq0、目標ゲー...
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/KathrinKoenig/QuantumTopologicalDataAnalysis
KathrinKoenig
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 24 11:04:02 2021 @author: Eric Brunner, Kathrin König, Andreas Woitzik """ import itertools as it import numpy as np import gudhi as gd from scipy.sparse import csr_matrix from scipy.linalg import expm from qiskit import QuantumCircuit...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_optimization import QuadraticProgram from qiskit_optimization.translators import from_docplex_mp # Make a Docplex model from docplex.mp.model import Model mdl = Model("docplex model") x = mdl.binary_var("x") y = mdl.integer_var(lb=-1, ub=5, name="y") mdl.minimize(x + 2 * y) mdl.add_constraint(x ...
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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator
GIRISHBELANI
min_qubits=2 max_qubits=8 skip_qubits=1 max_circuits=3 num_shots=1000 backend_id="dm_simulator" #backend_id="statevector_simulator" #hub="ibm-q"; group="open"; project="main" provider_backend = None exec_options = {} # # ========================== # # *** If using IBMQ hardware, run this once to a...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse dc = pulse.DriveChannel d0, d1, d2, d3, d4 = dc(0), dc(1), dc(2), dc(3), dc(4) with pulse.build(name='pulse_programming_in') as pulse_prog: pulse.play([1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1], d0) pulse.play([1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0...
https://github.com/usamisaori/quantum-expressibility-entangling-capability
usamisaori
import numpy as np from qiskit.quantum_info import state_fidelity, Statevector def getStatevector(circuit): return Statevector(circuit).data import warnings warnings.filterwarnings('ignore') def P_haar(N, F): if F == 1: return 0 else: return (N - 1) * ((1 - F) ** (N - 2)) ...
https://github.com/anpaschool/quantum-computing
anpaschool
# Useful additional packages import matplotlib.pyplot as plt %matplotlib inline import numpy as np from math import pi from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute from qiskit import Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.visualization import * ...
https://github.com/PabloMartinezAngerosa/QAOA-uniform-convergence
PabloMartinezAngerosa
import numpy as np import networkx as nx import qiskit from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, assemble from qiskit.quantum_info import Statevector from qiskit.aqua.algorithms import NumPyEigensolver from qiskit.quantum_info import Pauli from qiskit.aqua.operators...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
%matplotlib inline import matplotlib.pyplot as plt from qiskit import QuantumCircuit, execute, Aer from qiskit.circuit.random import random_circuit n_circs = 10000 n_qubits = 4 n_layers = 30 freq = [] backend_m = Aer.get_backend("qasm_simulator") backend_s = Aer.get_backend("statevector_simulator") for _ ...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 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 deriva...
https://github.com/ardieb/QiskitPlayground
ardieb
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, Aer, execute from qiskit.quantum_info import Statevector, random_statevector from qiskit.visualization import plot_bloch_multivector, plot_histogram, plot_state_qsphere, plot_state_city from qiskit.circuit.library import iSwapGate import numpy a...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 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 deriv...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.circuit.library import QFT def create_qpe_circuit(theta, num_qubits): '''Creates a QPE circuit given theta and num_qubits.''' # Step 1: Create a circuit with two quantum registers and one classica...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) qc.cx(1, 0) return qc def encode_message(qc, qubit, msg): if len(msg) != 2 or not set([0,1]).issubset({0,1}): raise ValueError(f"message '{msg}' is invalid") if msg[1] == "1": q...
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/abhik-99/Qiskit-Summer-School
abhik-99
!pip install -U -r grading_tools/requirements.txt from IPython.display import clear_output clear_output() # our backend is the Pulse Simulator from resources import helper from qiskit.providers.aer import PulseSimulator backend_sim = PulseSimulator() # sample duration for pulse instructions dt = 1e-9 ...
https://github.com/Pitt-JonesLab/mirror-gates
Pitt-JonesLab
from qiskit.transpiler.coupling import CouplingMap from mirror_gates.pass_managers import Mirage, QiskitLevel3 from qiskit.transpiler import PassManager from mirror_gates.logging import transpile_benchy_logger from mirror_gates.sqiswap_decomposer import SiSwapDecomposePass from qiskit.transpiler.passmanager import...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/swe-bench/Qiskit__qiskit
swe-bench
# 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/sahar-saoudi/Bernstein-Vazirani-Circuit
sahar-saoudi
from qiskit import QuantumCircuit import matplotlib.pyplot as plt from qiskit.circuit import Gate from qiskit.visualization import plot_histogram def oracle_function(qubits_number: int, secret_number: int) -> Gate: """ This function returns a gate corresponding to the question asked to know th...
https://github.com/tomtuamnuq/compare-qiskit-ocean
tomtuamnuq
import itertools import matplotlib.pyplot as plt import networkx as nx from dwave.system import DWaveSampler, FixedEmbeddingComposite import dwave_networkx as dnx import dimod from minorminer import find_embedding from random_lp.lp_random_gen import RandomLP var = 3 cstr = 3 multiple = 1 penalty = 1 ...