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 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/ronitd2002/IBM-Quantum-challenge-2024
ronitd2002
# qc-grader should be 0.18.11 (or higher) import qc_grader qc_grader.__version__ # Import all in one cell import numpy as np import matplotlib.pyplot as plt from timeit import default_timer as timer import warnings from qiskit import QuantumCircuit from qiskit.transpiler.preset_passmanagers import gene...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) ### removed cx gate ### 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"...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# -*- coding: utf-8 -*- # This code is part of Qiskit. # # (C) Copyright IBM 2017. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # #...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.opflow import I, X, Y, Z print(I, X, Y, Z) print(1.5 * I) print(2.5 * X) print(X + 2.0 * Y) print(X^Y^Z) print(X @ Y @ Z) print((X + Y) @ (Y + Z)) print((X + Y) ^ (Y + Z)) (I, X) 2.0 * X^Y^Z print(1.1 * ((1.2 * X)^(Y + (1.3 * Z)))) from qiskit.opflow import (StateFn, Zero, On...
https://github.com/strangequarkkk/BB84-Protocol-for-QKD
strangequarkkk
import matplotlib as mpl import numpy as np import matplotlib.pyplot as plt from qiskit import QuantumCircuit, Aer, transpile, assemble from qiskit.visualization import plot_histogram, plot_bloch_multivector qc = QuantumCircuit(1,1) # Alice prepares qubit in state |+> qc.h(0) qc.barrier() # Alice now sends t...
https://github.com/ughyper3/grover-quantum-algorithm
ughyper3
import numpy as np import networkx as nx import qiskit from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, assemble from qiskit.quantum_info import Statevector from qiskit.aqua.algorithms import NumPyEigensolver from qiskit.quantum_info import Pauli from qiskit.aqua.operators...
https://github.com/0tt3r/QuaC-qiskit
0tt3r
# -*- coding: utf-8 -*- """In this example, two-qubit Bell states are generated using the plugin. Additionally, a Quac noise model is applied. """ import math import numpy as np import matplotlib.pyplot as plt from qiskit import QuantumCircuit, execute from qiskit.visualization import plot_histogram from qua...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
%run init.ipynb matplotlib.rcParams.update({'font.size':12}); plt.figure(figsize = (5,3), dpi = 100) p = np.arange(0,1.01,0.01) plt.plot(p, p, label = r'$p$'); plt.plot(p, 3*p**2-2*p**3, label = r'$p_{e}$') plt.xlim(0,1); plt.ylim(-0.01,1.01); plt.legend(); plt.xlabel('p'); plt.show() from qiskit import * def...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver( atom="H 0 0 0; H 0 0 0.72" # Two Hydrogen atoms, 0.72 Angstrom apart ) molecule = driver.run() from qiskit_nature.second_q.mappers import QubitConverter, ParityMapper qubit_converter = QubitConverter(ParityMapper()) hamiltonian =...
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/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/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/unitaryfund/mitiq
unitaryfund
# Copyright (C) Unitary Fund # # This source code is licensed under the GPL license (v3) found in the # LICENSE file in the root directory of this source tree. """Unit tests for zero-noise extrapolation.""" import functools from typing import List import cirq import numpy as np import pytest import qisk...
https://github.com/GabrielPontolillo/QiskitPBT
GabrielPontolillo
from argparse import ArgumentParser, Namespace, BooleanOptionalAction from qiskit import QuantumCircuit as qc from qiskit import QuantumRegister as qr from qiskit import transpile from qiskit_aer import AerSimulator from qiskit.result import Counts from matplotlib.pyplot import show, subplots, xticks, yticks fro...
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/Qiskit/feedback
Qiskit
from qiskit import * q = QuantumRegister(3,'q') c = ClassicalRegister(2,'c') q1 = QuantumRegister(4,'q1') c1 = ClassicalRegister(2,'c1') res = ClassicalRegister(1,'r') backend = Aer.get_backend('qasm_simulator') qc = QuantumCircuit(q,c,res) qc.x([0,1]) qc.measure([0,1],[0,1]) qc.h(2).c_if([c[0],c[1]],3)...
https://github.com/qiskit-community/qiskit-device-benchmarking
qiskit-community
# This code is part of Qiskit. # # (C) Copyright IBM 2024. # # 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/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 from qiskit.circuit.library.standard_gates import RXGate, RZGate, RYGate, CXGate, CZGate, SGate, HGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister import numpy as np def get_linear_entangelment_ansatz(num_of_qubits, thetas, input_state, circuit_dep...
https://github.com/noamsgl/IBMAscolaChallenge
noamsgl
# %load imports.py import matplotlib.pyplot as plt import pandas as pd import seaborn as sns import numpy as np import ipywidgets as widgets widgets.IntSlider() widgets.FloatSlider() widgets.FloatLogSlider() widgets.IntRangeSlider() widgets.FloatRangeSlider() widgets.IntProgress(75) widgets.Fl...
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/IceKhan13/purplecaffeine
IceKhan13
# 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/helenup/Quantum-Euclidean-Distance
helenup
# import the necessary libraries import math as m from qiskit import * from qiskit import BasicAer from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute # First step is to encode the data into quantum states. #There are some techniques to do it, in this case Amplitude embedding was us...
https://github.com/apozas/qaoa-color
apozas
from functools import reduce from itertools import product from qiskit import BasicAer, QuantumRegister from qiskit_aqua import QuantumInstance from qiskit_aqua import Operator, run_algorithm from qiskit.quantum_info import Pauli from qiskit_aqua.components.optimizers import COBYLA from constrainedqaoa impor...
https://github.com/Pitt-JonesLab/mirror-gates
Pitt-JonesLab
from transpile_benchy.metrics.gate_counts import ( DepthMetric, TotalMetric, TotalSwaps, ) from qiskit.circuit.library import iSwapGate from qiskit.transpiler import CouplingMap from mirror_gates.pass_managers import Mirage, QiskitLevel3 from mirror_gates.utilities import SubsMetric from mirror_gat...
https://github.com/TheClintest/QuantumMedianFilter
TheClintest
from QMF import * filename = "lena.png" #Trasformazione in array img_array = Converter.to_array(filename) #Processo... #Trasformazione in immagine Converter.to_image(img_array, "nuova_immagine.png") patcher = ImagePatcher() patcher.load_image(img_array) # Caricamento/Processing patches = patcher.get_...
https://github.com/tomtuamnuq/compare-qiskit-ocean
tomtuamnuq
import dimod import neal import numpy as np from dwave.system import DWaveSampler, EmbeddingComposite, DWaveCliqueSampler A_int = np.array([[0,1,2,3,4,1], [2,1,4,1,0,2], [1,5,2,3,1,1]]) m, n = A_int.shape vartype = dimod.Vartype.BINARY c_int = np.array([1,2,1,-3,1,-1]) b = np.arr...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
%run qlatvia.py draw_qubit() sqrttwo=2**0.5 draw_quantum_state(1,0,"") draw_quantum_state(1/sqrttwo,1/sqrttwo,"|+>") # drawing the angle with |0>-axis from matplotlib.pyplot import gca, text from matplotlib.patches import Arc gca().add_patch( Arc((0,0),0.4,0.4,angle=0,theta1=0,theta2=45) ) text(0.08,...
https://github.com/carstenblank/dc-qiskit-qml
carstenblank
# -*- coding: utf-8 -*- # 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 app...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
from qiskit import * from qiskit.tools.visualization import plot_histogram import numpy as np def NOT(input): q = QuantumRegister(1) # a qubit in which to encode and manipulate the input c = ClassicalRegister(1) # a bit to store the output qc = QuantumCircuit(q, c) # this is where the quantum prog...
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/vandnaChaturvedi/Qauntum_algorithms_Qiskit
vandnaChaturvedi
import numpy as np import qiskit from qiskit import QuantumCircuit import matplotlib.pyplot as plt from qiskit.circuit import QuantumCircuit, Parameter import warnings warnings.filterwarnings('ignore') theta = Parameter("θ") phi = Parameter("φ") lamb = Parameter("λ") def sampleCircuitA(layer=1, qubits...
https://github.com/Pitt-JonesLab/mirror-gates
Pitt-JonesLab
from qiskit.transpiler import CouplingMap from mirror_gates.pass_managers import Mirage, QiskitLevel3 from mirror_gates.logging import transpile_benchy_logger from transpile_benchy.library import CircuitLibrary library = CircuitLibrary.from_txt("../../circuits/iters_select.txt") coupling_map = CouplingMap.fr...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, execute from qiskit.providers.fake_provider import FakeVigoV2 from qiskit.visualization import plot_gate_map backend = FakeVigoV2() plot_gate_map(backend)
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2018, 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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile, schedule from qiskit.visualization.timeline import draw 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/arian-code/nptel_quantum_assignments
arian-code
import numpy as np #Option A p1=np.matrix([[0, 1],[-1, 0]]) print (p1) print (p1.getH()) if (p1==p1.getH()).all(): print ("It is hermitian") else: print ("It is not hermitian") #Option B p1=np.matrix([[0, 0+1j],[0-1j, 0]]) print (p1) print (p1.getH()) if (p1==p1.getH()).all(): print ("It i...
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/PaulaGarciaMolina/QNLP_Qiskit_Hackathon
PaulaGarciaMolina
import numpy as np import pickle import qiskit qiskit.__qiskit_version__ from discopy import Ty, Word # Import the classes for the type of word and for the word s, n = Ty('s'), Ty('n') # Define the types s and n # Define the words (notice that we include both meaning and grammar) # nouns man, woman, k...
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
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/mnp-club/Quantum_Computing_Workshop_2020
mnp-club
%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 * import numpy as np from fractions import Fraction as frac ...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qiskit import execute # Choose the drawer you like best: from qiskit.tools.visualization import matplotlib_circuit_drawer as draw #from qiskit.tools.visualization import circuit_drawer as draw from qiskit import IBMQ IBMQ.load_accounts...
https://github.com/abhishekchak52/quantum-computing-course
abhishekchak52
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/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or deriv...
https://github.com/JavaFXpert/quantum-circuit-pygame
JavaFXpert
#!/usr/bin/env python # # Copyright 2019 the original author or authors. # # 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 # # Unle...
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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/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 * import numpy as np qc = QuantumCircuit(2,2) qc.draw('mpl') qreg = QuantumRegister(2, name = 'qreg') creg = ClassicalRegister(2, name = 'cr...
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 from qiskit.aqua.components.optimizers import COBYLA, SPSA from qiskit.circuit.library import TwoLocal # VOLTA from volta.vqd import VQD from volta.utils import ...
https://github.com/Qiskit/qiskit-transpiler-service
Qiskit
# Install the plugin # !pip install -e . from qiskit.transpiler import PassManager from qiskit_transpiler_service.ai.routing import AIRouting from qiskit.circuit.library import EfficientSU2 circuit = EfficientSU2(100, entanglement="circular", reps=1).decompose() print( f"Original circuit -> Depth: {circu...
https://github.com/maximusron/qgss_2021_labs
maximusron
from qiskit.circuit.library import RealAmplitudes ansatz = RealAmplitudes(num_qubits=2, reps=1, entanglement='linear') ansatz.draw('mpl', style='iqx') from qiskit.opflow import Z, I hamiltonian = Z ^ Z from qiskit.opflow import StateFn expectation = StateFn(hamiltonian, is_measurement=True) @ StateFn(an...
https://github.com/carstenblank/dc-qiskit-qml
carstenblank
# -*- coding: utf-8 -*- # 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 app...
https://github.com/biswaroopmukherjee/Quantum-Waddle
biswaroopmukherjee
import qiskit from qiskit import IBMQ from qiskit.tools.monitor import job_monitor IBMQ.load_account() IBMQ.providers() provider = IBMQ.get_provider(group='open') #check open servers import numpy as np import time import networkx as nx import matplotlib.pyplot as plt import random from qiskit import (Quant...
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/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
import unittest import hypothesis.strategies as st from hypothesis import given, settings, note import matplotlib.pyplot as plt import numpy as np import math from qiskit import QuantumCircuit, Aer, transpile, assemble, execute from qiskit.visualization import plot_histogram from qiskit.circuit.library impo...
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 pickle import time import datetime # Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z) from qiskit.opflow import ...
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/1chooo/Quantum-Oracle
1chooo
# %% [markdown] # # 第4章原始程式碼 # %% #Program 4.1 Apply CX-gate to qubit from qiskit import QuantumCircuit qc = QuantumCircuit(2) qc.cx(0,1) qc.draw('mpl') # %% #Program 4.2 Show unitary matrix of CX-gate (MSB as target bit) from qiskit import QuantumCircuit, Aer from qiskit.visualization import array_to_la...
https://github.com/mmetcalf14/Hamiltonian_Downfolding_IBM
mmetcalf14
# -*- coding: utf-8 -*- # 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. # #...
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/danieljaffe/quantum-algorithms-qiskit
danieljaffe
"""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/yaelbh/qiskit-projectq-provider
yaelbh
# -*- coding: utf-8 -*- # Copyright 2018, IBM. # # This source code is licensed under the Apache License, Version 2.0 found in # the LICENSE.txt file in the root directory of this source tree. # pylint: disable=invalid-name,missing-docstring,broad-except,no-member from test._random_circuit_generator import ...
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/quantumyatra/quantum_computing
quantumyatra
import numpy as np from numpy import pi # importing Qiskit from qiskit import QuantumCircuit, transpile, assemble, Aer from qiskit.visualization import plot_histogram, plot_bloch_multivector qc = QuantumCircuit(3) qc.h(2) qc.cp(pi/2, 1, 2) qc.cp(pi/4, 0, 2) qc.h(1) qc.cp(pi/2, 0, 1) qc.h(0) qc.swap(0, 2) ...
https://github.com/arnavdas88/QuGlassyIsing
arnavdas88
!pip install qiskit J = 4.0 B_x = 2.0 B_z = 1.0 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, Q...
https://github.com/Manish-Sudhir/QiskitCheck
Manish-Sudhir
import warnings from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, execute, Aer, transpile, IBMQ from qiskit.tools.monitor import job_monitor from qiskit.circuit.library import QFT from qiskit.visualization import plot_bloch_multivector, plot_histogram, array_to_latex warning...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools from pprint import pprint import pickle # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts import time import datetime # Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z) from qiskit.opflow import ...
https://github.com/pedroripper/qiskit_tutoriais
pedroripper
from qiskit import * %matplotlib inline import numpy as np qc = QuantumCircuit(2,2) qc.h(0) qc.cx(0,1) qc.measure([0,1],[0,1]) qc.draw(output='mpl') backend = Aer.get_backend('qasm_simulator') result = execute(qc,backend).result() from qiskit.tools.visualization import plot_histogram plot_histogram(r...
https://github.com/Pitt-JonesLab/mirror-gates
Pitt-JonesLab
"""Add custom gates to the session EquivalenceLibrary instance. NOTE: sel is global, so just import this file before calling transpile. """ import numpy as np from qiskit import QuantumCircuit from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel from qiskit.circuit.library.standard_...
https://github.com/AnikenC/JaxifiedQiskit
AnikenC
# All Imports import numpy as np import jax import jax.numpy as jnp from jax.numpy.linalg import norm import qiskit.pulse as pulse from qiskit_dynamics.array import Array from library.utils import PauliToQuditOperator, TwoQuditHamiltonian from library.new_sims import JaxedSolver Array.set_default_bac...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
https://github.com/JohnBurke4/qaoa_testing_framework
JohnBurke4
from qiskit import QuantumCircuit from qiskit.circuit import Parameter import numpy as np import random class CostHamiltonian: circuit = {} def __init__(self, numQubits, layers=1, costType='maxcut', problem=None): self.numQubits = numQubits self.costType = costType self.la...
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/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/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.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/krishphys/LiH_Variational_quantum_eigensolver
krishphys
from qiskit import BasicAer, Aer, IBMQ from qiskit.aqua import QuantumInstance, aqua_globals from qiskit.aqua.algorithms import VQE, ExactEigensolver from qiskit.aqua.components.initial_states import Zero from qiskit.aqua.components.optimizers import COBYLA, L_BFGS_B, SLSQP, SPSA from qiskit.aqua.components.variat...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or deriv...
https://github.com/rmlarose/qcbq
rmlarose
"""Imports for the notebook.""" import matplotlib.pyplot as plt import numpy as np from scipy.optimize import minimize import qiskit """Defining circuits with parameters.""" # Get a circuit and registers qreg = qiskit.QuantumRegister(2) creg = qiskit.ClassicalRegister(2) circ = qiskit.QuantumCircuit(qreg, ...
https://github.com/Tim-Li/Qiskit-NTU-hackathon-2022_QGEN
Tim-Li
import numpy as np import matplotlib.pyplot as plt # Importing standard Qiskit libraries from qiskit import QuantumCircuit, transpile, Aer, IBMQ from qiskit.tools.jupyter import * from qiskit.visualization import * # from ibm_quantum_widgetsets import * from qiskit.providers.aer import QasmSimulator from qisk...
https://github.com/Qiskit/feedback
Qiskit
from qiskit import QuantumCircuit, transpile, schedule, IBMQ from qiskit.transpiler import PassManager import numpy as np IBMQ.load_account() provider = IBMQ.get_provider(hub='ibm-q-internal', group='deployed', project='default') backend = provider.get_backend('ibm_lagos') %matplotlib inline %config Inli...
https://github.com/arnaucasau/Quantum-Computing-3SAT
arnaucasau
# imports import math # importing Qiskit from qiskit import QuantumCircuit, Aer, assemble, transpile from qiskit_aer import AerSimulator from qiskit.visualization import plot_histogram f = open("cnf_test2.txt") info = f.readline().split(' ') n_var = int(info[0]) n_clause = int(info[1]) lines = [line.rst...
https://github.com/anpaschool/quantum-computing
anpaschool
from qiskit import * from math import pi import numpy as np from qiskit.visualization import plot_bloch_multivector,plot_state_qsphere import matplotlib.pyplot as plt q = np.array([1.+0.j, 0.+0.j]) plot_bloch_multivector(q) plot_state_qsphere(q) q = np.array([0.+0.j, 1.+0.j]) plot_bloch_multivector(q) ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
%matplotlib inline from qiskit_finance import QiskitFinanceError from qiskit_finance.data_providers import * import datetime import matplotlib.pyplot as plt from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() data = RandomDataProvider( tickers=["TICKER1", "TICKER2...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
#Assign these values as per your requirements. global min_qubits,max_qubits,skip_qubits,max_circuits,num_shots,Noise_Inclusion min_qubits=1 max_qubits=3 skip_qubits=1 max_circuits=3 num_shots=1000 use_XX_YY_ZZ_gates = True Noise_Inclusion = False saveplots = False Memory_utilization_plot = True Type_...
https://github.com/Alice-Bob-SW/qiskit-alice-bob-provider
Alice-Bob-SW
############################################################################## # Copyright 2023 Alice & Bob # # 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://w...
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/alexyev/Grover-s_Algorithm
alexyev
import matplotlib.pyplot as plt import numpy as np !pip install qiskit from qiskit import IBMQ, Aer, assemble, transpile, execute from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qiskit.providers.ibmq import least_busy !pip install qiskit.visualization from qiskit.visualization import *...
https://github.com/duartefrazao/Quantum-Finance-Algorithms
duartefrazao
from qiskit import Aer from qiskit.circuit.library import TwoLocal from qiskit.aqua import QuantumInstance from qiskit.optimization.applications.ising.common import sample_most_likely from qiskit.aqua.algorithms import VQE, QAOA, NumPyMinimumEigensolver from qiskit.aqua.components.optimizers import COBYLA from au...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.units import DistanceUnit from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver( atom="H 0 0 0; H 0 0 0.735", basis="sto3g", charge=0, spin=0, unit=DistanceUnit.ANGSTROM, ) es_problem = driver.run() from qiskit_nature.second_q.mappers import J...
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/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2023 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or deriva...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
import numpy as np N = 10**7; d = np.arange(2,N+1,1); dl = np.zeros(len(d)); nv = np.zeros(len(d)) n = 1 for j in range(2,len(d)): nv[j] = n dl[j] = 2**n if d[j] >= dl[j]: n += 1 from matplotlib import pyplot as plt plt.plot(d,d, label=r'$d$') plt.plot(d,dl, label=r'$dl$') plt.xlabel(r'...
https://github.com/osamarais/qiskit_iterative_solver
osamarais
import qiskit from qiskit import QuantumCircuit, QuantumRegister from qiskit.extensions import UnitaryGate import numpy as np from scipy.linalg import fractional_matrix_power from scipy.io import loadmat from copy import deepcopy # problem = 'lower triangular' # problem = 'lower triangular identit...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 2023 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or deriva...
https://github.com/apcarrik/qiskit-dev
apcarrik
''' helloworld.py This file is intended as a simple template for qiskit files. The code can be found at: https://qiskit.org/documentation/intro_tutorial1.html ''' ### 1. Import Packages import numpy as np from matplotlib import pyplot from qiskit import QuantumCircuit, transpile # instructions of quantum ...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile ghz = QuantumCircuit(15) ghz.h(0) ghz.cx(0, range(1, 15)) ghz.draw(output='mpl')