repo stringclasses 885
values | file stringclasses 741
values | content stringlengths 4 215k |
|---|---|---|
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/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, L_BFGS_B
from qiskit.circuit.library import TwoLocal
# VOLTA
from volta.vqd import VQD
from volta.uti... |
https://github.com/qiskit-fall-fest-hackathon-france/qiskit-fall-fest-hackathon-france | qiskit-fall-fest-hackathon-france | import qiskit
qiskit.__qiskit_version__
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
qc = QuantumCircuit(qr,cr)
qc.draw()
qc.h(qr[0])
qc.draw()
qc = QuantumCircuit(qr,cr)
qc.h(qr[0])
qc.cx(qr[0],qr[1])
qc.measure(qr... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.utils import algorithm_globals
algorithm_globals.random_seed = 123456
from sklearn.datasets import make_blobs
features, labels = make_blobs(
n_samples=20,
centers=2,
center_box=(-1, 1),
cluster_std=0.1,
random_state=algorithm_globals.random_seed,
)
from qiskit import Ba... |
https://github.com/sathayen/qiskit-docker | sathayen | # Creating quantum circuits
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister
from qiskit import execute
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.h(qr)
... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # -*- 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/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience | PacktPublishing | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created Nov 2020
@author: hassi
"""
#!/usr/bin/env python
# coding: utf-8
print("Loading Qiskit...")
from qiskit import QuantumCircuit, IBMQ
from qiskit.compiler import transpile
from qiskit.providers.ibmq import least_busy
from IPython.core.display... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/jdanielescanez/quantum-solver | jdanielescanez | #!/usr/bin/env python3
# Author: Daniel Escanez-Exposito
from crypto.six_state.participant import Participant
from qiskit import QuantumCircuit
## The Sender entity in the Six-State implementation
## @see https://qiskit.org/textbook/ch-algorithms/quantum-key-distribution.html
class Sender(Participant):
#... |
https://github.com/quantum-tokyo/qiskit-handson | quantum-tokyo | # Qiskitライブラリーを導入
from qiskit import *
from qiskit.visualization import *
# 描画のためのライブラリーを導入
import matplotlib.pyplot as plt
%matplotlib inline
# Qiskitバージョンの確認
qiskit.__qiskit_version__
q = QuantumCircuit(1) # 1量子ビット回路を用意
q.x(0) # Xゲートを0番目の量子ビットに操作します。
q.draw(output="mpl") # 回路を描画
# 状態ベクト... |
https://github.com/GabrielPontolillo/QiskitPBT | GabrielPontolillo | '''
This program implements the quantum Fourier transform (QFT)
'''
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, IBMQ
from qiskit.visualization import circuit_drawer as drawer
from qiskit.tools.visualization import plot_histogram
from qiskit import execute
from qiskit import Aer
im... |
https://github.com/kosakhro/QAOA-for-exact-cover | kosakhro | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 16 20:22:29 2020
@author: Arttu Huikuri
"""
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
# Making the q... |
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/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/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/euler16/Distinguishing-Unitary-Gates-on-IBM-Quantum-Processor | euler16 | import sys, time
sys.path.append("../")
import Qconfig
qx_config = {
"APItoken": Qconfig.APItoken,
"url": Qconfig.config['url']}
print('Qconfig loaded from %s.' % Qconfig.__file__)
# Imports
import qiskit as qk
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qisk... |
https://github.com/PaulaGarciaMolina/QNLP_Qiskit_Hackathon | PaulaGarciaMolina | import numpy as np
import pickle
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
# Nouns
man, woman, kid = Word('man', n), Word('woman', n), Word('kid', n)
# Adjectives
morose, irascible = Word(... |
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/mathelatics/QGSS-2023-From-Theory-to-Implementations | mathelatics | from qiskit import *
%matplotlib inline
from qiskit.tools.visualization import plot_histogram
from qiskit.tools.monitor import job_monitor
# create qubit using quantum registers
qr = QuantumRegister(2)
# create classical register to take measurement of `qr`
cr = ClassicalRegister(2)
# build a circuit
q... |
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/usamisaori/qLipschitz | usamisaori | import numpy as np
from scipy.linalg import sqrtm
Dag = lambda matrix: matrix.conj().T
def D(rou, sigma):
A = rou - sigma
A_ = sqrtm( np.dot( A.conj().T, A ) )
return 0.5 * np.linalg.norm( np.trace(A_) )
def d(A, rou, sigma):
distance = 0
for output in A.O:
trace = np... |
https://github.com/ACDuriez/Ising-VQE | ACDuriez | import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from tqdm import tqdm
from scipy.optimize import minimize
from dataclasses import dataclass
from qiskit.providers.fake_provider import FakeManila,FakeQuito,FakeLima,FakeKolkata,FakeNairobi
from qiskit.transpiler import CouplingMap
from... |
https://github.com/TheGupta2012/QPE-Algorithms | TheGupta2012 | from qiskit import QuantumCircuit, execute, transpile, Aer
from qiskit.extensions import UnitaryGate,Initialize
from qiskit.quantum_info import Statevector
from qiskit.compiler import assemble
from qiskit.tools.visualization import plot_bloch_vector
from qiskit.tools.visualization import plot_histogram,plot_blo... |
https://github.com/EusseJhoan/DeutschJosza_algorithm | EusseJhoan | from qiskit import QuantumCircuit, transpile, Aer
from qiskit.visualization import plot_histogram
import numpy as np
sim = Aer.get_backend('aer_simulator')
def U_f1(qc):
return qc
def U_f2(qc):
qc.x(1) #Compuerta X al segundo qubit
return qc
def U_f3(qc):
qc.cx(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/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/nahumsa/volta | nahumsa | import sys
sys.path.append('../../')
import numpy as np
from qiskit import QuantumCircuit
from qiskit.opflow import I, X, Y, Z
import matplotlib.pyplot as plt
from volta.observables import sample_hamiltonian
from volta.hamiltonians import BCS_hamiltonian
EPSILONS = [3, 3]
V = -2
hamiltonian = BCS_hamilt... |
https://github.com/Hayatto9217/Qiskit7 | Hayatto9217 | 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.buil... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 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/Z-928/Bugs4Q | Z-928 | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.wrapper import available_backends, get_backend
from qiskit.wrapper import execute as q_execute
q = QuantumRegister(2, name='q')
c = ClassicalRegister(2, name='c')
qc = QuantumCircuit(q,c)
qc.h(q[0])
qc.h(q[1])
qc.cx(q[0], q[1]... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.tools.visualization import circuit_drawer
q = QuantumRegister(1)
c = ClassicalRegister(1)
qc = QuantumCircuit(q, c)
qc.h(q)
qc.measure(q, c)
circuit_drawer(qc, output='mpl', style={'backgroundcolor': '#EEEEEE'}) |
https://github.com/BOBO1997/osp_solutions | BOBO1997 | import numpy as np
import matplotlib.pyplot as plt
plt.style.use("ggplot")
from pprint import pprint
import pickle
import time
import datetime
%matplotlib inline
# Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z)
from qiskit.opflow import Zero, One, X, Y, Z, I
from qiskit.opflow.s... |
https://github.com/noamsgl/IBMAscolaChallenge | noamsgl | import logging
import sys
import time
from itertools import product
import numpy as np
import pandas as pd
from qiskit import QuantumCircuit, execute
from qiskit.circuit.library import U3Gate
from qiskit.providers.aer import QasmSimulator
from qiskit.providers.aer.noise import NoiseModel, depolarizing_error,... |
https://github.com/zapatacomputing/qe-qiskit | zapatacomputing | ################################################################################
# © Copyright 2021-2022 Zapata Computing Inc.
################################################################################
import pytest
import qiskit
from orquestra.quantum.circuits.symbolic.expressions import FunctionCall, Symbo... |
https://github.com/ElePT/qiskit-algorithms-test | ElePT | # -*- 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/AbeerVaishnav13/4-qubit-design | AbeerVaishnav13 | import warnings
warnings.filterwarnings('ignore')
from qiskit_metal import designs, MetalGUI
design = designs.DesignPlanar()
design.overwrite_enabled = True
design.chips.main.size_x = '12mm'
design.chips.main.size_y = '10mm'
gui = MetalGUI(design)
from qiskit_metal.qlibrary.qubits.transmon_pocket_cl i... |
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/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import pulse
with pulse.build(name='my_example') as my_program:
# Add instructions here
pass
my_program
from qiskit.pulse import DriveChannel
channel = DriveChannel(0)
from qiskit.providers.fake_provider import FakeValencia
backend = FakeValencia()
with pulse.build(backend=bac... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/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/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriva... |
https://github.com/xtophe388/QISKIT | xtophe388 | from svm_datasets import *
from qiskit_acqua.svm.data_preprocess import *
from qiskit_acqua.input import get_input_instance
from qiskit_acqua import run_algorithm
import logging
logger = logging.getLogger()
# logger.setLevel(logging.DEBUG) # uncomment it to see detailed logging
################# import Qconf... |
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/JavaFXpert/quantum-pong | 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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator | GIRISHBELANI | # all libraries used by some part of the VQLS-implementation
from qiskit import (
QuantumCircuit, QuantumRegister, ClassicalRegister,
Aer, execute, transpile, assemble
)
from qiskit.circuit import Gate, Instruction
from qiskit.quantum_info.operators import Operator
from qiskit.extensions import ZGate... |
https://github.com/rmlarose/qcbq | rmlarose | #!pip install qiskit
# Do the usual setup, but without classical registers or measurement
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister, execute
qr = QuantumRegister(1)
circ = QuantumCircuit(qr)
# Place an Ry gate with a −3π/4 rotation
circ.ry(-3/4 * np.pi, qr[0])
# Draw the ci... |
https://github.com/arian-code/nptel_quantum_assignments | arian-code | from sympy import *
from sympy.physics.quantum.state import Ket, Bra
import numpy as np
init_printing(use_unicode=True)
#in_1=Ket (0)
#in_1
in_1=Matrix([[1],[0],[0],[0]])
in_1
X_2 =Matrix([[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]])
CNOT=Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, ... |
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
qc.h(1)
qc.cx(1, 0)
return qc
def encode_message(qc, qubit, msg):
if len(msg) != 2 or not set([0,1]).issubset({0,1}):
raise ValueError(f"message '{msg}' is invalid")
if msg[1] == "1":
#... |
https://github.com/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges | MonitSharma | ### Install Qiskit and relevant packages, if needed
### IMPORTANT: Make sure you are using python 3.10 or 3.11 for compatibility of the required packages
%pip install qiskit[visualization]==1.0.2
%pip install qiskit-ibm-runtime
%pip install qiskit-aer
%pip install graphviz
%pip install qiskit-transpiler-service
... |
https://github.com/qiskit-community/qiskit-aqt-provider | qiskit-community | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019, Alpine Quantum Technologies 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.... |
https://github.com/usamisaori/Grover | usamisaori | import math
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.pyplot import arrow
from mpl_toolkits.axisartist.axislines import SubplotZero
from matplotlib.patches import Arc
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
def g... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import IBMQ, transpile
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
from qiskit.tools.visualization import plot_histogram
from qiskit.providers.fake_provider import FakeVigo
device_backend = FakeVigo()
# Construct quantum circuit
circ = QuantumCircuit(3, 3)
circ.h(0)
ci... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 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/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 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... |
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/JessicaJohnBritto/Quantum-Computing-and-Information | JessicaJohnBritto | import pennylane as qml
from pennylane import numpy as np
# Basis State preparation
def state_preparation(basis_id, n_qubits):
bits = [int(x) for x in np.binary_repr(basis_id, width=n_qubits)]
return qml.BasisStatePreparation(bits, wires=range(n_qubits))
#Testing
state_preparation(3,5)
# Swapppin... |
https://github.com/JessicaJohnBritto/Quantum-Computing-and-Information | JessicaJohnBritto | # Importing Packages
from qiskit import QuantumCircuit
from qiskit import IBMQ, Aer, transpile, assemble
from qiskit.visualization import plot_histogram
style = {'backgroundcolor': 'lightyellow'} # Style of the circuits
def encode(qc, qubit, msg):
if len(msg) != 2 or not set(msg).issubset({"0","1"}):
... |
https://github.com/acfilok96/Quantum-Computation | acfilok96 | import qiskit
from qiskit import *
print(qiskit.__version__)
%matplotlib inline
from qiskit.tools.visualization import plot_histogram
secret_number = '101001'
# here work is happen like buttom to up
for position,value in enumerate(reversed(secret_number)):
if value == '1':
print(position, value... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | import numpy as np
from qiskit import BasicAer
from qiskit.transpiler import PassManager
from qiskit.aqua import QuantumInstance
from qiskit.aqua.algorithms import VQE, NumPyMinimumEigensolver, IQPE
from qiskit.aqua.operators import WeightedPauliOperator
from qiskit.circuit.library import TwoLocal
from qiskit.aq... |
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/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/Qiskit/feedback | Qiskit | from qiskit_ibm_runtime import IBMRuntimeService
# Option 1 - Save default accounts per channel
IBMRuntimeService.save_account(channel="ibm_quantum", token="<IBM Quantum API token>")
IBMRuntimeService.save_account(
channel="ibm_cloud",
token="<IBM Cloud API key>",
instance="<CRN> or <Service Instanc... |
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources | aryashah2k | # here is a list holding all even numbers between 10 and 20
L = [10, 12, 14, 16, 18, 20]
# let's print the list
print(L)
# let's print each element by using its index but in reverse order
print(L[5],L[4],L[3],L[2],L[1],L[0])
# let's print the length (size) of list
print(len(L))
# let's print each elemen... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import IBMQ
IBMQ.load_account()
provider = IBMQ.get_provider(hub="ibm-q", group="open", project="main")
program_id = "qaoa"
qaoa_program = provider.runtime.program(program_id)
print(f"Program name: {qaoa_program.name}, Program id: {qaoa_program.program_id}")
print(qaoa_program.parameters())
... |
https://github.com/ggridin/QiskitTests | ggridin |
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, Aer
from QuantumPlatform import QuantumPlatform
# Set up the program
def get_quantum_spy_circuit():
alice = QuantumRegister(1, name='alice')
fiber = QuantumRegister(1, name='fiber')
bob = QuantumRegister(1, name='bob')
... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.compiler import transpile
from qiskit.transpiler import PassManager
circ = QuantumCircuit(3)
circ.ccx(0, 1, 2)
circ.draw(output='mpl')
from qiskit.transpiler.passes import Unroller
pass_ = Unroller(['u1', 'u2', 'u3', 'cx'])
pm = PassManager(pass_)
new_circ = pm... |
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.algorithms import IterativeAmplitudeEstimation, EstimationProblem
from qiskit.circuit.library import WeightedA... |
https://github.com/Pitt-JonesLab/clonk_transpilation | Pitt-JonesLab | # 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.quantum_info import SparsePauliOp
H2_op = SparsePauliOp.from_list(
[
("II", -1.052373245772859),
("IZ", 0.39793742484318045),
("ZI", -0.39793742484318045),
("ZZ", -0.01128010425623538),
("XX", 0.18093119978423156),
]
)
from qiskit.primitives impo... |
https://github.com/ionq-samples/qiskit-getting-started | ionq-samples | # initialization
import numpy as np
# importing Qiskit
from qiskit import IBMQ, Aer
from qiskit.providers.ibmq import least_busy
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
# s... |
https://github.com/farhad-abdi/InSilicoQ | farhad-abdi | # Quantum Kernel Machine Learning Functions
import numpy as np
## Utilities
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from typing import Optional, Callable, List, Union
from functools import reduce
# Importing standard Qiskit libraries
from qiskit import QuantumCircui... |
https://github.com/usamisaori/qLipschitz | usamisaori | from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
from qiskit.quantum_info import DensityMatrix
def getDensityMatrix(circuit):
return DensityMatrix(circuit).data
from qCircuit import createInputCircuit, createModelCircuit, createNoisyModelCircuit
from qLipschitz import QLi... |
https://github.com/intrinsicvardhan/QuantumComputingAlgos | intrinsicvardhan | # initialization
import numpy as np
# importing Qiskit
from qiskit import IBMQ, Aer
from qiskit.providers.ibmq import least_busy
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
# s... |
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') |
https://github.com/qiskit-community/prototype-zne | qiskit-community | from warnings import filterwarnings
filterwarnings('ignore')
import json
import numpy.random as npr
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
# mpl.rcParams["figure.dpi"] = 300
# plt.rcParams.update({"text.usetex": True, "font.family": "Computer Modern Roman"})
from qiskit... |
https://github.com/AmirhoseynpowAsghari/Qiskit-Tutorials | AmirhoseynpowAsghari | import numpy as np
import matplotlib.pyplot as plt
# Define parameters^M
frequency = 100 # Hz (cycles per second)^M
sampling_rate = 10000 # Samples per second^M
duration = 1 # Seconds^M
time = np.linspace(0, duration, sampling_rate)
# Generate signal^M
signal = np.sin(2 * np.pi * frequency * time)
# C... |
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
qc.h(1)
qc.cx(1, 0)
return qc
def encode_message(qc, qubit, msg):
if len(msg) != 2 or not set([0,1]).issubset({0,1}):
raise ValueError(f"message '{msg}' is invalid")
if msg[1] == "1":
q... |
https://github.com/avkhadiev/schwinger-vqe | avkhadiev | Energy evaluation 1 returned -0.314419 +/- 0.038533
Energy evaluation 2 returned -0.034149 +/- 0.036455
Energy evaluation 3 returned -0.252537 +/- 0.036098
Energy evaluation 4 returned -0.015569 +/- 0.041661
Energy evaluation 5 returned -0.284201 +/- 0.035386
Energy evaluation 6 returned -0.004501 +/- 0.042106
En... |
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
qc.h(1)
qc.cx(1, 0)
return qc
def encode_message(qc, qubit, msg):
if len(msg) != 2 or not set([0,1]).issubset({0,1}):
raise ValueError(f"message '{msg}' is invalid")
if msg[1] == "1":
q... |
https://github.com/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/Z-928/Bugs4Q | Z-928 | from qiskit import *
qc = QuantumCircuit(2)
qc.h(i)
qc.crz (PI/4, 0, 1)
|
https://github.com/qiskit-community/qiskit-cold-atom | qiskit-community | from pprint import pprint
import numpy as np
import matplotlib.pyplot as plt
from qiskit_cold_atom.providers import ColdAtomProvider
# save an account to disk
# ColdAtomProvider.save_account(url = ["url_of_backend_1", "url_of_backend_2"], username="JohnDoe",token="123456")
# load the stored account
provid... |
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | # -*- 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/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
qc.h(1)
### replaced cx gate ###
qc.cy(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")
... |
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
qc.h(1)
qc.cx(1, 0)
return qc
def encode_message(qc, qubit, msg):
if len(msg) != 2 or not set([0,1]).issubset({0,1}):
raise ValueError(f"message '{msg}' is invalid")
if msg[1] == "1":
#... |
https://github.com/1chooo/Quantum-Oracle | 1chooo | from qiskit import execute
from qiskit.providers.aer import AerSimulator
from qiskit.visualization import plot_histogram
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
qrx = QuantumRegister(3, 'x')
qry = QuantumRegister(1, 'y')
cr = ClassicalRegister(3, 'c')
qc = QuantumCircuit(qrx, qry,... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/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/h-rathee851/Pulse_application_qiskit | h-rathee851 | def speak(text):
from IPython.display import Javascript as js, clear_output
# Escape single quotes
text = text.replace("'", r"\'")
display(js(f'''
if(window.speechSynthesis) {{
var synth = window.speechSynthesis;
synth.speak(new window.SpeechSynthesisUtterance('{text}'));
... |
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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator | GIRISHBELANI | import sys
sys.path[1:1] = ["_common", "_common/qiskit"]
sys.path[1:1] = ["../../_common", "../../_common/qiskit"]
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
import time
import math
import os
import numpy as np
np.random.seed(0)
import execute as ex
import metrics as metrics
from... |
https://github.com/ElePT/qiskit-algorithms-test | ElePT | # 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/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience | PacktPublishing | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created Nov 2020, Updated March 2022
@author: hassi
"""
# https://www.qiskit.org/documentation/_modules/qiskit/algorithms/factorizers/shor.html
from qiskit import Aer, IBMQ
from qiskit.algorithms import Shor
from qiskit.utils import QuantumInstance
im... |
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/qwqmlf/qwgc | qwqmlf | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
from qiskit import QuantumCircuit
# ## Create Circuit
# In[2]:
def createInputCircuit(data):
qubits_num = len(data)
qcircuit = QuantumCircuit(qubits_num, qubits_num)
qubits = qcircuit.qubits
for i, d in enumer... |
https://github.com/abbarreto/qiskit2 | abbarreto | %run init.ipynb
|
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/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | %run init.ipynb
|
https://github.com/magn5452/QiskitQaoa | magn5452 | import matplotlib.pyplot as plt
import numpy as np
from VehicleRouting.standard.factories.VehicleRoutingProblemFactories import Experiment1VehicleRoutingProblemFactory
from VehicleRouting.standard.problems.VehicleRoutingProblem import VehicleRoutingProblem
from VehicleRouting.functions.functionsVehicleRouting imp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.