repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt 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 QuantumCircuit, QuantumRegister, ClassicalRegister...
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/jdanielescanez/quantum-solver
jdanielescanez
#!/usr/bin/env python3 # Author: Daniel Escanez-Exposito from qiskit import execute, QuantumCircuit, QuantumRegister, ClassicalRegister from crypto.e91.sender import Sender from crypto.e91.receiver import Receiver from crypto.e91.eavesdropper import Eveasdropper import binascii E91_SIMULATOR = 'E91 SIMULAT...
https://github.com/kaelynj/Qiskit-HubbardModel
kaelynj
#Jupyter notebook to check if imports work correctly %matplotlib inline import sys sys.path.append('./src') import HubbardEvolutionChain as hc import ClassicalHubbardEvolutionChain as chc from qiskit import QuantumCircuit, execute, Aer, IBMQ, BasicAer, QuantumRegister, ClassicalRegister from qiskit.compiler impo...
https://github.com/rickapocalypse/final_paper_qiskit_sat
rickapocalypse
from qiskit import * import matplotlib.pyplot as plt from qiskit.circuit import QuantumCircuit from qiskit.tools.visualization import plot_histogram from qiskit.tools.monitor import job_monitor qc = QuantumCircuit(2,2) # Bell Gate bell = QuantumCircuit(2) bell.h(0) bell.cx(0,1) bell.to_gate() bell.name =...
https://github.com/UST-QuAntiL/nisq-analyzer-content
UST-QuAntiL
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit # https://quantum-circuit.com/app_details/about/bw5r9HTiTHvQHtCB5 qc = QuantumCircuit() q = QuantumRegister(5, 'q') c = ClassicalRegister(3, 'c') qc.add_register(q) qc.add_register(c) qc.h(q[0]) qc.h(q[1]) qc.h(q...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/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/hamburgerguy/Quantum-Algorithm-Implementations
hamburgerguy
"""Qiskit code for running Simon's algorithm on quantum hardware for 2 qubits and b = '11' """ # importing Qiskit from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, execute # import basic plot tools from qiskit.visualization import plot_histogram ...
https://github.com/matteoacrossi/oqs-jupyterbook
matteoacrossi
############################# # Pauli channel on IBMQX2 # ############################# from qiskit import QuantumRegister, QuantumCircuit # Quantum register q = QuantumRegister(5, name="q") # Quantum circuit pauli = QuantumCircuit(q) # Pauli channel acting on q_2 ## Qubit identification system = 2 ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.dagcircuit import DAGCircuit from qiskit.converters import circuit_to_dag from qiskit.circuit.library.standard_gates import CHGate, U2Gate, CXGate from qiskit.converters import dag_to_circuit q = QuantumRegister(3, 'q') c = Classi...
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/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/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt import numpy as np from qiskit.circuit import ParameterVector from qiskit.circuit.library import TwoLocal from qiskit.quantum_info import Statevector from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler from qi...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.dagcircuit import DAGCircuit from qiskit.converters import circuit_to_dag from qiskit.visualization import dag_drawer q = QuantumRegister(3, 'q') c = ClassicalRegister(3, 'c') circ = QuantumCircuit(q, c) circ.h(q[0]) circ.cx(q[0...
https://github.com/drithidavuluri/Implementation-of-Algorithm-using-Qiskit
drithidavuluri
import qiskit.quantum_info as qi #this is used to do calculations from qiskit.circuit.library import FourierChecking from qiskit.visualization import plot_histogram f=[1,-1,-1,-1] g=[1,1,-1,-1] circuit = FourierChecking(f=f,g=g) circuit.draw() zero = qi.Statevector.from_label('00') sv = zero.evolve(circui...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# let's randomly pick a number between 0 and 9, and print its value if it is greater than 5 from random import randrange r = randrange(10) if r > 5: print(r) # when the condition (r > 5) is valid/true, the code (print(r)) will be executed # you may need to execute your code more than once to see an outcome #...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector qc = QuantumCircuit(2) qc.h(0) qc.x(1) # You can reverse the order of the qubits. from qiskit.quantum_info import DensityMatrix qc = QuantumCircuit(2) qc.h([0, 1]) qc.t...
https://github.com/acfilok96/Quantum-Computation
acfilok96
from qiskit import * from qiskit.tools.visualization import plot_bloch_multivector circuit = QuantumCircuit(1,1) circuit.x(0) simulator = Aer.get_backend('statevector_simulator') result = execute(circuit, backend=simulator).result() statevector = result.get_statevector() print(statevector) %matplotlib inlin...
https://github.com/nahumsa/Introduction-to-IBM_Qiskit
nahumsa
# initialization import numpy as np # importing Qiskit from qiskit import IBMQ, Aer from qiskit import QuantumCircuit, transpile # import basic plot tools from qiskit.visualization import plot_histogram # set the length of the n-bit input string. n = 3 # Constant Oracle const_oracle = QuantumCircui...
https://github.com/Interlin-q/diskit
Interlin-q
from qiskit import BasicAer from qiskit.aqua import QuantumInstance from qiskit.aqua.algorithms import Shor N = 15 shor = Shor(N) backend = BasicAer.get_backend('qasm_simulator') quantum_instance = QuantumInstance(backend, shots=1024) ret = shor.run(quantum_instance) print("The list of factors of {} as comput...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or...
https://github.com/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/qiskit-community/qiskit-translations-staging
qiskit-community
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, L_BFGS_B from qiskit.circuit import Parameter from qiskit.circuit.library import RealAmplitudes, ZZFeatureMap from qiskit.utils import alg...
https://github.com/Qottmann/Quantum-anomaly-detection
Qottmann
import sys sys.path.insert(1, '..') # sets the path to the parent folder, where the notebook was originally executed import time import datetime import numpy as np from matplotlib import pyplot as plt import qiskit from qiskit import * from qiskit.opflow import X,Z,I from qiskit.opflow.state_fns import S...
https://github.com/qclib/qclib
qclib
# Copyright 2021 qclib project. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in w...
https://github.com/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": #...
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/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
from random import randrange r = randrange(10,51) if r % 2 ==0: print(r,"is even") else: print(r,"is odd") from random import randrange for N in [100,1000,10000,100000]: first_half=second_half=0 for i in range(N): r = randrange(100) if r<50: first_half = first_half...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018, 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 modificati...
https://github.com/qiskit-community/qiskit-dell-runtime
qiskit-community
# This code is part of qiskit-runtime. # # (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 ...
https://github.com/Brogis1/2020_SCS_Qiskit_Workshop
Brogis1
import numpy as np from qiskit import __qiskit_version__ from qiskit.chemistry.drivers import PySCFDriver, PyQuanteDriver, UnitsType from qiskit.chemistry import FermionicOperator from qiskit.aqua.algorithms import VQE, ExactEigensolver from qiskit.chemistry.components.variational_forms import UCCSD from qiskit.c...
https://github.com/harshagarine/QISKIT_INDIA_CHALLENGE
harshagarine
### WRITE YOUR CODE BETWEEN THESE LINES - START # import libraries that are used in the function below. from qiskit import QuantumCircuit import numpy as np from math import sqrt, pi ### WRITE YOUR CODE BETWEEN THESE LINES - END def build_state(): circuit = QuantumCircuit(1) i...
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/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import QuantumCircuit from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler from qiskit_finance.circuit.library import NormalDistribution # can be used in case a...
https://github.com/swe-train/qiskit__qiskit
swe-train
# This code is part of Qiskit. # # (C) Copyright IBM 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/BoxiLi/qiskit-CR-calibration
BoxiLi
""" Generation of echoed and direct CNOT gate based on calibrated CR pulse data. """ from copy import deepcopy import numpy as np from numpy import pi from scipy.signal import find_peaks import matplotlib.pyplot as plt from scipy.optimize import curve_fit import qiskit from qiskit import pulse, circuit,...
https://github.com/mattalcasabas/quantum-shors-algorithm
mattalcasabas
import matplotlib.pyplot as plt import numpy as np from qiskit import QuantumCircuit, Aer, execute from math import gcd import pandas as pd from qiskit.visualization import plot_histogram
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) ### added y gate ### qc.cx(0, 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 ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# External imports from pylab import cm from sklearn import metrics import numpy as np import matplotlib.pyplot as plt # Qiskit imports from qiskit import QuantumCircuit from qiskit.circuit import ParameterVector from qiskit.visualization import circuit_drawer from qiskit.algorithms.optimizers import SPSA f...
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/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/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/abbarreto/qiskit3
abbarreto
https://github.com/DRA-chaos/Quantum-Classical-Hyrid-Neural-Network-for-binary-image-classification-using-PyTorch-Qiskit-pipeline
DRA-chaos
!pip install qiskit # check if CUDA is available import torch train_on_gpu = torch.cuda.is_available() if not train_on_gpu: print('CUDA is not available. Training on CPU ...') else: print('CUDA is available! Training on GPU ...') import numpy as np import matplotlib.pyplot as plt import to...
https://github.com/luis6156/Shor-s-Quantum-Algorithm
luis6156
from qiskit import QuantumCircuit, Aer, execute, IBMQ from qiskit.utils import QuantumInstance import numpy as np from qiskit.algorithms import Shor IBMQ.enable_account('ENTER API TOKEN HERE') # Enter your API token here provider = IBMQ.get_provider(hub='ibm-q') backend = Aer.get_backend('qasm_simulator') qu...
https://github.com/arian-code/nptel_quantum_assignments
arian-code
from sympy import * from sympy.physics.quantum.state import Ket, Bra from sympy.physics.quantum import TensorProduct import numpy as np init_printing(use_unicode=True) #One Q bit gates H=Matrix([[1/sqrt(2), 1/sqrt(2)],[1/sqrt(2), -1/sqrt(2)]]) S=Matrix([[0, 1],[1, I]]) X=Matrix([[0, 1],[1, 0]]) Y=Matrix([[0,...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
# import the drawing methods from matplotlib.pyplot import plot, figure, show # draw a figure figure(figsize=(6,6), dpi=80) # include our predefined functions %run qlatvia.py # draw the axes draw_axes() # draw the origin plot(0,0,'ro') # a point in red color # draw these quantum states as points (in...
https://github.com/neelkamath/quantum-experiments
neelkamath
from qiskit import * from qiskit.tools.visualization import plot_histogram %matplotlib inline secretnumber = '11100011' circuit = QuantumCircuit(len(secretnumber)+1,len(secretnumber)) circuit.h(range(len(secretnumber))) circuit.x(len(secretnumber)) circuit.h(len(secretnumber)) circuit.barrier() for i...
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/abbarreto/qiskit4
abbarreto
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import * from qiskit.visualization import plot_histogram # quantum circuit to make a Bell state bell = QuantumCircuit(2, 2) bell.h(0) bell.cx(0, 1) meas = QuantumCircuit(2, 2) meas.measure([0,1], [0,1]) # execute the quantum circuit backend = BasicAer.get_backend('qasm_simulator') # the dev...
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/nickk124/quantumsearch
nickk124
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 27 12:07:22 2020 @author: ericyelton """ #Imports import numpy as np from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit,execute, Aer # gates/operators from qiskit.quantum_info.operators import Operator from qiskit....
https://github.com/qiskit-community/prototype-zne
qiskit-community
# 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_nature.circuit.library import UCCSD ansatz = UCCSD() ansatz.num_spin_orbitals = 10 from qiskit_nature.second_q.circuit.library import UCCSD ansatz = UCCSD() ansatz.num_spatial_orbitals = 5 from qiskit_nature.circuit.library import UCC, UVCC ucc = UCC(qubit_converter=None, num_particles=None...
https://github.com/martynscn/Masters-Thesis-on-Quantum-Cryptography
martynscn
# This code has been adapted and modified from IBM Qiskit 2021 and also from https://github.com/ttlion/ShorAlgQiskit. # It uses the implementation as contained in the work of Stephane Beauregard (https://arxiv.org/abs/quant-ph/0205095) # Many thanks to IBM Qiskit team, Tiago Miguel (ttlion), Qubit by Qubit, Peter Sho...
https://github.com/usamisaori/Grover
usamisaori
import qiskit from qiskit import QuantumCircuit from qiskit.visualization import plot_histogram from qiskit.quantum_info import Operator import numpy as np from qiskit import execute, Aer simulator = Aer.get_backend('qasm_simulator') import matplotlib.pyplot as plt import warnings warnings.filterwarn...
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/IvanIsCoding/Quantum
IvanIsCoding
%matplotlib inline from qiskit import * from qiskit.visualization import plot_histogram circuit = QuantumCircuit(2) circuit.x(0) circuit.z(1) circuit.draw(output="mpl") unitary_simulator = Aer.get_backend("unitary_simulator") unitary = execute(circuit, backend=unitary_simulator).result().get_unitary() prin...
https://github.com/chunfuchen/qiskit-chemistry
chunfuchen
# -*- 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/qiskit-community/qiskit-translations-staging
qiskit-community
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, L_BFGS_B from qiskit.circuit import Parameter from qiskit.circuit.library import RealAmplitudes, ZZFeatureMap from qiskit.utils import alg...
https://github.com/ColibrITD-SAS/mpqp
ColibrITD-SAS
from mpqp import QCircuit from mpqp.gates import H, CNOT circuit = QCircuit([H(0), CNOT(0,1)], label="Bell state") print(circuit) from mpqp.execution import run, ATOSDevice result = run(circuit, ATOSDevice.MYQLM_PYLINALG) print(result) print(result.amplitudes) print(result.probabilities) from mpqp.meas...
https://github.com/kosakhro/QAOA-for-exact-cover
kosakhro
from qiskit import * from qiskit.visualization import plot_bloch_multivector from qiskit.visualization import plot_histogram import numpy as np import matplotlib.pyplot as plt import seaborn as sns IBMQ.load_account() matplotlib inline my_provider = IBMQ.get_provider() my_provider.backends() simulator...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.mappers.second_quantization import LogarithmicMapper mapper = LogarithmicMapper(2) from qiskit_nature.second_q.mappers import LogarithmicMapper mapper = LogarithmicMapper(2) from qiskit_nature.second_q.mappers import LogarithmicMapper mapper = LogarithmicMapper(padding=2) from qiski...
https://github.com/abbarreto/qiskit4
abbarreto
from qiskit import QuantumCircuit, Aer, execute, IBMQ from qiskit.utils import QuantumInstance import numpy as np from qiskit.algorithms import Shor IBMQ.enable_account('ENTER API TOKEN HERE') # Enter your API token here provider = IBMQ.get_provider(hub='ibm-q') backend = Aer.get_backend('qasm_simulator') qu...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( document ).ready(code_toggle); </script> <form action="javascript:code_toggle()"><input type="submit" val...
https://github.com/nagarx/Quantum-KNN-Classifier-using-Qiskit
nagarx
from qiskit import QuantumCircuit, QuantumRegister def swap_test(N): ''' `N`: Number of qubits of the quantum registers. ''' a = QuantumRegister(N, 'a') b = QuantumRegister(N, 'b') d = QuantumRegister(1, 'd') # Quantum Circuit qc_swap = QuantumCircuit(name = ' SWAP \nTes...
https://github.com/kaelynj/Qiskit-HubbardModel
kaelynj
#Jupyter notebook to check if imports work correctly %matplotlib inline import sys sys.path.append('./src') import HubbardEvolutionChain as hc import ClassicalHubbardEvolutionChain as chc import FullClassicalHubbardEvolutionChain as fhc from qiskit import QuantumCircuit, execute, Aer, IBMQ, BasicAer, QuantumRegi...
https://github.com/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
from qiskit import * from qiskit.visualization import plot_histogram import numpy as np def NOT(inp): """An NOT gate. Parameters: inp (str): Input, encoded in qubit 0. Returns: QuantumCircuit: Output NOT circuit. str: Output value measured from qubit 0. ...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or...
https://github.com/lvillasen/Introduccion-a-la-Computacion-Cuantica
lvillasen
!pip install numpy import numpy as np print(np.round(np.pi,4)) lista = [0,1,2,3,4,5] print(lista[1]) print(lista[0:-1]) for i in range(5): print("Hola mundo i=%d" %i) lista = [i for i in range(10)] lista import matplotlib.pyplot as plt plt.plot(lista) plt.draw() i = 10 while (i < 15): ...
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/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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector qc = QuantumCircuit(2) qc.h(0) qc.x(1) state = Statevector(qc) plot_bloch_multivector(state)
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse d0 = pulse.DriveChannel(0) d1 = pulse.DriveChannel(1) with pulse.build() as pulse_prog: with pulse.align_right(): # this pulse will start at t=0 pulse.play(pulse.Constant(100, 1.0), d0) # this pulse will start at t=80 pulse.play(pulse.Constant(20,...
https://github.com/Qiskit/qiskit-transpiler-service
Qiskit
# -*- coding: utf-8 -*- # (C) Copyright 2024 IBM. All Rights Reserved. # # 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 modificat...
https://github.com/primaryobjects/oracle
primaryobjects
"""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/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/HuangJunye/Qiskit-for-GameDev
HuangJunye
#!/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/shell-raiser/Qiskit-Developer-Certification-Notes-and-Code
shell-raiser
from qiskit import * from qiskit.tools.visualization import plot_bloch_multivector circuit = QuantumCircuit(1,1) #init ckt circuit.x(0) #Simulate it simulator = Aer.get_backend('statevector_simulator') #statevector describes the quantum gate state result = execute(circuit, backend=simulator).result() state...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# -*- coding: utf-8 -*- # This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0....
https://github.com/Qottmann/Quantum-anomaly-detection
Qottmann
import time import datetime import numpy as np from matplotlib import pyplot as plt import qiskit from qiskit import * from qiskit.opflow import X,Z,I from qiskit.opflow.state_fns import StateFn, CircuitStateFn from qiskit.providers.aer import StatevectorSimulator, AerSimulator from qiskit.algorithms import ...
https://github.com/Keerthiraj-Nagaraj/IBM-quantum-challenge-2020
Keerthiraj-Nagaraj
from IPython.display import Image, display Image('ryoko_pillars.png') Image('lights_out_rule.png') Image('lights_out_prob.png') import numpy as np # import qiskit libraries from qiskit import IBMQ, Aer,QuantumRegister, ClassicalRegister, QuantumCircuit, execute from qiskit.providers.ibmq import least_b...
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/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools 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 Zero, One, I, X, Y, Z from...
https://github.com/Ilan-Bondarevsky/qiskit_algorithm
Ilan-Bondarevsky
import numpy as np from qiskit import BasicAer, execute from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, AncillaRegister, Aer, transpile from qiskit.tools.visualization import plot_histogram from qiskit.circuit.gate import Gate import sys sys.path.insert(0, "D:/myProjects/AfekaCodeProjec...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import FakeBoeblingen backend = FakeBoeblingen() ghz = QuantumCircuit(5) ghz.h(0) ghz.cx(0,range(1,5)) circ = transpile(ghz, backend, scheduling_method="asap") circ.draw(output='mpl')
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # define a quantum register with one qubit q = QuantumRegister(1,"qreg") # define a classical register with one bit # it stores the measurement result of the quan...
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/apozas/qaoa-color
apozas
# Copied and modified from qiskit_aqua.algorithms.adaptive.qaoa.qaoa.py # and qiskit_aqua.algorithms.adaptive.qaoa.varform.py # ============================================================================= import logging from qiskit_aqua.algorithms import QuantumAlgorithm from qiskit_aqua import AquaError, Plu...
https://github.com/veenaiyuri/qiskit-education
veenaiyuri
from QiskitEducation import * qc = QuantumAlgorithm(3,3) qc.h(qc.q[0]) qc.h(qc.q[1]) qc.cx(qc.q[1], qc.q[2]) qc.cx(qc.q[0], qc.q[1]) qc.h(qc.q[0]) qc.measure(qc.q[0], qc.c[0]) qc.measure(qc.q[1], qc.c[1]) qc.cx(qc.q[1], qc.q[2]) qc.cz(qc.q[0], qc.q[2]) qc.h(qc.q[2]) qc.measure(qc.q[2], qc.c[2]) p...
https://github.com/mgg39/qiskit-networks
mgg39
import numpy as np import qiskit class Node: """ Object class for the empty Nodes. """ def __init__(self, name: str, location: list, elements: list, ports: list): """ Constructor of the Node. :param name: the name of the Node. :param location: defined locati...
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/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience
PacktPublishing
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created Nov 2020 @author: hassi """ # Importing Qiskit from qiskit import QuantumCircuit # Import display circuit from our Grover collection from ch9_grover_functions import display_circuit def main(): # First, let's see a phase shift print("C...
https://github.com/ctuning/ck-qiskit
ctuning
# -*- coding: utf-8 -*- # Copyright 2017, 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. """ The eval_hamiltonian function has been borrowed from QISKit's tools/apps/optimization.py and slightly modified b...
https://github.com/abbarreto/qiskit4
abbarreto
https://github.com/xtophe388/QISKIT
xtophe388
from qiskit import ClassicalRegister, QuantumRegister from qiskit import QuantumCircuit, execute from qiskit import register, available_backends, get_backend #import Qconfig and set APIToken and API url import sys sys.path.append("../../") # go to parent dir import Qconfig qx_config = { "APItoken": Qconfi...
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...