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 from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix from qiskit.visualization import plot_state_hinton qc = QuantumCircuit(2) qc.h([0, 1]) qc.cz(0,1) qc.ry(np.pi/3 , 0) qc.rx(np.pi/5, 1) state = DensityMatrix(qc) plot_state_hinton(state, title="New Hinton Plo...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(1) cr = ClassicalRegister(1) qc = QuantumCircuit(qr, cr) qc.h(0) qc.measure(0, 0) qc.x(0).c_if(cr, 0) qc.measure(0, 0) qc.draw('mpl')
https://github.com/drobiu/quantum-project
drobiu
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister, BasicAer, execute from qiskit.circuit.library import XGate from src.arithmetic.comparator import comparator from src.arithmetic.counter import mincount, count from src.logic.oracles import oracle_a, oracle_b from src.logic.query import query ...
https://github.com/xtophe388/QISKIT
xtophe388
# checking the version of PYTHON; only support > 3.5 import sys if sys.version_info < (3,5): raise Exception('Please use Python version 3.5 or greater.') # importing QISKit from qiskit import QuantumProgram #import Qconfig # import basic plotting tools from qiskit.tools.visualization import plot_h...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
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/alejomonbar/Quantum-Supply-Chain-Manager
alejomonbar
%load_ext autoreload %autoreload 2 # to use dataframe and load csv file import pandas as pd # to use for mathematical operations import numpy as np # split the set in 2 set, common train and test from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler # plot...
https://github.com/tanmaybisen31/Quantum-Teleportation
tanmaybisen31
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 numpy as np import matplotlib.pyplot as plt try: import cplex from cplex.exceptions import CplexError except: print("Warning: Cplex not found.") import math from qiskit.utils import algorithm_globals from qiskit.algorithms.minimum_eigensolvers import SamplingVQE from qiskit.algorithms.o...
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/2lambda123/Qiskit-qiskit
2lambda123
# 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/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/iqm-finland/qiskit-on-iqm
iqm-finland
# Copyright 2023 Qiskit on IQM developers # # 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 a...
https://github.com/Cgrubick/GroversSearchAlgorithm
Cgrubick
# HONR 293W Quantum Computing for Fun Clayton Grubick # complete program written in Qiskit for searching a # two-qubit quantum database using Grover’s search # algorithm. # from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram from numpy import random from matplotlib...
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/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/qiskit-translations-staging
qiskit-community
import datetime import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt plt.rcParams.update({"text.usetex": True}) plt.rcParams["figure.figsize"] = (6,4) mpl.rcParams["figure.dpi"] = 200 from qiskit_ibm_runtime import Estimator, Session, QiskitRuntimeService, Options from qiskit.quantum_in...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools from pprint import pprint # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts # 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 Qua...
https://github.com/MetalKyubit/Quantum-Algorithms-in-Qiskit
MetalKyubit
# initialization import numpy as np # importing Qiskit from qiskit import * # import basic plot tools from qiskit.visualization import plot_histogram from qiskit.providers.fake_provider import FakeJakarta from qiskit.providers.fake_provider import FakeNairobi #defining a function to create the Grover...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import qiskit.qasm3 program = """ OPENQASM 3.0; include "stdgates.inc"; input float[64] a; qubit[3] q; bit[2] mid; bit[3] out; let aliased = q[0:1]; gate my_gate(a) c, t { gphase(a / 2); ry(a) c; cx c, t; } gate my_phase(a) c { ctrl ...
https://github.com/jeevesh2002/QuantumKatasQiskit
jeevesh2002
%kata T1_ApplyY operation ApplyY (q : Qubit) : Unit is Adj+Ctl { Y(q); // As simple as that } %kata T2_GlobalPhaseI operation GlobalPhaseI (q : Qubit) : Unit is Adj+Ctl { Z(q); Y(q); X(q); } %kata T3_SignFlipOnZero operation SignFlipOnZero (q : Qubit) : Unit is Adj+Ctl { X(q); ...
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/qiskit-community/qiskit-translations-staging
qiskit-community
# If you introduce a list with less colors than bars, the color of the bars will # alternate following the sequence from the list. import numpy as np from qiskit.quantum_info import DensityMatrix from qiskit import QuantumCircuit from qiskit.visualization import plot_state_paulivec qc = QuantumCircuit(2) qc....
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import json import time import warnings import matplotlib.pyplot as plt import numpy as np from IPython.display import clear_output from qiskit import ClassicalRegister, QuantumRegister from qiskit import QuantumCircuit from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import RealAm...
https://github.com/dnnagy/qintro
dnnagy
import math import numpy as np import matplotlib as mpl from matplotlib import pyplot as plt import qiskit from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import Aer, execute from qiskit.visualization import plot_bloch_multivector from qiskit.visualization import plot_bloc...
https://github.com/bertolinocastro/quantum-computing-algorithms
bertolinocastro
# A Quantum Circuit to Construct All Maximal Cliques Using Grover’s Search Algorithm ## Chu Ryang Wie ### DOI: https://arxiv.org/abs/1711.06146v2 import matplotlib #matplotlib.use('Agg') import matplotlib.pyplot as plt from qiskit import * # IBMQ.load_account() from qiskit.visualization import * n = 3 ...
https://github.com/Seanaventure/HighErrorRateRouting
Seanaventure
import matplotlib.pyplot as plt import networkx as nx import qiskit import HERR from qiskit.transpiler import CouplingMap from qiskit.transpiler.passes.routing import BasicSwap from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.dagcircuit import DAGCircuit from qiskit.converters import circuit_to...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
#importing array and useful math functions import numpy as np #importing circuits and registers from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister #importing backends and running environment from qiskit import BasicAer, execute ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Clifford, random_clifford qc = QuantumCircuit(3) cliff = random_clifford(2) qc.append(cliff, [0, 1]) qc.ccx(0, 1, 2) qc.draw('mpl')
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
import sys import os current_dir = os.getcwd() sys.path.append(current_dir) from quantum_circuit import QuantumCircuit # import qiskit.providers.fake_provider from qiskit.transpiler import CouplingMap import qiskit_ibm_runtime.fake_provider from Backend.backend import Backend class FakeBackend(Backend): ...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
1 + 1 a = 1 b = 0.5 a + b an_integer = 42 # Just an integer a_float = 0.1 # A non-integer number, up to a fixed precision a_boolean = True # A value that can be True or False a_string = '''just enclose text between two 's, or two "s, or do what we did for this string''' # Text none_of_the_above = None # The...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
#!/usr/bin/env python # coding: utf-8 # In[1]: from qiskit.test.ibmq_mock import mock_get_backend mock_get_backend('FakeVigo') # In[2]: from qiskit import IBMQ from qiskit.providers.ibmq.visualization import iplot_gate_map IBMQ.load_account() provider = IBMQ.get_provider(group='open', project...
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho
OJB-Quantum
%load_ext autoreload %autoreload 2 import qiskit_metal as metal from qiskit_metal import designs, draw from qiskit_metal import MetalGUI, Dict design = designs.DesignPlanar() design.overwrite_enabled = True gui = MetalGUI(design) from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket q1o...
https://github.com/1chooo/Quantum-Oracle
1chooo
from qiskit import QuantumCircuit import math from qiskit.quantum_info import Statevector qc = QuantumCircuit(3) qc.rx(math.pi/2, 0) qc.ry(math.pi/2, 1) qc.rz(math.pi/2, 2) qc.draw("mpl") state = Statevector.from_instruction(qc) state.draw('bloch')
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile from qiskit_aer import AerSimulator from qiskit.tools.visualization import plot_histogram import random circ = QuantumCircuit(40, 40) # Initialize with a Hadamard layer circ.h(range(40)) # Apply some random CNOT and T gates qubit_indices = [i for i in range(40)...
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 """ from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram from IPython.core.display import display print("Ch 4: Upside down quantum coin toss") print("--------------------------...
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/jwalaQ/my-qiskit-textbook-solutions
jwalaQ
from qiskit_textbook.widgets import plot_bloch_vector_spherical from math import pi,sqrt coords = [0,0,1] plot_bloch_vector_spherical(coords) coords = [pi,0,1] plot_bloch_vector_spherical(coords) coords = [pi/2,0,1] plot_bloch_vector_spherical(coords) coords = [pi/2,-pi/2,1] plot_bloch_vector_spherical...
https://github.com/xtophe388/QISKIT
xtophe388
import sys, time, getpass try: sys.path.append("../../") # go to parent dir import Qconfig qx_config = { "APItoken": Qconfig.APItoken, "url": Qconfig.config['url']} print('Qconfig loaded from %s.' % Qconfig.__file__) except: APItoken = getpass.getpass('Please input your toke...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.utils import algorithm_globals algorithm_globals.random_seed = 42 from qiskit.circuit import Parameter from qiskit import QuantumCircuit params1 = [Parameter("input1"), Parameter("weight1")] qc1 = QuantumCircuit(1) qc1.h(0) qc1.ry(params1[0], 0) qc1.rx(params1[1], 0) qc1.draw("mpl") from q...
https://github.com/AsishMandoi/VRP-explorations
AsishMandoi
import numpy as np import pandas as pd class Initializer: def __init__(self, n, a, b): self.n = n self.a = a self.b = b def generate_nodes_and_weight_matrix(self): n = self.n a = self.a b = self.b np.random.seed(100*a + b) ...
https://github.com/biswaroopmukherjee/Quantum-Waddle
biswaroopmukherjee
# Practical Implementation of a Quantum String Matching Algorithm # S. Faro, F.P. Marino, and A. Scardace # QUASAR 2024 %%capture !pip install ibm-cloud-sdk-core==3.18.2 !pip install qiskit==0.45.1 !pip install qiskit-aer==0.13.1 !pip install pylatexenc==2.10 from numpy import log2, sqrt from numpy import ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import the drawing methods from matplotlib.pyplot import plot, figure # draw a figure figure(figsize=(6,6), dpi=60) # draw the origin plot(0,0,'ro') # a point in red color # draw the quantum states as points (in blue color) plot(1,0,'bo') plot(0,1,'bo') plot(-1,0,'bo') plot(0,-1,'bo') # import the ...
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/bayesian-randomized-benchmarking/qiskit-advocates-bayes-RB
bayesian-randomized-benchmarking
#Import general libraries (needed for functions) import numpy as np import matplotlib.pyplot as plt from IPython import display #Import Qiskit classes import qiskit from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors.standard_errors import depolarizing_error, thermal_relaxa...
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/qiskit-community/qiskit-translations-staging
qiskit-community
import json import matplotlib.pyplot as plt import numpy as np from IPython.display import clear_output from qiskit import QuantumCircuit from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit import ParameterVector from qiskit.circuit.library import ZFeatureMap from qiskit.quantum_info import Spar...
https://github.com/tushdon2/Qiskit_Hackathon_IITR_2021
tushdon2
from qiskit import execute, QuantumCircuit from qiskit.providers.aer import QasmSimulator # Import from Qiskit Aer noise module from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise import pauli_error import warnings warnings.filterwarnings('ignore') def get_noise(): # Er...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
import os import sys cwd = os.getcwd() qiskit_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(cwd)))) sys.path.append(qiskit_dir) from qiskit import IBMQ from qiskit.tools.jupyter import * IBMQ.load_account() %qiskit_backend_overview
https://github.com/abbarreto/qiskit3
abbarreto
import sympy from sympy import * import numpy as np from numpy import random import math import scipy init_printing(use_unicode=True) from matplotlib import pyplot as plt %matplotlib inline from sympy.physics.quantum.dagger import Dagger from sympy.physics.quantum import TensorProduct as tp from mpmath impor...
https://github.com/WhenTheyCry96/qiskitHackathon2022
WhenTheyCry96
%load_ext autoreload %autoreload 2 import os import warnings import numpy as np import pyEPR as epr import qiskit_metal as metal from collections import OrderedDict import scqubits as scq from scipy.constants import c, h, pi, hbar, e from qiskit_metal import designs, draw, MetalGUI, Dict, Headings from qis...
https://github.com/OccumRazor/implement-quantum-algotirhms-with-qiskit
OccumRazor
from qiskit import * from qiskit.circuit.library.standard_gates import SwapGate,CU1Gate,XGate,U1Gate from math import pi,sqrt from qiskit.quantum_info.operators import Operator import numpy as np def ini(circ,qr,ipt): # Input binary form, and append [0] ahead for qr1 block. for i in range(len(ipt)): ...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/Pitt-JonesLab/mirror-gates
Pitt-JonesLab
# TODO, show how different aggression configurations impact results from qiskit.transpiler import CouplingMap from mirror_gates.pass_managers import Mirage, QiskitLevel3 from transpile_benchy.metrics.abc_metrics import MetricInterface from transpile_benchy.metrics.gate_counts import DepthMetric from mirror_gates.u...
https://github.com/DRA-chaos/Quantum-Classical-Hyrid-Neural-Network-for-binary-image-classification-using-PyTorch-Qiskit-pipeline
DRA-chaos
!pip install qiskit import numpy as np import matplotlib.pyplot as plt import torch from torch.autograd import Function from torchvision import datasets, transforms import torch.optim as optim import torch.nn as nn import torch.nn.functional as F import qiskit from qiskit import transpile, assemble fro...
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/AlphaMiyaL/Qiskit-Quantum-Journey
AlphaMiyaL
%matplotlib inline #Imports from qiskit import QuantumCircuit, execute, Aer, IBMQ, ClassicalRegister, QuantumRegister from qiskit.compiler import transpile, assemble import numpy as np from qiskit.tools.jupyter import * from qiskit.visualization import * import json from qiskit.transpiler import PassManager fr...
https://github.com/Alice-Bob-SW/qiskit-alice-bob-provider
Alice-Bob-SW
''' qiskitpool/job.py Contains the QJob class ''' from functools import partial from qiskit import execute class QJob(): ''' QJob Job manager for asynch qiskit backends ''' def __init__(self, *args, qjob_id=None, **kwargs): ''' QJob.__init__ ...
https://github.com/ElePT/qiskit-algorithms-test
ElePT
# 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/UST-QuAntiL/nisq-analyzer-content
UST-QuAntiL
from typing import List from qiskit import QuantumCircuit, transpile, QuantumRegister, ClassicalRegister from qiskit import BasicAer,Aer,execute, IBMQ from qiskit.providers.aer import QasmSimulator from qiskit.circuit.library.arithmetic import DraperQFTAdder, RGQFTMultiplier from qiskit.circuit.library import Inte...
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 CustomStatePrep import StatePreparation from qiskit_aer.backends.a...
https://github.com/jonasmaziero/computacao_quantica_qiskit_sbf_2023
jonasmaziero
from sympy import Matrix X = Matrix([[0,1],[1,0]]); X Y = Matrix([[0,-1j],[1j,0]]); Y Z = Matrix([[1,0],[0,-1]]); Z X.eigenvals() X.eigenvects() Y.eigenvects() Z.eigenvects() from sympy import Matrix X = Matrix([[0,1],[1,0]]) ket0 = Matrix([[1],[0]]); ket1 = Matrix([[0],[1]]); ket0, ket1 X*ke...
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/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
%run init.ipynb from qiskit import * nshots = 8192 IBMQ.load_account() provider = IBMQ.get_provider(hub = 'ibm-q-research-2', group = 'federal-uni-sant-1', project = 'main') simulator = Aer.get_backend('qasm_simulator') device = provider.get_backend('ibm_nairobi') from qiskit.tools.visualization import plot_hi...
https://github.com/martian17/qiskit-graph-coloring-hamiltonian
martian17
import math from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, BasicAer from qiskit.visualization import plot_histogram # 4,0 -> 00 # 4,1 -> 01 # 4,2 -> 10 # 4,3 -> 11 # 4, 3 -> 11 # 2,3 -> 1,1 # 1,1 -> exit def genvec(veclen, n): vec = [] veclen = int(vecl...
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/feedback
Qiskit
# imports from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import PermutationGate from qiskit.transpiler.passes.synthesis.high_level_synthesis import ( HighLevelSynthesis, HighLevelSynthesisPluginManager, HighLevelSynthesisPlugin, HLSConfig, ) from qiskit.compiler i...
https://github.com/Pitt-JonesLab/clonk_transpilation
Pitt-JonesLab
import numpy as np from scipy.linalg import expm from qiskit.circuit.library import * S = expm( -1j * np.pi * (XGate().to_matrix() + YGate().to_matrix() + ZGate().to_matrix()) / np.sqrt(33) ) from qiskit.extensions.unitary import UnitaryGate from qiskit import QuantumCircuit S_gate = Un...
https://github.com/KMU-quantum-classroom/qiskit-classroom-converter
KMU-quantum-classroom
""" converter service """ # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Versio...
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 import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(1) cr = ClassicalRegister(1) qc = QuantumCircuit(qr, cr) qc.h(0) qc.measure(0, 0) qc.x(0).c_if(cr, 0) qc.measure(0, 0) qc.draw('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/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
# -*- 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/sebasmos/QuantumVE
sebasmos
import qiskit as q from qiskit import IBMQ %matplotlib inline IBMQ.save_account("5bd4ecfdc74e6680da7c79998259781431661e5326ae2f88eea95dee8f74b87530ba63fbca8105404de4ffd36e4b484631907acff73c805580928218a5ccf0b3") # Details in: https://qiskit.org/documentation/install.html # https://quantumcomputing.stackexchange...
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/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
#Import general libraries (needed for functions) import numpy as np import matplotlib.pyplot as plt #Import Qiskit classes classes import qiskit from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors.standard_errors import depolarizing_error, thermal_relaxation_error #Import...
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/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit from qiskit.circuit.library.arithmetic.piecewise_chebyshev import PiecewiseChebyshev f_x, degree, breakpoints, num_state_qubits = lambda x: np.arcsin(1 / x), 2, [2, 4], 2 pw_approximation = PiecewiseChebyshev(f_x, degree, breakpoints, num_state_qubits) pw_approx...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit # Create a circuit with a register of three qubits circ = QuantumCircuit(3) # H gate on qubit 0, putting this qubit in a superposition of |0> + |1>. circ.h(0) # A CX (CNOT) gate on control qubit 0 and target qubit 1 generating a Bell state. circ.cx(0, 1) # CX (CNOT) gate on cont...
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/hamburgerguy/Quantum-Algorithm-Implementations
hamburgerguy
"""Python implementation of Grovers algorithm through use of the Qiskit library to find the value 3 (|11>) out of four possible values.""" #import numpy and plot library import matplotlib.pyplot as plt import numpy as np # importing Qiskit from qiskit import IBMQ, Aer, QuantumCircuit, ClassicalRegister, Qu...
https://github.com/SaashaJoshi/IBM-Qiskit-Summer-School-2020
SaashaJoshi
#!/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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector from qiskit.visualization import plot_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) # plot using a Statevector state = Statevector(qc) plot_state_city(state)
https://github.com/Z-928/Bugs4Q
Z-928
from qiskit import Aer, QuantumCircuit, transpile from qiskit.circuit.library import PhaseEstimation qc= QuantumCircuit(3,3) # dummy unitary circuit unitary_circuit = QuantumCircuit(1) unitary_circuit.h(0) # QPE qc.append(PhaseEstimation(2, unitary_circuit), list(range(3))) qc.measure(list(range(3)), list(range...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile, schedule from qiskit.visualization.pulse_v2 import draw, IQXDebugging from qiskit.providers.fake_provider import FakeBoeblingen qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.measure_all() qc = transpile(qc, FakeBoeblingen(), layout_method='trivial') sched = schedu...
https://github.com/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/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
### Install Qiskit and relevant packages, if needed ### IMPORTANT: Make sure you are on 3.10 > python < 3.12 %pip install qiskit[visualization]==1.0.2 %pip install qiskit-ibm-runtime %pip install qiskit-aer %pip install graphviz %pip install qiskit-serverless -U %pip install qiskit-transpiler-service -U %pip in...
https://github.com/mareksubocz/QRBM-qiskit
mareksubocz
from qiskit import IBMQ # IBMQ.save_account(MY_API_TOKEN) import qiskit qiskit.__version__ import scipy import numpy as np import random from sklearn import preprocessing from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.quantum_info.operators import Operator from qiskit ...
https://github.com/sathayen/qiskit-docker
sathayen
# Creating quantum circuits from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister from qiskit import execute, Aer from qiskit.tools.visualization import circuit_drawer, plot_histogram qr = QuantumRegister(1) cr = ClassicalRegister(1) qc = QuantumCircuit(qr, cr) # Apply a single H gate qc....
https://github.com/chaitanya-bhargava/QiskitSolutions
chaitanya-bhargava
## Enter Team ID import os os.environ["TEAMID"] = "Excalibur" def get_min_swaps_line(N, controls, targets, connectivity_map): min_swaps = [] ### You code goes here length=len(controls) for i in range(length): if(targets[i] in connectivity_map[controls[i]]): min_swaps....
https://github.com/fedimser/quantum_decomp
fedimser
import quantum_decomp as qd from scipy.stats import unitary_group from collections import Counter import time for qubits_count in range(1,10): time_start = time.time() gates = qd.matrix_to_gates(unitary_group.rvs(2 ** qubits_count)) duration = time.time() - time_start total = len(gates) ...
https://github.com/CQCL/pytket-qiskit
CQCL
import qiskit from qiskit.dagcircuit import DAGCircuit from qiskit.providers import BaseBackend from qiskit.transpiler.basepasses import TransformationPass, BasePass from qiskit.converters import circuit_to_dag, dag_to_circuit from pytket._transform import Transform from pytket._routing import route, Architectu...
https://github.com/COFAlumni-USB/qiskit-fall-2022
COFAlumni-USB
import qiskit as qiskit import numpy as np import math from numpy import sqrt from random import randint from qiskit import * from qiskit import Aer, QuantumCircuit, IBMQ, execute, quantum_info from qiskit.visualization import plot_state_city, plot_bloch_multivector from qiskit.visualization import plot_histogr...
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] B1 = QuantumCircuit(2) # Apply h gate to the control qubit B1.h(0) #Applying the CNOT gate ...
https://github.com/quantum-kittens/quantum-computing-basics
quantum-kittens
# run this cell if you're executing this notebook in your browser !pip install qiskit from IPython.display import clear_output clear_output() from qiskit import * from qiskit import IBMQ # IBMQ.save_account('APITOKEN', overwrite=True) ## Uncomment and replace APITOKEN with your API token to save new crede...
https://github.com/Qubico-Hack/tutorials
Qubico-Hack
import matplotlib.pyplot as plt import numpy as np !pip install qiskit from qiskit.circuit.library import RealAmplitudes from qiskit.primitives import Sampler !pip install qiskit_algorithms from qiskit_algorithms.optimizers import COBYLA from qiskit_algorithms.utils import algorithm_globals from sklearn.model_s...
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...