repo stringclasses 885
values | file stringclasses 741
values | content stringlengths 4 215k |
|---|---|---|
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/Qottmann/Quantum-anomaly-detection | Qottmann | import time
import itertools
import numpy as np
import qiskit
from qiskit import *
from qiskit.quantum_info import Statevector
from qiskit.algorithms.optimizers import COBYLA, L_BFGS_B, SPSA
from qiskit.opflow.state_fns import StateFn, CircuitStateFn
from qiskit.providers.aer import StatevectorSimulator, AerS... |
https://github.com/anirban-m/qiskit-superstaq | anirban-m | from unittest.mock import MagicMock, patch
import applications_superstaq
import qiskit
import qiskit_superstaq as qss
def test_provider() -> None:
ss_provider = qss.superstaq_provider.SuperstaQProvider(access_token="MY_TOKEN")
assert str(ss_provider.get_backend("ibmq_qasm_simulator")) == str(
... |
https://github.com/AasthaShayla/Qiskit-Teleportation | AasthaShayla | import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit,execute, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
from qiskit.providers.aer import QasmSimulator
# Loading your IBM Quantum account(s)... |
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/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.visualization.timeline import draw as timeline_draw
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")
... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | from qiskit import Aer, IBMQ
import getpass, random, numpy, math
def title_screen ():
print("\n\n\n\n\n\n\n\n")
print(" ██████╗ ██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ ██╗███╗ ███╗ ")
print(" ██╔═══██╗██║ ██║██╔══██╗████╗ ██║╚══██╔══╝██║ ██║████╗ ████║ ... |
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/primaryobjects/oracle | primaryobjects | import json
import logging
import numpy as np
import warnings
from functools import wraps
from typing import Any, Callable, Optional, Tuple, Union
from qiskit import IBMQ, QuantumCircuit, assemble
from qiskit.circuit import Barrier, Gate, Instruction, Measure
from qiskit.circuit.library import UGate, U3Ga... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/AmirhoseynpowAsghari/Qiskit-Tutorials | AmirhoseynpowAsghari | import numpy as np
# Parameters
J = 1
k_B = 1
T = 2.269 # Critical temperature
K = J / (k_B * T)
# Transfer matrix for a 2x2 Ising model (simplified example)
def transfer_matrix(K):
T = np.zeros((4, 4))
configs = [(-1, -1), (-1, 1), (1, -1), (1, 1)]
for i, (s1, s2) in enumerate(configs):
... |
https://github.com/darkmatter2000/Quantum_phase_estimation | darkmatter2000 | from qiskit import ClassicalRegister , QuantumCircuit, QuantumRegister
import numpy as np
qr = QuantumRegister(2)
cr = ClassicalRegister(3) #For tree classicals bites
qc = QuantumCircuit(qr , cr)
qc.h(qr[0]) #auxiliary qubit
qc.x(qr[1]) # eigenvector
#qc.cp((3/2)*np.pi , qr[0] , qr[1])
qc.cp(3*np.pi , qr[... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from sklearn.datasets import load_iris
iris_data = load_iris()
print(iris_data.DESCR)
features = iris_data.data
labels = iris_data.target
from sklearn.preprocessing import MinMaxScaler
features = MinMaxScaler().fit_transform(features)
import pandas as pd
import seaborn as sns
df = pd.DataFrame(ir... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | #General imports
import numpy as np
#Operator Imports
from qiskit.opflow import Z, X, I, StateFn, CircuitStateFn, SummedOp
from qiskit.opflow.gradients import Gradient, NaturalGradient, QFI, Hessian
#Circuit imports
from qiskit.circuit import QuantumCircuit, QuantumRegister, Parameter, ParameterVector, Parame... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
from qiskit.transpiler.passes import UnitarySynthesis
circuit = QuantumCircuit(1)
circuit.rx(0.8, 0)
unitary = Operator(circuit).data
unitary_circ = QuantumCircuit(1)
unitary_circ.unitary(unitary, [0])
synth = UnitarySynthesis(basi... |
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/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | from qiskit import IBMQ
IBMQ.backends()
IBMQ.delete_accounts()
IBMQ.stored_accounts()
import Qconfig_IBMQ_experience
import Qconfig_IBMQ_network
IBMQ.enable_account(Qconfig_IBMQ_experience.APItoken)
# uncomment to print to screen (it will show your token and url)
# IBMQ.active_accounts()
IBMQ.ba... |
https://github.com/MAI-cyber/QIT | MAI-cyber | # ! pip install numpy
# ! pip install qiskit
# ! pip install matplotlib
from qiskit import QuantumCircuit, execute, Aer, BasicAer
from qiskit.visualization import plot_histogram
import numpy as np
n = 2
f1 = QuantumCircuit(n+1, name='f1')
# Applying the x gate to ancilla for when f_1 = 1
f1.cx(1,... |
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/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/dimple12M/Qiskit-Certification-Guide | dimple12M | from qiskit import QuantumCircuit,QuantumRegister,ClassicalRegister,AncillaRegister
q=QuantumRegister(2)
q=QuantumRegister(2,'qr')
c=ClassicalRegister(2)
c=ClassicalRegister(2,'cr')
qr1=QuantumRegister(2,'qr_1')
qr2=QuantumRegister(3,'qr_2')
c=ClassicalRegister(2,'cr')
qc=QuantumCircuit(qr1,qr2,c)
qc.d... |
https://github.com/kaelynj/Qiskit-IsingModel | kaelynj | %reset -f
#%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ, QuantumRegister
from qiskit.providers.aer import QasmSimulator, StatevectorSimulator, UnitarySimulator
from qiskit.compiler import transpile, assemble
from qiskit.tool... |
https://github.com/tomtuamnuq/compare-qiskit-ocean | tomtuamnuq | import warnings
import numpy as np
from qiskit import IBMQ, execute, transpile, BasicAer
from qiskit_optimization.algorithms import CplexOptimizer
from qiskit_optimization import QuadraticProgram
from qiskit.visualization import plot_histogram
from qiskit.providers.ibmq.job import job_monitor
from utilities.he... |
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/rohitgit1/Quantum-Computing-Summer-School | rohitgit1 | !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/DaisukeIto-ynu/KosakaQ | DaisukeIto-ynu | # 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/swe-train/qiskit__qiskit | swe-train | # 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/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | %run init.ipynb
((10+9.8+9.5)/3+10)/2
(9.77+10)/2
|
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/anpaschool/quantum-computing | anpaschool | %matplotlib inline
import numpy as np
import IPython
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit,ClassicalRegister,QuantumRegister
from qiskit import BasicAer
from qiskit.tools.jupyter import *
from qiskit.visualization import *
import seaborn as sns
sns.set()
from helper import *
d... |
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/mathelatics/QGSS-2023-From-Theory-to-Implementations | mathelatics | import numpy as np
import pylab
from qiskit import Aer, IBMQ
from qiskit.aqua import QuantumInstance, aqua_globals
from qiskit.aqua.algorithms import VQE, NumPyMinimumEigensolver
from qiskit.aqua.components.optimizers import SPSA
from qiskit.circuit.library import TwoLocal
from qiskit.aqua.operators import Wei... |
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/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/Glebegor/Quantum-programming-algorithms | Glebegor |
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/minnukota381/Quantum-Computing-Qiskit | minnukota381 | from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram
# Create a quantum circuit with a single qubit
qc = QuantumCircuit(1)
qc.x(0)
qc.h(0)
qc.z(0)
qc.h(0)
# qc.draw()
qc.draw('mpl')
backend = Aer.get_backend('statevector_simulator')
... |
https://github.com/ElePT/qiskit-algorithms-test | ElePT | # 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/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | 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/UST-QuAntiL/nisq-analyzer-content | UST-QuAntiL | from qiskit import QuantumCircuit
# n = 3 # number of qubits used to represent s
# s = '011' # the hidden binary string
# https://qiskit.org/textbook/ch-algorithms/bernstein-vazirani.html
def get_circuit(**kwargs):
n = kwargs["number_of_qubits"]
s = kwargs["s"]
# We need a circuit with n ... |
https://github.com/matteoacrossi/oqs-jupyterbook | matteoacrossi | import numpy as np
from scipy.optimize import fsolve, differential_evolution
# Main qiskit imports
from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, execute, Aer, IBMQ
# Tomography
from qiskit.ignis.verification.tomography import state_tomography_circuits
from qiskit.ig... |
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/Z-928/Bugs4Q | Z-928 | from qiskit import Aer, QuantumCircuit, transpile
from qiskit.circuit.library import PhaseEstimation
qc= QuantumCircuit(3,3)
# dummy unitary circuit
unitary_circuit = QuantumCircuit(1)
unitary_circuit.h(0)
# QPE
qc.append(PhaseEstimation(2, unitary_circuit), list(range(3)))
qc.measure(list(range(3)), list(range... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile
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/PabloMartinezAngerosa/QAOA-uniform-convergence | PabloMartinezAngerosa | import qiskit
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict
from operator import itemgetter
from scipy.optimize import minimize
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
from qiskit.aqua.algorithms import Nu... |
https://github.com/qwqmlf/qwgc | qwqmlf | # ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.3.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
import numpy as np
import copy
from qis... |
https://github.com/7enTropy7/Shor-s-Algorithm_Quantum | 7enTropy7 | from math import gcd,log
from random import randint
import numpy as np
from qiskit import *
qasm_sim = qiskit.Aer.get_backend('qasm_simulator')
def period(a,N):
available_qubits = 16
r=-1
if N >= 2**available_qubits:
print(str(N)+' is too big for IBMQX')
qr = QuantumR... |
https://github.com/Pitt-JonesLab/slam_decomposition | Pitt-JonesLab | # this notebook I was trying to understand the fsim hamiltonian
# I couldn't make sense of the parameter g, so I think I have to make sense
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib wi... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.algorithms import AmplificationProblem
# the state we desire to find is '11'
good_state = ['11']
# specify the oracle that marks the state '11' as a good solution
oracle = QuantumCircuit(2)
oracle.cz(0, 1)
# define Grover's algorithm
problem = AmplificationPro... |
https://github.com/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/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | %run init.ipynb
CX_12 = tp(proj(cb(2,0)),id(2)) + tp(proj(cb(2,1)),pauli(1)); CX_12
CX_21 = tp(id(2),proj(cb(2,0))) + tp(pauli(1),proj(cb(2,1))); CX_21
SWAP = CX_12*CX_21*CX_12; SWAP
Cz = tp(proj(cb(2,0)), id(2)) + tp(proj(cb(2,1)), pauli(3)); Cz_12 = Cz
Cz_21 = tp(id(2),proj(cb(2,0))) + tp(pauli(3),proj(c... |
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/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/idriss-hamadi/Qiskit-Quantaum-codes- | idriss-hamadi | # Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
from qiskit_aer import AerSimulator
# qiskit-ibmq-provider has been deprecated.
# Please see the Migration Guides in https:/... |
https://github.com/Qiskit/feedback | Qiskit | from qiskit import Aer
from qiskit.utils import QuantumInstance
from qiskit_nature.algorithms import VQEUCCFactory
from qiskit_nature.algorithms.initial_points.mp2_initial_point import MP2InitialPoint
from qiskit_nature.drivers import Molecule
from qiskit_nature.drivers.second_quantization import (
Electron... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources | aryashah2k | %matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from qiskit import Aer
from qiskit.aqua import QuantumInstance
from qiskit.aqua.algorithms import QGAN
np.random.seed(2020)
N = 1000
real_data = np.random.binomial(3,0.5,N)
plt.hist(real_data, bins = 4);
n = 2
num_qubits = [n]
num_e... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from __future__ import annotations
import numpy as np
import networkx as nx
num_nodes = 4
w = np.array([[0., 1., 1., 0.],
[1., 0., 1., 1.],
[1., 1., 0., 1.],
[0., 1., 1., 0.]])
G = nx.from_numpy_array(w)
layout = nx.random_layout(G, seed=10)
colors = ['r', 'g', ... |
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.circuit.random import random_circuit
circuit = random_circuit(2, 2, seed=0).decompose(reps=1)
display(circuit.draw("mpl"))
from qiskit.quantum_info import SparsePauliOp
observable = SparsePauliOp("XZ")
print(f">>> Observable: {observable.paulis}")
from qiskit.primitives import Estimator
est... |
https://github.com/Heisenbug-s-Dog/qnn_visualization | Heisenbug-s-Dog | from google.colab import drive
drive.mount('/content/drive')
!pip install torch==1.3.1
!pip install torchvision==0.4.2
!pip install Pillow==6.2.1
!pip install pennylane==0.7.0
# OpenMP: number of parallel threads.
%env OMP_NUM_THREADS=1
# Plotting
%matplotlib inline
import matplotlib.p... |
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/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library.standard_gates import HGate
qc1 = QuantumCircuit(2)
qc1.x(0)
qc1.h(1)
custom = qc1.to_gate().control(2)
qc2 = QuantumCircuit(4)
qc2.append(custom, [0, 3, 1, 2])
qc2.draw('mpl') |
https://github.com/orionhunts-ai/QiskitRuskit | orionhunts-ai | from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2 as Estimator
# Create a new circuit with two qubits (first argument) and two classical
#... |
https://github.com/Simultonian/hamilutor-qiskit | Simultonian | from qiskit import QuantumCircuit
from qiskit.opflow import PauliTrotterEvolution, X, Y, Z, I # For `eval`
from ..utils.repr import qiskit_string_repr, qiskit_string_repr_pauli
def trotter_from_terms(terms: list[tuple[str, float]]) -> QuantumCircuit:
"""
API that takes a list of terms that must be exp... |
https://github.com/urwin419/QiskitChecker | urwin419 | from qiskit import QuantumCircuit
def create_bell_pair():
qc = QuantumCircuit(2)
### replaced x gate ###
qc.x(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")
... |
https://github.com/MonitSharma/qiskit-projects | MonitSharma | import numpy as np
import random
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neighbors import NearestCentroid
from IPython.display import clear_output
import pandas as pd
# =======================================================
import math
import time
from ... |
https://github.com/RavenPillmann/quantum-battleship | RavenPillmann |
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/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/IlliaOvcharenko/quantum-search | IlliaOvcharenko | import sys, os
sys.path.append(os.getcwd())
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit
# from qiskit.primitives.sampler import Sampler
from qiskit_aer.primitives import SamplerV2 as Sampler
from qiskit_aer import AerSimulator
from qiskit ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.library.arithmetic.piecewise_chebyshev import PiecewiseChebyshev
f_x, degree, breakpoints, num_state_qubits = lambda x: np.arcsin(1 / x), 2, [2, 4], 2
pw_approximation = PiecewiseChebyshev(f_x, degree, breakpoints, num_state_qubits)
pw_approx... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 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/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/Chibikuri/qwopt | Chibikuri | import numpy as np
from .parser import GraphParser
from qiskit import QuantumRegister, QuantumCircuit
from numpy import pi
class OperationCreator:
'''
Creating operations of szegedy walk.
reference:
Loke, T., and J. B. Wang. "Efficient quantum circuits
for Szegedy quantum walks.... |
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/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/Axect/QuantumAlgorithms | Axect | import qiskit
qiskit.__qiskit_version__
#initialization
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
# importing Qiskit
from qiskit import IBMQ, BasicAer
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute
from qiskit.compiler import transpile
from qiski... |
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | %%capture
%pip install qiskit
%pip install qiskit_ibm_provider
%pip install qiskit-aer
# Importing standard Qiskit libraries
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, QuantumCircuit, transpile, Aer
from qiskit_ibm_provider import IBMProvider
from qiskit.tools.jupyter import *
from... |
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/iqm-finland/qiskit-on-iqm | iqm-finland | # Copyright 2022 Qiskit on IQM developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... |
https://github.com/TheGupta2012/QPE-Algorithms | TheGupta2012 | from qiskit import QuantumCircuit, execute
from qiskit.tools.visualization import plot_histogram
from qiskit.extensions import UnitaryGate
import numpy as np
from IPython.display import display
class KQPE:
"""
Implements the Kitaev's phase estimation algorithm where a single circuit
is used to e... |
https://github.com/mmetcalf14/Hamiltonian_Downfolding_IBM | mmetcalf14 | # -*- 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/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/abbarreto/qiskit2 | abbarreto | import qiskit
from qiskit import *
import math
import numpy as np
def qc_ezz(t):
qc = QuantumCircuit(2, name = 'e^(-itZZ)')
qc.cx(0, 1); qc.rz(2*t, 1); qc.cx(0, 1)
return qc
def qc_exx(t):
qc = QuantumCircuit(2, name = 'e^(-itXX)')
qc.h([0,1]); qc.cx(0, 1); qc.rz(2*t, 1); qc.cx(0, 1); q... |
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/stevvwen/QAlgoImplementation | stevvwen | # Do the necessary imports
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, BasicAer, IBMQ
from qiskit.visualization import plot_histogram, plot_bloch_multivector
### Creating 3 qubit and 2 classical bits in each separate register
qr = QuantumRegister(3)
crz = Cla... |
https://github.com/peiyong-addwater/Hackathon-QNLP | peiyong-addwater | import collections
import pickle
import warnings
warnings.filterwarnings("ignore")
import os
from random import shuffle
import random
from discopy.tensor import Tensor
from discopy import Word
from discopy.rigid import Functor
from discopy import grammar
import seaborn as sns
import pandas as pd
import mat... |
https://github.com/qiskit-community/community.qiskit.org | qiskit-community | from qiskit import *
from qiskit.visualization import plot_histogram
measure_z = QuantumCircuit(1,1)
measure_z.measure(0,0)
measure_z.draw(output='mpl')
measure_x = QuantumCircuit(1,1)
measure_x.h(0)
measure_x.measure(0,0)
measure_x.draw(output='mpl')
qc_0 = QuantumCircuit(1)
qc_0.draw(output='mpl... |
https://github.com/khaledalam/QuantumComputingAndPrimesAndOthers | khaledalam | # Author: Khaled Alam(khaledalam.net@gmail.com)
'''
Guess binary string (secret) of length N in 1 shot only using quantum computing circuit!
~ by using clasical computers we need at least N shots to guess string (secret) of length N
~ by using quantum computer we need 1 shot to guess string (secre... |
https://github.com/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | from sympy import *
init_printing(use_unicode=True)
r1,r2,r3,s1,s2,s3 = symbols('r_1 r_2 r_3 s_1 s_2 s_3')
I = Matrix([[1,0],[0,1]]); X = Matrix([[0,1],[1,0]]); Y = Matrix([[0,-1j],[1j,0]]); Z = Matrix([[1,0],[0,-1]])
rho = (1/2)*(I+r1*X+r2*Y+r3*Z); sigma = (1/2)*(I+s1*X+s2*Y+s3*Z)
#rho, sigma
def frho(r1,r2,... |
https://github.com/TRSasasusu/qiskit-quantum-zoo | TRSasasusu | """The following is python code utilizing the qiskit library that can be run on extant quantum
hardware using 5 qubits for factoring the integer 15 into 3 and 5. Using period finding,
for a^r mod N = 1, where a = 11 and N = 15 (the integer to be factored) the problem is to find
r values for this identity such that... |
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/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/quantumjim/qreative | quantumjim | import sys
sys.path.append('../')
import CreativeQiskit
result = CreativeQiskit.bell_correlation('ZZ')
print(' Probability of agreement =',result['P'])
result = CreativeQiskit.bell_correlation('XZ')
print(' Probability of agreement =',result['P'])
result = CreativeQiskit.bell_correlation('ZX')
print... |
https://github.com/tomtuamnuq/compare-qiskit-ocean | tomtuamnuq | import time
import numpy as np
from qiskit import BasicAer
from qiskit.aqua import QuantumInstance, aqua_globals
from qiskit.aqua.algorithms import QAOA
from qiskit.aqua.components.optimizers import COBYLA
from qiskit.optimization.algorithms import MinimumEigenOptimizer, CplexOptimizer
from qiskit.optimizatio... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.transpiler.passes import RemoveBarriers
circuit = QuantumCircuit(1)
circuit.x(0)
circuit.barrier()
circuit.h(0)
circuit = RemoveBarriers()(circuit)
circuit.draw('mpl') |
https://github.com/MAI-cyber/QIT | MAI-cyber | ! pip install numpy
! pip install qiskit
! pip install matplotlib
from qiskit import QuantumCircuit, Aer ,BasicAer, execute
from qiskit.visualization import plot_bloch_multivector, plot_histogram, plot_state_qsphere
from qiskit.quantum_info import Statevector
import matplotlib.pyplot as plt
import numpy as np... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library.standard_gates import HGate
qc1 = QuantumCircuit(2)
qc1.x(0)
qc1.h(1)
custom = qc1.to_gate().control(2)
qc2 = QuantumCircuit(4)
qc2.append(custom, [0, 3, 1, 2])
qc2.draw('mpl') |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import json
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import clear_output
from qiskit import QuantumCircuit
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit import ParameterVector
from qiskit.circuit.library import ZFeatureMap
from qiskit.quantum_info import Spar... |
https://github.com/Fergus-Hayes/qiskit_tools | Fergus-Hayes | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ
import qiskit_tools as qt
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
phase = True
digit_A = 5.25
digit_B = 7.5
print(digit_A,'x',digit_B,'=',digit_A*digit_B)
nintA = qt.get_nint(digit_A)
... |
https://github.com/mballarin97/mps_qnn | mballarin97 | # This code is part of qcircha.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.