repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
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/animeshnanda1/my_QAOA_qiskit
animeshnanda1
import qiskit qiskit.__qiskit_version__ # import warnings; warnings.filterwarnings("ignore") 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, Quan...
https://github.com/acfilok96/Quantum-Computation
acfilok96
# Quantum Computation import qiskit print(qiskit.__version__) import qiskit.quantum_info as qi from qiskit.circuit.library import FourierChecking from qiskit.visualization import plot_histogram f = [1, -1, -1, -1] g = [1, 1, -1, -1] # How co-related fourier transform of function g to function f. # we ...
https://github.com/jonasmaziero/computacao_quantica_qiskit_sbf_2023
jonasmaziero
import math; import numpy as np; phmax = 4*math.pi; npt = 100; dth = phmax/npt; ph = np.arange(0,phmax+dth,dth) from matplotlib import pyplot as plt; PrD0 = 0.5*(1+np.cos(ph)); plt.plot(ph,PrD0, label=r'$Pr(D_0)$') PrD0 = 0.5*(1-np.cos(ph)); plt.plot(ph,PrD0, label=r'$Pr(D_1)$'); plt.legend(); plt.xlabel(r'$\phi$'); ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np import matplotlib.pyplot as plt from IPython.display import display, clear_output from qiskit.primitives import Estimator from qiskit.algorithms.minimum_eigensolvers import VQE from qiskit.algorithms.observables_evaluator import estimate_observables from qiskit.algorithms.optimizers import COBY...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/scaleway/qiskit-scaleway
scaleway
# Copyright 2024 Scaleway # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
https://github.com/abbarreto/qiskit3
abbarreto
%run init.ipynb c00,c01,c10,c11 = symbols('c_{00} c_{01} c_{10} c_{11}') psiAB = Matrix([[c00],[c01],[c10],[c11]]); psiAB rhoAB = psiAB*conjugate(psiAB.T); rhoAB rhoA = ptraceB(2,2,rhoAB); rhoB = ptraceA(2,2,rhoAB) rhoA, rhoB pauli(3)*pauli(1)*pauli(3), pauli(3)*pauli(2)*pauli(3), comm(pauli(3),pauli(1)),...
https://github.com/arnavdas88/QuGlassyIsing
arnavdas88
!pip install qiskit from qiskit.providers.aer import AerSimulator, QasmSimulator from qiskit.algorithms import VQE from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import TwoLocal # opflow is Qiskit's module for creating operators like yours from qiskit import * from qiskit.opflow i...
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/apcarrik/qiskit-dev
apcarrik
import numpy as np from qiskit import * from matplotlib import pyplot # Initialize quantum circuit with 3 qubits (and no classical bits) circ = QuantumCircuit(3) # Set circuit into 3-qubit GHZ state circ.h(0) circ.cx(0,1) circ.cx(0,2) # Visualize circuit circ.draw('mpl') pyplot.show() ### Simulating...
https://github.com/zapata-engineering/orquestra-qiskit
zapata-engineering
################################################################################ # © Copyright 2022 Zapata Computing Inc. ################################################################################ from typing import List, Optional import numpy as np from orquestra.quantum.api.wavefunction_simulator import ...
https://github.com/icarosadero/maxima_function_qiskit
icarosadero
%matplotlib inline from qiskit import QuantumCircuit, execute, Aer, IBMQ, QuantumRegister from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * provider = IBMQ.load_account() circ = QuantumCircuit(4,4) #Preparation circ.h(0) circ.h(1) #Oracle f...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/swe-train/qiskit__qiskit
swe-train
# 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/MiChaelinzo/Quantum-time-travel
MiChaelinzo
from qiskit.optimization.applications import Maxcut from qiskit.aqua.algorithms import QAOA from qiskit import Aer # Define a graph representing your decision problem (example: Maxcut) graph = generate_butterfly_graph(with_weights=True) max_cut = Maxcut(graph) qp = max_cut.to_quadratic_program() # QAOA param...
https://github.com/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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. # # Any modifications or...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
# let's print all numbers between 0 and 9 for i in range(10): print(i) # range(n) represents the list of all numbers from 0 to n-1 # i is the variable to take the values in the range(n) iteratively: 0, 1, ..., 9 in our example # let's write the same code in two lines for i in range(10): # do not forget to use co...
https://github.com/shantomborah/Quantum-Algorithms
shantomborah
import numpy as np import matplotlib.pyplot as plt from qiskit import QuantumCircuit, Aer, execute from qiskit.circuit import ParameterVector from qiskit.extensions import HamiltonianGate from qiskit.visualization import plot_histogram from qiskit.aqua.components.optimizers import COBYLA class QAOA: ...
https://github.com/iqm-finland/qiskit-on-iqm
iqm-finland
# -*- 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/Aman-Agrawal01/Quantum-Computing-Qiskit-Tutorial
Aman-Agrawal01
from qiskit import * from qiskit.tools.visualization import plot_histogram %matplotlib inline qr1 = QuantumRegister(size=2,name='numbers') qr2 = QuantumRegister(size=1,name='answer-bit') qr3 = QuantumRegister(size=1,name='carry-bit') cr1 = ClassicalRegister(size=1,name='answer-cbit') cr2 = ClassicalRegister(...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
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 import qiskit.quantum_info as qi Aer.backends() simulator = Aer.get_backend('aer_simulator') # Create circuit circ = QuantumCircu...
https://github.com/0tt3r/QuaC-qiskit
0tt3r
# -*- coding: utf-8 -*- """This example demonstrates the applying measurement error to a GHZ circuit in the plugin. Additionally, the use of multiple classical registers is demonstrated. """ from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute from qiskit.visualization import plot_histo...
https://github.com/HuangJunye/Qiskit-for-GameDev
HuangJunye
import sys sys.path.append('/Users/kirais/Documents/GitHub/Qiskit-for-GameDev/pygame/') from qgame import CircuitGridModel, CircuitGridNode, MeasurementsHistogram from qgame import circuit_node_types as node_types from qiskit import QuantumCircuit circuit_grid_model = CircuitGridModel(4, 18) circuit_grid_mo...
https://github.com/SanNare/qiskit-notebooks
SanNare
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector from qiskit.tools.visualization import plot_bloch_multivector, plot_histogram def logicalAnd(circuit,input_qubits,output_qubit): circuit.mcx(input_qubits,output_qubit) def logicalOr(circuit,input_qubits,output_qubit): fo...
https://github.com/ctuning/ck-qiskit
ctuning
#-------------------------------------------------------------------------------------------------------------- # This module contains control unitaries that can be used while developing circuits on IBM QExperience #-----------------------------------------------------------------------------------------------------...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import execute, pulse d0 = pulse.DriveChannel(0) with pulse.build() as pulse_prog: pulse.play(pulse.Constant(100, 1.0), d0) pulse_prog.draw()
https://github.com/qiskit-community/qiskit-qcgpu-provider
qiskit-community
import matplotlib.pyplot as ply %matplotlib inline import networkx as nx import numpy as np from qiskit_aqua.translators.ising import tsp from qiskit_aqua.input import EnergyInput from qiskit_aqua import run_algorithm from qiskit_qcgpu_provider import QCGPUProvider locations = 3 problem = tsp.random_ts...
https://github.com/quantum-kittens/quantum-computing-basics
quantum-kittens
from qiskit import * from qiskit.visualization import plot_histogram %config InlineBackend.figure_format = 'svg' qc_ab = QuantumCircuit(6,6) #Create a quantum circuit with 6 qubits and 6 classical bits ##ENCODE BIT STRING #The random bit sequence Alice needs to encode is: 100100, so the first and fourth qubi...
https://github.com/ElePT/qiskit-algorithms-test
ElePT
# This code is part of Qiskit. # # (C) Copyright IBM 2018, 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/maryrbarros2/QuantumAlgorithms_Qiskit
maryrbarros2
# initialization import numpy as np import matplotlib # importing Qiskit from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ, BasicAer, assemble, transpile from qiskit.quantum_info import Statevector # import basic plot tools ...
https://github.com/arnavdas88/QuGlassyIsing
arnavdas88
!pip install qiskit J = 4.0 B_x = 0.25 B_z = 1.5 import numpy as np from qiskit.providers.aer import AerSimulator, QasmSimulator from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import TwoLocal from qiskit.aqua.operators import * from qiskit.aqua import set_qiskit_aqua_logging, ...
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 """ print("Ch 7: Aer out of the box, a perfect quantum computer") print("----------------------------------------------------") # Import Qiskit from qiskit import QuantumCircuit from qiskit import Aer, IBMQ, execute # ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
%run qlatvia.py draw_qubit() [x,y]=[1,0] draw_quantum_state(x,y,"v0") sqrttwo = 2**0.5 oversqrttwo = 1/sqrttwo R = [ [oversqrttwo, -1*oversqrttwo], [oversqrttwo,oversqrttwo] ] # function for rotation R def rotate(px,py): newx = R[0][0]*px + R[0][1]*py newy = R[1][0]*px + R[1][1]*py re...
https://github.com/1chooo/Quantum-Oracle
1chooo
from qiskit import execute from qiskit.providers.aer import AerSimulator from qiskit.visualization import plot_histogram from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector qc = QuantumCircuit(2, 2) sv = Statevector.from_label("10") qc.initialize(sv, range(2)) qc.h(0) qc.cx(0, 1) ...
https://github.com/epelaaez/QuantumLibrary
epelaaez
import numpy as np from qiskit import Aer from qiskit.algorithms import Shor import matplotlib.pyplot as plt x = np.linspace(start=0, stop=29, num=30) plt.plot(x, (3**x) % 20, 'x--', linewidth=1) plt.xlabel('x', fontsize=10) plt.ylabel('$3^x$ mod 20', fontsize=10) plt.grid(visible=True) plt.show() backend...
https://github.com/RicardoBBS/ShorAlgo
RicardoBBS
import sys import numpy as np from matplotlib import pyplot as plt from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, visualization from random import randint def to_binary(N,n_bit): Nbin = np.zeros(n_bit, dtype=bool) for i in range(1,n_bit+1): bit_sta...
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/maryrbarros2/QuantumAlgorithms_Qiskit
maryrbarros2
from qiskit import QuantumCircuit, assemble, Aer from qiskit.visualization import plot_histogram, plot_bloch_vector from math import sqrt, pi qc = QuantumCircuit(1) #Quantum circuit with one qubit initial_state = [0,1] # Define initial_state as |1> qc.initialize(initial_state, 0) # Apply initialisation ope...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit qr = QuantumRegister(2) cr = ClassicalRegister(2) qc = QuantumCircuit(qr, cr) qc.h(range(2)) qc.measure(range(2), range(2)) # apply x gate if the classical register has the value 2 (10 in binary) qc.x(0).c_if(cr, 2) # apply y gate if bi...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer # we use four pairs of two qubits in order to see all results at once # the first pair -> q...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.providers.fake_provider import FakeManilaV2 from qiskit import transpile from qiskit.tools.visualization import plot_histogram # Get a fake backend from the fake provider backend = FakeManilaV2() # Create a simple circuit circuit = QuantumCircuit(3) circuit.h(...
https://github.com/VoicuTomut/Qsiris-Quantum-Odyssey-and-Qiskit
VoicuTomut
import numpy as np from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.compiler import transpile import matplotlib.pyplot as plt import matplotlib.image as mpimg from project_qsiris.conversion_qiskit_qo import qiskit_to_odyssey, save_odyssey_puzzle #Add here any Qiskit g...
https://github.com/mahabubul-alam/QAOA-Compiler
mahabubul-alam
!python run.py -device_json examples/QC.json -circuit_json examples/QAOA_circ.json -config_json examples/Config.json -policy_compilation VIC -initial_layout_method vqp !cat VIC_QAOA.qasm
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/zapata-engineering/orquestra-qiskit
zapata-engineering
################################################################################ # © Copyright 2021-2022 Zapata Computing Inc. ################################################################################ import numpy as np import pytest import qiskit import qiskit.circuit.random import sympy from orquestra....
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/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/2lambda123/Qiskit-qiskit
2lambda123
# 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/filipecorrea/deutsch-jozsa
filipecorrea
import numpy as np import qiskit from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, execute from qiskit.visualization import plot_histogram qiskit.__qiskit_version__ # set the length of the n-bit input string n = 3 const_oracle = QuantumCircu...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# 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/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit from qiskit.visualization import visualize_transition qc = QuantumCircuit(1) qc.y(0) qc.draw('mpl') visualize_transition(qc) qc1 = QuantumCircuit(1) qc1.x(0) qc1.y(0) qc1.draw('mpl') visualize_transition(qc1)
https://github.com/anpaschool/QC-School-Fall2020
anpaschool
from qiskit import QuantumCircuit, execute,QuantumCircuit, ClassicalRegister, QuantumRegister, Aer from math import pi import numpy as np from qiskit.visualization import plot_bloch_multivector, plot_histogram %matplotlib inline qc = QuantumCircuit(3) # Apply H-gate to each qubit: for qubit in range(3): q...
https://github.com/dkp-quantum/Tutorials
dkp-quantum
%matplotlib inline # Importing standard Qiskit libraries and configuring account from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * # Loading your IBM Q account(s) provider = IBMQ.load_account...
https://github.com/vm6502q/qiskit-qrack-provider
vm6502q
# 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. # # Any modifications or...
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
# -*- 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 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/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 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/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt from scipy.interpolate import griddata %matplotlib inline import numpy as np from qiskit import QuantumRegister, QuantumCircuit, AncillaRegister, transpile from qiskit.circuit.library import IntegerComparator, WeightedAdder, LinearAmplitudeFunction from qiskit.algorithms import...
https://github.com/JohnBurke4/qaoa_testing_framework
JohnBurke4
from Image_Reader import ImageReader from DCT_Classic import DCT import Quantum_Subroutines import os import Image_Compression import cv2 import matplotlib.pyplot as plt import numpy as np from qiskit import QuantumCircuit, Aer, transpile from qiskit_aer.backends.aerbackend import AerBackend from qiskit.provi...
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/theflyingrahul/qiskitsummerschool2020
theflyingrahul
# -*- 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_optimization import QuadraticProgram qp = QuadraticProgram() qp.binary_var("x") qp.binary_var("y") qp.integer_var(lowerbound=0, upperbound=7, name="z") qp.maximize(linear={"x": 2, "y": 1, "z": 1}) qp.linear_constraint(linear={"x": 1, "y": 1, "z": 1}, sense="LE", rhs=5.5, name="xyz_leq") qp.linear...
https://github.com/Tojarieh97/VQE
Tojarieh97
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 = 100 w_vector = np.asarray([4,3,2,1]) from qiskit import Aer from qiskit.utils import QuantumInstance, algorithm_globals seed = 50 algorithm_...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# You can choose different colors for the real and imaginary parts of the density matrix. from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix from qiskit.visualization import plot_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) state = DensityMatrix(qc) plot_state_city(st...
https://github.com/mistryiam/IBM-Qiskit-Machine-Learning
mistryiam
import numpy as np # Importing standard Qiskit libraries from qiskit import QuantumCircuit, transpile, assemble, Aer, IBMQ, execute from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector, plot_histogram from qiskit_textbook.problems import dj_problem_oracle def lab...
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/urwin419/QiskitChecker
urwin419
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, 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)) new_circ_lv3 = transpile(ghz, bac...
https://github.com/mballarin97/mps_qnn
mballarin97
# This code is part of qcircha. # # 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...
https://github.com/Qiskit/feedback
Qiskit
import qiskit qiskit.__version__ from qiskit.circuit.library import XGate gate = XGate() print(f"name: {gate.name}\n") print(f"params: {gate.params}\n") print(f"matrix:\n{gate.to_matrix()}\n") print(f"definition:\n{gate.definition}\n") new_gate = XGate() print(f"name: {gate.name}\n") print(f"params: {gate...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.algorithms import AmplificationProblem # the state we desire to find is '11' good_state = ['11'] # specify the oracle that marks the state '11' as a good solution oracle = QuantumCircuit(2) oracle.cz(0, 1) # define Grover's algorithm problem = AmplificationPro...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 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...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/NesyaLab/qaoa
NesyaLab
import os os.chdir("..") from classes import Qaoa as Q from classes import Problems as P from functions import qaoa_utilities as qaoa_utils from functions import maxcut_utilities as mcut_utils from functions import qaoa_optimizers as optims import numpy as np import pickle import sys from config import ...
https://github.com/COFAlumni-USB/qiskit-fall-2022
COFAlumni-USB
#For Python and advanced manipulation import these packages try: import numpy as np except: !pip install numpy import numpy as np try: import qiskit except: !pip install qiskit import qiskit try: !pip install pylatexenc estilo = 'mpl' QuantumCircuit(1).draw(estilo) except: es...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix from qiskit.visualization import plot_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) # plot using a DensityMatrix state = DensityMatrix(qc) plot_state_city(state)
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute from qiskit.quantum_info import Statevector from qiskit.visualization import plot_s...
https://github.com/shell-raiser/Qiskit-Developer-Certification-Notes-and-Code
shell-raiser
from qiskit import IBMQ, assemble, transpile from qiskit.circuit.random import random_circuit provider = IBMQ.load_account() backend = provider.backend.ibmq_vigo qx = random_circuit(n_qubits=5, depth=4) #generate random ckt transpiled = transpile(qx, backend=backend) job = backend.run(transpiled) retrieved_jo...
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/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2020, 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/xtophe388/QISKIT
xtophe388
from IPython.display import Image Image(filename="error_correction_files/error_correction_1_0.png", width=450, height=300) Image(filename="error_correction_files/error_correction_3_0.png", width=450, height=300) Image(filename="error_correction_files/error_correction_5_0.png", width=450, height=300) ...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from scipy.stats import kruskal import pandas as pd import numpy as np #if p value less than alpha reject qiskit_data = np.concatenate((np.full(4925, 'z00'), np.full(5075, 'z11'), np.full(5016, 'x00'), np.full(4984, 'x11'), np.full(4898, 'y10'), np.full(5102, 'y01'))) print(qiskit_dat...
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)) new_circ_lv0 = transpile(ghz, bac...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import qiskit.tools.jupyter %qiskit_version_table %qiskit_copyright
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/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/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 deriv...
https://github.com/carstenblank/qiskit-aws-braket-provider
carstenblank
import cmath import math import numpy as np import qiskit import matplotlib.pyplot as plt from qiskit import QuantumCircuit from typing import Optional, List, Dict from qiskit_aws_braket_provider.awsprovider import AWSProvider def compute_rotation(index_state): if len(index_state) != 2: re...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
%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/benkoehlL/Qiskit_Playground
benkoehlL
from qiskit import * import matplotlib.pyplot as plt from matplotlib.pyplot import plot, draw, show import numpy as np from qiskit.providers.ibmq import least_busy from qiskit.tools.visualization import plot_histogram import os, shutil def dot(s,z): sum = 0 for i in range(len(str(s))): sum +...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
import numpy as np import matplotlib.pyplot as plt # Constants electron_wavelength = 0.1 # De Broglie wavelength of electrons slit_width = 0.1 # Width of each slit screen_distance = 2.0 # Distance from the slits to the screen screen_width = 2.0 # Width of the screen screen_resolution = 800 # Number of pix...
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/anirban-m/qiskit-superstaq
anirban-m
import importlib from typing import List, Optional, Union import applications_superstaq import qiskit try: import qtrl.sequencer except ModuleNotFoundError: pass class AQTCompilerOutput: def __init__( self, circuits: Union[qiskit.QuantumCircuit, List[qiskit.QuantumCircuit]...
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)) # Virtual -> physical # 0 ...
https://github.com/arthurfaria/Qiskit_certificate_prep
arthurfaria
from qiskit import QuantumCircuit, BasicAer, execute, IBMQ from qiskit.visualization import plot_histogram ghz = QuantumCircuit(3,3) ghz.h(0) ghz.cx(0,1) ghz.cx(1,2) #ghz.barrier(0,2) ghz.measure([0,1,2],[0,1,2]) # also possible to measure only one qubit with the desired classical bit. #For example, qubit 2...
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/sohamch08/Qiskit-Quantum-Algo
sohamch08
# Import all the necessary libraries numpy, math, random, time import numpy as np import math import random import time seed = np.random.seed(0) """ Define parameters n - Problem size in terms of input variables. Change it as per the problem size theta,delta,m1,m2 - Par...
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...