repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np import matplotlib.pyplot as plt from qiskit import QuantumRegister, QuantumCircuit from qiskit.circuit.library import IntegerComparator from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler # set problem parameters n_z = 2 ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit circ = QuantumCircuit(2, 2) circ.h(0) circ.cx(0, 1) circ.measure(0, 0) circ.measure(1, 1) circ.draw('mpl') from qiskit import pulse from qiskit.pulse.library import Gaussian from qiskit.providers.fake_provider import FakeValencia backend = FakeValencia() with pulse...
https://github.com/daimurat/qiskit-implementation
daimurat
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.providers.aer import QasmSimulator # Loading your IBM Quantum account(s) provid...
https://github.com/JohnBurke4/qaoa_testing_framework
JohnBurke4
import networkx as nx import numpy as np from Helper_Functions import getBestMaxcut, custom_graphs, ry_simulator, greedyMaxcutSolver, customSATSolverCircuit from qiskit import transpile, Aer from QAOA_Cost_Function import CostFunction v = 6 d = 3 for i in range(0, 1): graph = nx.random_graphs.random...
https://github.com/ionq-samples/qiskit-getting-started
ionq-samples
#imports from qiskit_ionq import IonQProvider ionq_provider = IonQProvider(token='API-key-goes-here') import numpy as np from qiskit import QuantumCircuit, execute, Aer from qiskit.tools.visualization import plot_histogram, array_to_latex from qiskit.extensions import UnitaryGate swap_gate=QuantumCircuit(2) ...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# 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/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/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/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/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/gustavomirapalheta/Quantum-Computing-with-Qiskit
gustavomirapalheta
import numpy as np V = np.array([[3+2j],[4-2j]]) modV = np.real(V.T.conjugate().dot(V)[0,0])**0.5 Vn = V/modV; Vn v0 = np.array([[1,0]]).T v1 = np.array([[0,1]]).T Vn[0,0]*v0 + Vn[1,0]*v1 Vn[0,0].conjugate()*Vn[0,0] Vn[1,0].conjugate()*Vn[1,0] import numpy as np CNOT = np.array([[1,0,0,0], ...
https://github.com/dimple12M/Qiskit-Certification-Guide
dimple12M
from qiskit import * qc1=QuantumCircuit(2,2) qc2=QuantumCircuit(3,3) #qc=qc1+qc2 #qc.draw() #Note: circuits are incompatible qc1=QuantumCircuit(2,2) qc1.h(0) qc1.s(1) qc2=QuantumCircuit(2,2) qc2.x(1) qc2.cx(0,1) qc1.draw(output='mpl') qc2.draw(output='mpl') qc=qc1+qc2 qc.draw(output='mpl') ...
https://github.com/ShabaniLab/q-camp
ShabaniLab
import numpy as np # import numpy # this is a comment pi_number = np.pi print(pi_number) e_number = np.e print(e_number) # float with specific number of decimals print("pie is {0:.5f}, {1}".format(pi_number, " test")) print(f"pi is {pi_number}") print("The Euler number is {0:.2f}".format(e_number))...
https://github.com/Qiskit/feedback
Qiskit
%load_ext autoreload %autoreload 2 import qiskit_metal as metal from qiskit_metal import designs, draw from qiskit_metal import MetalGUI, Dict, open_docs %metal_heading Welcome to Qiskit Metal! from qiskit_metal.qlibrary.qubits.transmon_pocket_6 import TransmonPocket6 from qiskit_metal.qlibrary.tlines.me...
https://github.com/Pitt-JonesLab/slam_decomposition
Pitt-JonesLab
import logging import random from abc import ABC from sys import maxsize from qiskit import QuantumCircuit from qiskit.circuit.gate import Gate from qiskit.quantum_info import Operator, random_clifford, random_unitary from qiskit.transpiler.passes import Collect2qBlocks, ConsolidateBlocks, CountOps from qiski...
https://github.com/Axect/QuantumAlgorithms
Axect
import qiskit qiskit.__qiskit_version__ # useful additional packages import numpy as np import matplotlib.pyplot as plt %matplotlib inline # importing Qiskit from qiskit import BasicAer, IBMQ from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute from qiskit.compiler import transpi...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# -*- 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/ElePT/qiskit-algorithms-test
ElePT
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator
GIRISHBELANI
""" Shor's Order Finding Algorithm Benchmark - QSim """ import math import sys import time import numpy as np from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister sys.path[1:1] = ["_common", "_common/qsim", "shors/_common", "quantum-fourier-transform/qsim"] sys.path[1:1] = ["../../_commo...
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/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit # Create a Quantum Circuit acting on a quantum register of three qubits circ = QuantumCircuit(3) # Add a H gate on qubit 0, putting this qubit in superposition. circ.h(0) # Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting # the qubit...
https://github.com/abbarreto/qiskit2
abbarreto
%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/tigerjack/qiskit_grover
tigerjack
from math import sqrt, pi from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister import oracle_simple import composed_gates def get_circuit(n, oracles): """ Build the circuit composed by the oracle black box and the other quantum gates. :param n: The number of qubits (not including...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
import matplotlib.pyplot as plt import numpy as np x = np.arange(-3*np.pi,3*np.pi,0.1) # start,stop,step y = np.sin(x) yaxis = 0 plt.axes() plt.plot(x,y,xaxis) plt.show()
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from qiskit import QuantumCircuit, QuantumRegister import sys import math import numpy as np class Dynamics: """ Class to implement the simulation of quantum dynamics as described in Section 4.7 of Nielsen & Chuang (Quantum computation and quantum information (10th anniv. version), 2010.) ...
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/theflyingrahul/qiskitsummerschool2020
theflyingrahul
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # (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 modifi...
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 from numpy import savetxt, save, savez_compressed import sys #===================================================================================================================== simulator =...
https://github.com/tomtuamnuq/compare-qiskit-ocean
tomtuamnuq
import warnings import numpy as np from numpy import pi from matplotlib import MatplotlibDeprecationWarning from qiskit import QuantumRegister, QuantumCircuit, execute, BasicAer from qiskit_optimization import QuadraticProgram from qiskit.visualization import plot_state_qsphere from qiskit.quantum_info.operator...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile, schedule from qiskit.visualization.pulse_v2 import draw 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 = schedule(qc, FakeBoe...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt 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 from qiskit import QuantumCircuit, QuantumRegister, IBMQ, execute, transpile,...
https://github.com/clausia/qiskit-fall-fest-peru-2022
clausia
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit A = QuantumRegister(1, 'a') B = QuantumRegister(1, 'b') CarryIn = QuantumRegister(1, 'cin-sum') cero = QuantumRegister(1, 'aux-cout') adder = QuantumCircuit(A, B, CarryIn, cero) adder.ccx(0, 1, 3) adder.cx(0, 1) adder.ccx(1, 2, 3) adder....
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/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/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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, QuantumRegister from qiskit.circuit.library.standard_gates import HGate qr = QuantumRegister(3) qc = QuantumCircuit(qr) c3h_gate = HGate().control(2) qc.append(c3h_gate, qr) qc.draw('mpl')
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/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
# Importing everything from qiskit import * from qiskit.visualization import plot_histogram # For Jupyter Notebooks, change the settings to get nicer images %config InlineBackend.figure_format = 'svg' def create_bell_pair(qc, a, b): qc.h(a) qc.cx(a, b) def encode_message(qc, qubit, message): if...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.circuit.library import MCXGate gate = MCXGate(4) from qiskit import QuantumCircuit circuit = QuantumCircuit(5) circuit.append(gate, [0, 1, 4, 2, 3]) 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/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/1chooo/Quantum-Oracle
1chooo
#Program 3.1a Apply X-gate to qubit from qiskit import QuantumCircuit qc = QuantumCircuit(2) qc.x(1) qc.draw('mpl') #Program 3.1b Show Bloch sphere of qubit w/wo X-gate from qiskit.quantum_info import Statevector state = Statevector.from_instruction(qc) state.draw('bloch') #Program 3.2a Measure state of qu...
https://github.com/qiskit-community/qiskit-aqt-provider
qiskit-community
# This code is part of Qiskit. # # (C) Alpine Quantum Technologies GmbH 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 modi...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile from qiskit.visualization import plot_circuit_layout from qiskit.providers.fake_provider import FakeVigo backend = FakeVigo() ghz = QuantumCircuit(3, 3) ghz.h(0) ghz.cx(0,range(1,3)) ghz.barrier() ghz.measure(range(3), range(3)) ghz.draw(output='mpl')
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/snow0369/qiskit_tutorial_2021_summerschool
snow0369
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.providers.aer import AerProvider from qiskit import execute qr = QuantumRegister(2) # 2 qubits cr = ClassicalRegister(2) # 2 classical bits qc = QuantumCircuit(qr, cr) # a quantum circuit with 2 qubits and 2 bits qc.draw() qc...
https://github.com/qiskit-community/qiskit-alt
qiskit-community
# Benchmark qiskit_alt peforming the Jordan-Wigner transform on a Fermi operator. import qiskit_alt qiskit_alt.project.ensure_init() import timeit def make_setup_code(basis, geometry): return f""" import qiskit_alt.electronic_structure h2_geometry = [['H', [0., 0., 0.]], ['H', [0., 0., 0.7414]]] h2o...
https://github.com/abbarreto/qiskit4
abbarreto
https://github.com/0sophy1/Qiskit-Dev-Cert-lectures
0sophy1
a = 2 + 3j b = 5 - 2j print("a + b=", a+b) print("a * b=", a*b) a = 2 + 3j a_bar = 2 - 3j print("a + a_bar = ", a + a_bar) print("a * a_bar = ", a * a_bar) import matplotlib.pyplot as plt import numpy as np import math z1 = 3 + 4j x_min = 0 x_max = 5.0 y_min = 0 y_max = 5.0 def plot_complex_...
https://github.com/rigetti/qiskit-rigetti
rigetti
from typing import Callable PreCompilationHook = Callable[[str], str] """Represents a function that can transform a QASM program string just before compilation.""" def set_rewiring(rewiring: str) -> PreCompilationHook: """ Create a hook which will apply rewiring before compilation. See: https:...
https://github.com/Cryoris/surfer
Cryoris
"""The Gradient interface. Avoids using the plain name Gradient since that exists in Qiskit and I want to avoid conflicts. """ from abc import ABC, abstractmethod import qiskit import qiskit.opflow import numpy as np class GradientCalculator(ABC): """The Gradient interface.""" def __init__(se...
https://github.com/adlantz/QiskitSG
adlantz
# initialization import itertools as it import os from typing import List # importing Qiskit from qiskit import ( Aer, QuantumCircuit, ClassicalRegister, QuantumRegister, transpile, ) # import basic plot tools from qiskit.visualization import plot_histogram import pprint ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import QuantumCircuit from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler from qiskit_finance.circuit.library import NormalDistribution # can be used in case a...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 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 deriv...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# -*- 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/alejomonbar/Quantum-Supply-Chain-Manager
alejomonbar
# !pip install --upgrade pip # !pip uninstall tensorflow --y # !pip install tensorflow #import os #os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # load csv file import pandas as pd # numpy to the seed import numpy as np # load csv fileframework to neural networks...
https://github.com/SaashaJoshi/IBM-Qiskit-Summer-School-2020
SaashaJoshi
!pip install -U -r grading_tools/requirements.txt from IPython.display import clear_output clear_output() import numpy as np; pi = np.pi from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram from copy import deepcopy as make_copy def prepare_hets_circuit(depth, ang...
https://github.com/Pitt-JonesLab/slam_decomposition
Pitt-JonesLab
from typing import List import numpy as np import weylchamber from qiskit.circuit.gate import Gate from qiskit.circuit.parameterexpression import ParameterValueType from qiskit.extensions import UnitaryGate from slam.hamiltonian import ( CirculatorHamiltonian, ConversionGainPhaseHamiltonian, Co...
https://github.com/PavanCyborg/Quantum-Algorithms-Benchmarking
PavanCyborg
#Assign these values as per your requirements. global min_qubits,max_qubits,skip_qubits,max_circuits,num_shots,Noise_Inclusion method = 2 min_qubits=4 # must be at least (MIN_STATE_QUBITS=1) + 3 = 4 ## for method-1 min_qubits = 5 (MIN_STATE_QUBITS = 2)+3 = 5 max_qubits=10 # Because circuit size grows significan...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# randomly create a 2-dimensional quantum state from random import randrange def random_quantum_state(): first_entry = randrange(101) first_entry = first_entry/100 first_entry = first_entry**0.5 if randrange(2) == 0: first_entry = -1 * first_entry second_entry = 1 - (first_entry**2...
https://github.com/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
# required imports: from qiskit.visualization import array_to_latex from qiskit.quantum_info import Statevector, random_statevector from qiskit.quantum_info.operators import Operator, Pauli from qiskit import QuantumCircuit from qiskit.circuit.library import HGate, CXGate import numpy as np ket0 = [[1],[0]] ...
https://github.com/AmirhoseynpowAsghari/Qiskit-Tutorials
AmirhoseynpowAsghari
import random import matplotlib.pyplot as plt def generate_n_bit_inputs(n): """Generate all possible n-bit inputs.""" return [bin(i)[2:].zfill(n) for i in range(2**n)] def constant_function(value): """Returns a constant function that always returns the given value.""" return lambda x: val...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse d0 = pulse.DriveChannel(0) d1 = pulse.DriveChannel(1) with pulse.build() as pulse_prog: with pulse.align_right(): # this pulse will start at t=0 pulse.play(pulse.Constant(100, 1.0), d0) # this pulse will start at t=80 pulse.play(pulse.Constant(20,...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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_optimization.problems import QuadraticProgram # define a problem qp = QuadraticProgram() qp.binary_var("x") qp.integer_var(name="y", lowerbound=-1, upperbound=4) qp.maximize(quadratic={("x", "y"): 1}) qp.linear_constraint({"x": 1, "y": -1}, "<=", 0) print(qp.prettyprint()) from qiskit_optimizati...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# load necessary Runtime libraries from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Session backend = "ibmq_qasm_simulator" # use the simulator from qiskit.circuit import Parameter from qiskit.opflow import I, X, Z mu = Parameter('$\\mu$') ham_pauli = mu * X cc = Parameter('$c$') ww = Para...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile from qiskit.visualization import plot_circuit_layout from qiskit.providers.fake_provider import FakeVigo backend = FakeVigo() ghz = QuantumCircuit(3, 3) ghz.h(0) ghz.cx(0,range(1,3)) ghz.barrier() ghz.measure(range(3), range(3)) ghz.draw(output='mpl')
https://github.com/Z-928/Bugs4Q
Z-928
from qiskit import * qc = QuantumCircuit(2) qc.h(i) qc.crz (PI/4, 0, 1)
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np # Import Qiskit from qiskit import QuantumCircuit, transpile from qiskit_aer import AerSimulator # Construct quantum circuit circ = QuantumCircuit(2, 2) circ.h(0) circ.cx(0, 1) circ.measure([0,1], [0,1]) # Select the AerSimulator from the Aer provider simulator = AerSimulator(method='...
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, 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
from qiskit import QuantumCircuit circ = QuantumCircuit(2, 2) circ.h(0) circ.cx(0, 1) circ.measure(0, 0) circ.measure(1, 1) circ.draw('mpl') from qiskit import pulse from qiskit.pulse.library import Gaussian from qiskit.providers.fake_provider import FakeValencia backend = FakeValencia() with pulse...
https://github.com/alvinli04/Quantum-Steganography
alvinli04
import qiskit from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, AncillaRegister from qiskit import execute from qiskit import Aer from qiskit import IBMQ from qiskit.compiler import transpile from time import perf_counter from qiskit.tools.visualization import plot_histogram from qiskit.cir...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import * from qiskit.providers.ibmq import least_busy from qiskit.tools.visualization import plot_histogram from IPython.display import display, Math, Latex def Increment(size): U = QuantumCircuit(size) control = [x...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse d0 = pulse.DriveChannel(0) x90 = pulse.Gaussian(10, 0.1, 3) x180 = pulse.Gaussian(10, 0.2, 3) with pulse.build() as hahn_echo: with pulse.align_equispaced(duration=100): pulse.play(x90, d0) pulse.play(x180, d0) pulse.play(x90, d0) hahn_echo.draw()
https://github.com/snow0369/qiskit_tutorial_2021_summerschool
snow0369
from qiskit import IBMQ, QuantumRegister, QuantumCircuit, ClassicalRegister, transpile from qiskit.tools import backend_overview, backend_monitor from qiskit.providers.ibmq.job import job_monitor from qiskit.quantum_info import hellinger_fidelity from qiskit.providers.ibmq import IBMQAccountCredentialsNotFound fro...
https://github.com/daimurat/qiskit-implementation
daimurat
import numpy as np import matplotlib.pyplot as plt from qiskit import Aer, QuantumCircuit from qiskit.circuit import Parameter from qiskit.circuit.library import RealAmplitudes, ZZFeatureMap from qiskit.opflow import StateFn, PauliSumOp, AerPauliExpectation, Gradient from qiskit.utils import Quant...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
%run init.ipynb 2*acos(sqrt(2/3)), 2*asin(sqrt(1/3)). cos(2*pi/3), sin(2*pi/3), cos(4*pi/3), sin(4*pi/3), cos(8*pi/3), sin(8*pi/3) cos(2*pi/3), sin(2*pi/3), cos(4*pi/3), sin(4*pi/3), cos(8*pi/3), sin(8*pi/3)
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import * from qiskit.circuit import Gate my_gate = Gate(name='my_gate', num_qubits=2, params=[]) qr = QuantumRegister(3, 'q') circ = QuantumCircuit(qr) circ.append(my_gate, [qr[0], qr[1]]) circ.append(my_gate, [qr[1], qr[2]]) circ.draw() # Build a sub-circuit sub_q = Q...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import math from qiskit import pulse from qiskit.providers.fake_provider import FakeOpenPulse3Q # TODO: This example should use a real mock backend. backend = FakeOpenPulse3Q() d2 = pulse.DriveChannel(2) with pulse.build(backend) as bell_prep: pulse.u2(0, math.pi, 0) pulse.cx(0, 1) with pulse...
https://github.com/Z-928/Bugs4Q
Z-928
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.wrapper import available_backends, get_backend from qiskit.wrapper import execute as q_execute q = QuantumRegister(2, name='q') c = ClassicalRegister(2, name='c') qc = QuantumCircuit(q,c) qc.h(q[0]) qc.h(q[1]) qc.cx(q[0], q[1]...
https://github.com/usamisaori/quantum-expressibility-entangling-capability
usamisaori
import sys sys.path.append('../') from circuits import sampleCircuitA, sampleCircuitB1, sampleCircuitB2,\ sampleCircuitB3, sampleCircuitC, sampleCircuitD, sampleCircuitE,\ sampleCircuitF from entanglement import Ent import warnings warnings.filterwarnings('ignore') labels = [ 'Circuit A', 'Ci...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt import numpy as np from qiskit.circuit import ParameterVector from qiskit.circuit.library import TwoLocal from qiskit.quantum_info import Statevector from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler from qi...
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/7enTropy7/Shor-s-Algorithm_Quantum
7enTropy7
import numpy as np import math import gmpy2 from gmpy2 import powmod,mpz,isqrt,invert from qiskit.aqua.algorithms import Shor from qiskit.aqua import QuantumInstance from qiskit import Aer,execute,QuantumCircuit from qiskit.tools.visualization import plot_histogram from qiskit.providers.ibmq import least_busy ...
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/devilkiller-ag/UnravelQuantum
devilkiller-ag
# ########## Import Initialization ############ from qiskit import QuantumCircuit, transpile from qiskit.providers.basic_provider import BasicProvider from qiskit_aer import AerSimulator from qiskit.visualization import plot_histogram, circuit_drawer from qiskit_ibm_provider.job import job_monitor from qiskit_ibm...
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/abbarreto/qiskit3
abbarreto
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
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/renatawong/quantum-maxcut
renatawong
''' (C) Renata Wong (NCTS-NTU) 2023 This is the accompanying code for the paper "Quantum speedup for the maximum cut problem" for the example graph given in Fig. 1. Note: It is impossible to execute it for graphs with more than 2 edges as the number of qubits exceeds the simulator limit. ''' from qiskit i...
https://github.com/AnshDabkara/Qiskit_Algorithm
AnshDabkara
import cirq import numpy as np from qiskit import QuantumCircuit, execute, Aer import seaborn as sns import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (15,10) q0, q1, q2 = [cirq.LineQubit(i) for i in range(3)] circuit = cirq.Circuit() #entagling the 2 quibits in different laboratories #and p...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.circuit.quantumcircuitdata import CircuitInstruction from qiskit.circuit import Measure from qiskit.circuit.library import HGate, CXGate qr = QuantumRegister(2) cr = ClassicalRegister(2) instructions = [ CircuitInstruction(...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit # Create a Quantum Circuit acting on a quantum register of three qubits circ = QuantumCircuit(3) # Add a H gate on qubit 0, putting this qubit in superposition. circ.h(0) # Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting # the qubit...
https://github.com/dlyongemallo/qiskit-zx-transpiler
dlyongemallo
from qiskit.circuit import QuantumCircuit from qiskit.converters import circuit_to_dag from qiskit.visualization import dag_drawer import numpy as np # Taken from https://github.com/Quantomatic/pyzx/blob/master/circuits/Fast/mod5_4_before qc = QuantumCircuit(5) qc.x(4) qc.h(4) qc.ccz(0, 3, 4) qc.ccz(2, 3, 4)...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import torch from qiskit.utils import algorithm_globals algorithm_globals.random_seed = 123456 _ = torch.manual_seed(123456) # suppress output import numpy as np num_dim = 2 num_discrete_values = 8 num_qubits = num_dim * int(np.log2(num_discrete_values)) from scipy.stats import multivariate_normal c...
https://github.com/Naphann/Solving-TSP-Grover
Naphann
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit import IBMQ, Aer, execute from qiskit.tools.visualization import plot_histogram ## oracle_initialize_part def OR(qubit_1, qubit_2, k): # enter qubit numbers here """ function does the equivalent of a classical OR betwee...