repo stringclasses 885
values | file stringclasses 741
values | content stringlengths 4 215k |
|---|---|---|
https://github.com/googlercolin/Qiskit-Course | googlercolin | import numpy as np
import torch
from torchvision.transforms import ToTensor
from torch import no_grad
from torchvision import datasets
import torch.optim as optim
from torch.nn import (Module, Conv2d, Linear, Dropout2d, NLLLoss, MaxPool2d, Flatten, Sequential, ReLU)
import torch.nn as nn
import torch.nn.funct... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
top = QuantumCircuit(1)
top.x(0);
bottom = QuantumCircuit(2)
bottom.cry(0.2, 0, 1);
tensored = bottom.tensor(top)
tensored.draw('mpl') |
https://github.com/orpgol/quantum_algorithms_qiskit | orpgol | import numpy as np
from qiskit import BasicAer
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute
from qiskit.providers.ibmq import least_busy
from qiskit.visualization import plot_histogram
from qiskit import IBMQ, assemble, transpile
from qiskit.tools.monitor import job_monitor
fr... |
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/swe-bench/Qiskit__qiskit | swe-bench | # 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/WhenTheyCry96/qiskitHackathon2022 | WhenTheyCry96 | 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/JanLahmann/RasQberry | JanLahmann | #!/usr/bin/env python
# coding: utf-8
# Credits: https://github.com/wmazin/Visualizing-Quantum-Computing-using-fractals
#############################################################
# Importing standard python libraries
from typing import Tuple, List
from math import pi
# Importing standard Qiskit libraries
... |
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/InvictusWingsSRL/QiskitTutorials | InvictusWingsSRL | #Libraries needed to implement and simulate quantum circuits
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, transpile, qasm2, qasm3
from qiskit_aer import Aer
from qiskit.primitives import BackendSampler
#Custem functions to simplify answers
import Our_Qiskit_Functions as oq #a part of the ... |
https://github.com/baronefr/perceptron-dqa | baronefr | import tensorflow as tf
import tensorflow.linalg as tfl
import numpy as np
import matplotlib.pyplot as plt
from tqdm.notebook import tqdm
physical_devices = tf.config.list_physical_devices('GPU')
print('GPU devices:', physical_devices)
if physical_devices:
for device in physical_devices:
tf.c... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem
from qiskit.circuit.library import LinearAmplitudeFunction
from qiskit_aer.primitives import Sampler
from qiskit_finance.circuit.library import LogNormalDistribut... |
https://github.com/zeynepCankara/Introduction-Quantum-Programming | zeynepCankara | # vector v
v = [1,2,-3]
# vector u
u=[-2,3]
vu = []
for i in range(len(v)): # Each element of v will be replaced
for j in range(len(u)): # the vector u will come here after multiplying with the entry there
vu.append( v[i] * u[j] )
print("v=",v)
print("u=",u)
print("vu=",vu)
#
# your solu... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # -*- 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/grossiM/Qiskit_workshop1019 | grossiM | import numpy as np
from qiskit import *
%matplotlib inline
# 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 qu... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.algorithms.optimizers import SLSQP
from qiskit.circuit.library import TwoLocal
num_qubits = 2
ansatz = TwoLocal(num_qubits, "ry", "cz")
optimizer = SLSQP(maxiter=1000)
ansatz.decompose().draw("mpl", style="iqx")
from qiskit.primitives import Estimator
estimator = Estimator()
from qiskit.al... |
https://github.com/epelaaez/QuantumLibrary | epelaaez | # To clean enviroment variables
%reset
import numpy as np
import pandas as pd
import folium
import matplotlib.pyplot as plt
try:
import cplex
from cplex.exceptions import CplexError
except:
print("Warning: Cplex not found.")
import math
from qiskit.utils import algorithm_globals
from qis... |
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/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit_nature.second_q.drivers import GaussianForcesDriver
# if you ran Gaussian elsewhere and already have the output file
driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log")
# if you want to run the Gaussian job from Qiskit
# driver = GaussianForcesDriver(
# ['#p B... |
https://github.com/qiskit-community/qiskit-aqt-provider | qiskit-community | # This code is part of Qiskit.
#
# (C) Copyright 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.
#
# Any... |
https://github.com/shell-raiser/Qiskit-Developer-Certification-Notes-and-Code | shell-raiser | import qiskit.quantum_info as qi
from qiskit.circuit.library import FourierChecking #FourierChecking is an algorithm circuit built into the circuit library
from qiskit.visualization import plot_histogram
#these both are functions, among which, we find the corelativity
f=[1,-1,-1,-1]
g=[1,1,-1,-1]
circ = Fou... |
https://github.com/stevvwen/QAlgoImplementation | stevvwen | # initialization
import numpy as np
import matplotlib
# importing Qiskit
from qiskit.providers.ibmq import least_busy
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ, BasicAer, assemble, transpile
from qiskit.quantum_info import Statevector
# import basic plot tools
... |
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/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
qc = QuantumCircuit(qr, cr)
qc.h(range(2))
qc.measure(range(2), range(2))
# apply x gate if the classical register has the value 2 (10 in binary)
qc.x(0).c_if(cr, 2)
# apply y gate if bi... |
https://github.com/pedroripper/qiskit_tutoriais | pedroripper | # Importando módulos
from qiskit import *
from qiskit.tools.visualization import plot_histogram
# Inicializando o circuito
nQubits = 2
nBits = 2
circuitoQuantico = QuantumCircuit(nQubits, nBits)
# Para aplicar uma porta no circuito devemos seguir o seguinte exemplo onde aplicamos uma Hadamard Gate
circu... |
https://github.com/Keerthiraj-Nagaraj/IBM-quantum-challenge-2020 | Keerthiraj-Nagaraj | # Importing standard Qiskit libraries and configuring account
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import IBMQ, Aer, execute
from qiskit.visualization import plot_bloch_multivector
# If you run this code outside IBM Quantum Experience,
# run the following commands to ... |
https://github.com/qiskit-community/community.qiskit.org | qiskit-community | secret_unitary = 'hz'
# make the imports that are necessary for our work
import qiskit as qk
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
from qiskit import execute, Aer
from qiskit import IBMQ
from qiskit.tools.visualization import plot_histogram
# simple function that applies a ser... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem
from qiskit.circuit.library import LinearAmplitudeFunction
from qiskit_aer.primitives import Sampler
from qiskit_finance.circuit.library import LogNormalDistribut... |
https://github.com/BryceFuller/qiskit_camp | BryceFuller | %matplotlib inline
import sys
sys.path.append("..")
import compress
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer
import numpy as np
from functools import partial
from qiskit.aqua.components.optimizers import SPSA
from multideterminant_prep import PrepareMultiDeterminantSta... |
https://github.com/kerenavnery/qmail | kerenavnery | from qiskit import *
from qiskit.quantum_info import Statevector
from parser import QSerializer
from SocketChannel import SocketChannel
class Channel:
def __init__(self):
#self._is_master = is_master
self._master_qargs_list = None
self._master_cargs_list = None
s... |
https://github.com/Pitt-JonesLab/mirror-gates | Pitt-JonesLab | from qiskit.algorithms.optimizers import SLSQP
from qiskit.circuit.library import TwoLocal
from qiskit.extensions import UnitaryGate
from weylchamber import canonical_gate
gate = UnitaryGate(canonical_gate(0.5, 0.25, 0.25).full())
# gate ='cx'
num_qubits = 2
ansatz = TwoLocal(num_qubits, ["ry", "rz"], ga... |
https://github.com/electricalgorithm/BernsteinVaziraniAlgorithm | electricalgorithm | """
This module implements the Bernstein-Vazirani Algorithm.
"""
from qiskit import Aer
from qiskit import QuantumCircuit, assemble, transpile
from qiskit.circuit.instruction import Instruction
class BVAlgorithm:
"""This class implements the Bernstein-Vazirani Algorithm."""
@staticmethod
de... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriva... |
https://github.com/qiskit-community/prototype-quantum-kernel-training | qiskit-community | # pylint: disable=import-error, wrong-import-position, too-few-public-methods, no-self-use, function-redefined
from functools import partial
from typing import Sequence
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
# Import Qiskit packages
from qiskit.circuit.library import ZZFeatu... |
https://github.com/ronitd2002/IBM-Quantum-challenge-2024 | ronitd2002 | # please create a 3 qubit GHZ circuit
# please create a 2 qubit ch gate with only cx and ry gate
# Enter your prompt here - Delete this line |
https://github.com/victor-onofre/Quantum_Algorithms | victor-onofre | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ, BasicAer
from qiskit.visualization import plot_bloch_multivector,plot_bloch_vector, plot_histogram, plot_state_qsphere
from qiskit.quantum_info import Statevector, partial_trace
import random
import numpy as np
import matpl... |
https://github.com/xtophe388/QISKIT | xtophe388 | # Importing QISKit
import math, sys
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
# Import basic plotting tools
from qiskit.tools.visualization import plot_histogram
# Import methods to connect with remote backends
from qiskit import available_backends, execute, register, get_backend
... |
https://github.com/0tt3r/QuaC-qiskit | 0tt3r | # -*- coding: utf-8 -*-
"""This module contains objective functions for optimizing noise models.
"""
from concurrent import futures
from typing import List
import numpy as np
from typing import Callable
from scipy import optimize
import nevergrad as ng
from qiskit import QuantumCircuit
from qiskit.providers... |
https://github.com/indian-institute-of-science-qc/qiskit-aakash | indian-institute-of-science-qc | # -*- 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/xtophe388/QISKIT | xtophe388 | # Imports
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from qiskit import QuantumProgram, QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import available_backends, get_backend, execute, register, least_busy
from qiskit.tools.visualization import plot_histogram, circuit_d... |
https://github.com/arnavdas88/QuGlassyIsing | arnavdas88 | from qiskit.providers.aer import QasmSimulator
from qiskit.providers.aer import AerSimulator
from qiskit import Aer, transpile
from qiskit.circuit.library import TwoLocal
from qiskit.algorithms import VQE
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import EfficientSU2
from qisk... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
# Create a circuit with a register of three qubits
circ = QuantumCircuit(3)
# H gate on qubit 0, putting this qubit in a superposition of |0> + |1>.
circ.h(0)
# A CX (CNOT) gate on control qubit 0 and target qubit 1 generating a Bell state.
circ.cx(0, 1)
# CX (CNOT) gate on cont... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit
qr = QuantumRegister(1)
cr = ClassicalRegister(1)
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.measure(0, 0)
qc.draw('mpl') |
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.tools.visualization import plot_bloch_vector
from qiskit.tools.visualization import plot_histogram,plot_bloch_multivector
import numpy as np
... |
https://github.com/minnukota381/Quantum-Computing-Qiskit | minnukota381 | from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram
# Create a quantum circuit with 2 qubits
# The default initial state of qubits will be |0> or [1,0]
qc = QuantumCircuit(2)
# Apply X gate to change the input or target
qc.x(0)
qc.x(1)
#Applyi... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
# Build a quantum circuit
circuit = QuantumCircuit(3, 3)
circuit.x(1)
circuit.h(range(3))
circuit.cx(0, 1)
circuit.measure(range(3), range(3));
print(circuit)
circuit.draw()
# Matplotlib Drawing
circuit.draw(output='mpl')
# Dra... |
https://github.com/Spintronic6889/Introduction-of-Quantum-walk-its-application-on-search-and-decision-making | Spintronic6889 | %matplotlib inline
import matplotlib as mpl
from random import randrange
import numpy as np
import matplotlib.pyplot as plt
from random import randrange
pose=[]
for i in range(400):
pose.append([])
#print(pose)
#pose[-1]=1
#print(pose[-1])
pose[0]=200
for k in range(200):
rand = randrange(0,2)... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
# Import Qiskit
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
# Construct quantum circuit
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure([0,1], [0,1])
# Select the AerSimulator from the Aer provider
simulator = AerSimulator(method='... |
https://github.com/qBraid/qBraid | qBraid | # Copyright (C) 2024 qBraid
#
# This file is part of the qBraid-SDK
#
# The qBraid-SDK is free software released under the GNU General Public License v3
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
import numpy as np
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import RealAmplitudes
from qiskit.primitives import Sampler
from qiskit.utils import algorithm_globals
from sklearn.model_selection import train_test_split
from sklearn.preprocessing imp... |
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources | aryashah2k | from matplotlib.pyplot import bar
labels = []
elements = []
for i in range(8):
labels = labels + [i+1]
elements = elements + [1]
# visualize the values of elements in the list
bar(labels,elements)
#
# 1st step - query
#
# change the sign of the marked element, i.e., multiply it by -1
# ... |
https://github.com/Ben-Foxman/Quantum-Exploration | Ben-Foxman | # Superdense Coding Implementation Ben Foxman
import matplotlib.pyplot as plt
import numpy as np
from qiskit import *
bits = input("Enter 2 bits.") # the 2 bits to encode/decode
assert bits in ['00', '01', '10', '11']
# p1 encodes by creating map from each of the 4 bell states to each of the 4 2-bit code... |
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-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.draw('mpl') |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import transpile
from qiskit import QuantumCircuit
from qiskit.providers.fake_provider import FakeVigoV2
backend = FakeVigoV2()
qc = QuantumCircuit(2, 1)
qc.h(0)
qc.x(1)
qc.cp(np.pi/4, 0, 1)
qc.h(0)
qc.measure([0], [0])
qc_basis = transpile(qc, backend)
qc_basis.draw(output='mpl') |
https://github.com/sebasmos/QuantumVE | sebasmos | !pip install tensorflow==2.4.1
!pip install tensorflow-quantum
import tensorflow as tf
import tensorflow_quantum as tfq
import cirq
import sympy
import numpy as np
# visualization tools
%matplotlib inline
import matplotlib.pyplot as plt
from cirq.contrib.svg import SVGCircuit
a, b = sympy.symbols('... |
https://github.com/riddheshMarkandeya/shors-algorithm-quantum | riddheshMarkandeya | import math
import numpy as np
from qiskit import QuantumCircuit, Aer, transpile, execute
from qiskit.visualization import plot_histogram, circuit_drawer
from math import gcd
from fractions import Fraction
# Constants
N = 15
x = 7
n_count = 9 # number of counting qubits
# Controlled Unitary Operation
... |
https://github.com/kaelynj/Qiskit-HubbardModel | kaelynj | %matplotlib inline
import sys
sys.path.append('./src')
# Importing standard Qiskit libraries and configuring account
#from qiskit import QuantumCircuit, execute, Aer, IBMQ
#from qiskit.compiler import transpile, assemble
#from qiskit.tools.jupyter import *
#from qiskit.visualization import *
import matplotlib.p... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # 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 retain this
# copyright notice, an... |
https://github.com/qiskit-community/qiskit-cold-atom | qiskit-community | from qiskit_cold_atom.spins import SpinSimulator
from qiskit import QuantumCircuit, QuantumRegister
backend = SpinSimulator()
qc = QuantumCircuit(4)
qc.measure_all()
# confirm that an empty circuit will return '0 0 0 0'
job = backend.run(qc, spin=3)
print(job.result().get_counts())
from qiskit_nature.seco... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
#... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.circuit.library import QFT
def create_qpe_circuit(theta, num_qubits):
'''Creates a QPE circuit given theta and num_qubits.'''
# Step 1: Create a circuit with two quantum registers and one classica... |
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/donaldkaito/quantum-100knocks | donaldkaito | import numpy as np
from qiskit import QuantumCircuit, Aer
from qiskit.visualization import plot_bloch_multivector
from qiskit.quantum_info import Statevector
sim = Aer.get_backend("aer_simulator")
# 13の2進数表記
binary_13 = f"{13:05b}"
print(binary_13)
new_binary = binary_13[:2] + ("0" if binary_13[2] == "1" ... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # 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/arthurfaria/QC_basic_agorithms_qiskit | arthurfaria | # Do the necessary imports
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import IBMQ, Aer, transpile, assemble
from qiskit.visualization import plot_histogram, plot_bloch_multivector, array_to_latex
from qiskit.extensions import Initialize
from qiskit.ignis.v... |
https://github.com/shell-raiser/Introduction-to-Quantum-Computing-Quantum-Algorithms-and-Qiskit | shell-raiser | import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
#from ibm_quantum_widgets import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()
from qiskit import assemble... |
https://github.com/Fabiha-Noshin/Quantum-Algorithms-with-Qiskit | Fabiha-Noshin | import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ, execute, assemble
from qiskit.providers.ibmq import least_busy
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
# Loading your IBM Quantum acc... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.timeline import draw, IQXDebugging
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial')
draw(... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.utils import algorithm_globals
from qiskit.algorithms.minimum_eigensolvers import QAOA, NumPyMinimumEigensolver
from qiskit.algorithms.optimizers import COBYLA
from qiskit.primitives import Sampler
from qiskit_optimization.algorithms import (
MinimumEigenOptimizer,
RecursiveMinimumEigenOptimiz... |
https://github.com/JavaFXpert/quantum-circuit-pygame | JavaFXpert | #
# 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
#
# Unless required by applicab... |
https://github.com/Alice-Bob-SW/emulation-examples | Alice-Bob-SW | from qiskit import QuantumCircuit, execute, transpile
from typing import Optional
from matplotlib import pyplot as plt
import numpy as np
import scipy as sp
from tqdm.notebook import tqdm
import warnings
# set default plot parameters
plt.rcParams.update({
'figure.facecolor': 'white',
'axes.facecolor... |
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/GroenteLepel/qiskit-quantum-knn | GroenteLepel | """The quantum KNN algorithm."""
from typing import Dict, Optional, Union
import logging
import itertools
import numpy as np
import scipy.stats as stats
import qiskit as qk
import qiskit.result as qres
import qiskit.tools as qktools
from qiskit.utils import QuantumInstance
import qiskit.providers as qkp... |
https://github.com/Qiskit-Extensions/circuit-knitting-toolbox | Qiskit-Extensions | import numpy as np
from qiskit.circuit.random import random_circuit
from qiskit.quantum_info import SparsePauliOp
circuit = random_circuit(7, 6, max_operands=2, seed=1242)
observable = SparsePauliOp(["ZIIIIII", "IIIZIII", "IIIIIIZ"])
circuit.draw("mpl", scale=0.8)
from circuit_knitting.cutting.automated_c... |
https://github.com/qcware/qusetta | qcware | """Translating circuits to and from ``qiskit``."""
import qiskit
import qusetta as qs
from typing import List
__all__ = "Qiskit",
class Qiskit(qs.Conversions):
"""Translation methods for qiskit's representation of a circuit.
Example
--------
Create a qiskit circuit.
>>> impor... |
https://github.com/mspronesti/qlearnkit | mspronesti | import warnings
import logging
import numpy as np
from copy import deepcopy
from typing import List, Dict, Union, Optional
from qiskit import QuantumCircuit
from qiskit.result import Result
from qiskit.providers import Backend
from qiskit.tools import parallel_map
from qiskit.utils import QuantumInstance
... |
https://github.com/qiskit-community/qiskit-pocket-guide | qiskit-community | from qiskit import QuantumCircuit,Aer,transpile
from qiskit.visualization import plot_state_qsphere
from math import pi
backend = Aer.get_backend("aer_simulator_statevector")
qc = QuantumCircuit(3)
qc.rx(pi, 0)
qc.ry(pi/8, 2)
qc.swap(0, 2)
qc.h(0)
qc.cp(pi/2,0, 1)
qc.cp(pi/4, 0, 2)
qc.h(1)
qc.cp(pi/2, ... |
https://github.com/googlercolin/Qiskit-Course | googlercolin | 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>), Pauli operators (X, Y, Z), and the identity operator (I)
from qiskit.opflow import Zero, One, X, Y, Z, I
# Returns the XXX Heisenberg model for 3... |
https://github.com/shaurya010/Shor-s-Algorithm- | shaurya010 | from qiskit import IBMQ
from qiskit.utils import QuantumInstance
from qiskit.algorithms import Shor
IBMQ.enable_account('ENTER API KEY HERE') # Enter your API token here
provider = IBMQ.get_provider(hub='ibm-q')
backend = provider.get_backend('ibmq_qasm_simulator') # Specifies the quantum device
print('\n S... |
https://github.com/1chooo/Quantum-Oracle | 1chooo | #Program 2.1 Initialize qubit state
from qiskit import QuantumCircuit
import math
qc = QuantumCircuit(4)
qc.initialize([1,0],0)
qc.initialize([0,1],1)
qc.initialize([1/math.sqrt(2), 1/math.sqrt(2)],2)
qc.initialize([1/math.sqrt(2), -1/math.sqrt(2)],3)
qc.draw('mpl')
#Program 2.2 Initialize qubit state and sh... |
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
"""
print("Ch 7: Understanding your circuits with the unitary simulator")
print("------------------------------------------------------------")
# Import the required Qiskit classes
from qiskit import(QuantumCircuit, execut... |
https://github.com/minminjao/qiskit1 | minminjao | import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, 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)
provid... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriva... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure([0, 1], [0, 1])
circ.draw("mpl")
from qiskit import transpile, schedule as build_schedule
from qiskit.providers.fake_provider import FakeHanoi
backend = FakeHanoi()
transpiled_circ = transpile(circ, bac... |
https://github.com/zeynepCankara/Introduction-Quantum-Programming | zeynepCankara | from matplotlib.pyplot import bar
labels = []
L = []
for i in range(8):
labels = labels + [i+1]
L = L + [1]
# visualize the values of elements in the list
bar(labels,L)
#
# 1st step - query
#
# 4th element is marked flip the sign
L[3] = -1 * L[3]
# visualize the values of elements in the... |
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 | # useful additional packages
import matplotlib.pyplot as plt
import numpy as np
import networkx as nx
from qiskit_aer import Aer
from qiskit.tools.visualization import plot_histogram
from qiskit.circuit.library import TwoLocal
from qiskit_optimization.applications import Maxcut, Tsp
from qiskit.algorithms.min... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # 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/epelaaez/QuantumLibrary | epelaaez | import numpy as np
from qiskit.quantum_info import state_fidelity
def schmidt_decomp_even(state):
n = int(np.log2(len(state)))
mat = state.reshape(2 ** (n // 2), 2 ** (n // 2))
u, s, v = np.linalg.svd(mat)
a = [u[:, i].reshape(2 ** (n // 2), 1) for i in range(2 ** (n // 2))]
b... |
https://github.com/anpaschool/quantum-computing | anpaschool | from qiskit import *
from math import pi
import numpy as np
from qiskit.visualization import *
import matplotlib.pyplot as plt
qc = QuantumCircuit(1)
qc.h(0)
qc.draw(output='mpl')
# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc,backend).result().get_statevector()... |
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/psasanka1729/nisq-grover-qiskit-floquet-model | psasanka1729 | L = 8;
using PyCall
using Random
using LinearAlgebra
using SparseArrays
using DelimitedFiles
file = raw"gates_list_"*string(L)*".txt" # Change for every L.
M = readdlm(file)
# Name.
Gates_data_1 = M[:,1];
# Angle.
Gates_data_2 = M[:,2];
# Qubit.
Gates_data_3 = M[:,3];
Number_of_Gates = length(Gates_da... |
https://github.com/ionq-samples/getting-started | ionq-samples | import numpy as np
from qiskit import QuantumCircuit
# Building the circuit
# 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... |
https://github.com/vm6502q/qiskit-qrack-provider | vm6502q | # This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/theflyingrahul/qiskitsummerschool2020 | theflyingrahul | !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/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem
from qiskit.circuit.library import LinearAmplitudeFunction
from qiskit_aer.primitives import Sampler
from qiskit_finance.circuit.library import LogNormalDistribut... |
https://github.com/InvictusWingsSRL/QiskitTutorials | InvictusWingsSRL | #Libraries needed to implement and simulate quantum circuits
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, transpile
from qiskit_aer import Aer
from qiskit.primitives import BackendSampler
#from qiskit.providers.aer import Aer, execute
#Custem functions to simplify answers
import Our_Qis... |
https://github.com/abbarreto/qiskit2 | abbarreto | %run init.ipynb
2*acos(sqrt(2/3)), 2*asin(sqrt(1/3)).
cos(2*pi/3), sin(2*pi/3), cos(4*pi/3), sin(4*pi/3), cos(8*pi/3), sin(8*pi/3)
cos(2*pi/3), sin(2*pi/3), cos(4*pi/3), sin(4*pi/3), cos(8*pi/3), sin(8*pi/3)
|
https://github.com/parton-quark/RLSB-CongX-Qiskit | parton-quark | # (c) Copyright 2020 Shin Nishio, parton@sfc.wide.ad.jp
def tfc_to_qiskit(tfc_path):
tfc_file = open(tfc_path, "r", encoding = "utf_8")
# convert tfc_file into list of lines
tfc_lines = tfc_file.readlines()
# prepare .py file
tfc_path_left = tfc_path.split('.')
py_file_name = "RLSBCQ_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.