repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
https://github.com/Interlin-q/diskit
Interlin-q
import sys sys.path.append("..") from diskit import * import warnings warnings.filterwarnings("ignore") circuit_topo = Topology() circuit_topo.create_qmap(3, [2, 3, 3], "sys") circuit_topo.qmap, circuit_topo.emap print("Total Number of Qubits in Topology : ", circuit_topo.num_qubits()) print("Total Numbe...
https://github.com/COFAlumni-USB/qiskit-fall-2022
COFAlumni-USB
import numpy as np import math import qiskit as qiskit from numpy import sqrt from random import randint from qiskit import * from qiskit import Aer, QuantumCircuit, IBMQ, execute, quantum_info, transpile from qiskit.visualization import plot_state_city, plot_bloch_multivector from qiskit.visualization import p...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer all_pairs = ['00','01','10','11'] for pair in all_pairs: # # your code is here ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # OUR SOLUTION # # initial case # We assume that the probability of getting head is 1 at the beginning, # because Asja will start with one euro. prob_head = 1 prob_tail = 0 # # first coin-flip # # if the last result was head new_prob_head_from_head = prob_head * 0.6 new_prob_tail_from_head = p...
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 with open("e2d1_raw.pkl", "rb") as f: raw = pickle.load(f) with open("e2d1_qrem.pkl", "rb") as f: qrem = pickle.load(f) with open("e2d1_...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from qsvm_datasets import * from qiskit_aqua.utils import split_dataset_to_data_and_labels, map_label_to_class_name from qiskit_aqua.input import get_input_instance from qiskit_aqua import run_algorithm # setup aqua logging import logging from qiskit_aqua._logging import set_logging_config, build_logging_config...
https://github.com/JackHidary/quantumcomputingbook
JackHidary
"""키스킷 간단한 예제 프로그램.""" # 키스킷 패키지를 가져오세요. import qiskit # 1개 큐비트를 갖는 양자 레지스터를 생성하세요. qreg = qiskit.QuantumRegister(1, name='qreg') # 1개 큐비트와 연결된 고전 레지스터를 생성하세요. creg = qiskit.ClassicalRegister(1, name='creg') # 위의 두 레지스터들로 구성된 양자 회로를 생성하세요. circ = qiskit.QuantumCircuit(qreg, creg) # NOT연산을 추가하세요. cir...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, transpile from qiskit.visualization import plot_circuit_layout from qiskit.providers.fake_provider import FakeVigo backend = FakeVigo() ghz = QuantumCircuit(3, 3) ghz.h(0) ghz.cx(0,range(1,3)) ghz.barrier() ghz.measure(range(3), range(3)) new_circ_lv3 = transpile(ghz, bac...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt from qiskit import QuantumCircuit, transpile from qiskit.providers.fake_provider import FakeAuckland backend = FakeAuckland() ghz = QuantumCircuit(15) ghz.h(0) ghz.cx(0, range(1, 15)) ghz.draw(output='mpl')
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/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/qiskit-translations-staging
qiskit-community
from qiskit.circuit.library import MCXGate gate = MCXGate(4) from qiskit import QuantumCircuit circuit = QuantumCircuit(5) circuit.append(gate, [0, 1, 4, 2, 3]) circuit.draw('mpl')
https://github.com/qclib/qclib
qclib
# 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/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 deriva...
https://github.com/urwin419/QiskitChecker
urwin419
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) ### added h gate ### 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 inva...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# # your solution is here # # let's import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer # let's import randrange for random choices from ran...
https://github.com/108mk/Quantum_Algorithms_and_Qiskit
108mk
#!conda deactivate !conda update anaconda-navigator !conda update conda !conda update conda !conda update anaconda import numpy as np a = np.array([[ 1., 0., 0., 0.], [ 0., 1., 0., 0.], [ 0., 0., 0., 1.], [ 0., 0., 1., 0.]]) p = q =r= s = 1 b = np.array([[ p, 0.,...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver, QAOA, SamplingVQE from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import TwoLocal from qiskit.result import QuasiDistribution from qiskit_aer.primitives import Sampler from qiskit_finance.applications.optimizati...
https://github.com/AnshDabkara/Qiskit_Algorithm
AnshDabkara
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/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# 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/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/UST-QuAntiL/qiskit-service
UST-QuAntiL
# ****************************************************************************** # Copyright (c) 2020-2021 University of Stuttgart # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. # # Licensed under the Apache License, Version 2.0 (the "License"...
https://github.com/duartefrazao/Quantum-Finance-Algorithms
duartefrazao
from qiskit import BasicAer,Aer from qiskit.aqua import aqua_globals, QuantumInstance from qiskit.aqua.algorithms import QAOA, NumPyMinimumEigensolver,VQE from qiskit.circuit.parameter import Parameter from qiskit.optimization.algorithms import MinimumEigenOptimizer, RecursiveMinimumEigenOptimizer,GroverOptimizer ...
https://github.com/IvanIsCoding/Quantum
IvanIsCoding
%matplotlib inline from qiskit import * # The following code is for nicer display of the matrices from IPython.display import display, Markdown def format_float(x): if x % 1 == 0: return int(x) else: return x def format_imaginary(z): if abs(z.imag) < 1e-15: return "{...
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/Z-928/Bugs4Q
Z-928
from qiskit import Aer, QuantumCircuit 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(3))) back...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/bertolinocastro/quantum-computing-algorithms
bertolinocastro
# A Quantum Circuit to Construct All Maximal Cliques Using Grover’s Search Algorithm ## Chu Ryang Wie ### DOI: https://arxiv.org/abs/1711.06146v2 from sympy import * #import sympy.physics.quantum as qp # quantum physics from sympy.physics.quantum.qubit import * from sympy.physics.quantum import Dagger, Tens...
https://github.com/danieljaffe/quantum-algorithms-qiskit
danieljaffe
#!pip install qiskit import numpy as np import matplotlib.pyplot as plt from math import floor, pi, sqrt from time import process_time from qiskit import * from qiskit.quantum_info.operators import Operator from qiskit.visualization import plot_histogram from qiskit.circuit import Gate def get_bitstring_pe...
https://github.com/abhik-99/Qiskit-Summer-School
abhik-99
!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/vandnaChaturvedi/Qauntum_algorithms_Qiskit
vandnaChaturvedi
# @title Copyright 2020 The Cirq 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agree...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
from qiskit import QuantumCircuit from qiskit.visualization import visualize_transition,circuit_drawer from math import pi qc=QuantumCircuit(2) qc.h(0) qc.cx(0,1) qc.draw(output="mpl") qc=QuantumCircuit(2) qc.h(0) qc.cx(0,1) circuit_drawer(qc,output="mpl") qc=QuantumCircuit(1) qc.h(0) qc.draw(output=...
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/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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import execute, pulse d0 = pulse.DriveChannel(0) with pulse.build() as pulse_prog: pulse.play(pulse.Constant(100, 1.0), d0) pulse_prog.draw()
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer # define a quantum register with one qubit qreg1 = QuantumRegister(1) # define a classi...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import transpile, QuantumCircuit import qiskit.quantum_info as qi from qiskit_aer import AerSimulator from qiskit_aer.noise import NoiseModel, amplitude_damping_error from qiskit.tools.visualization import plot_histogram # CNOT matrix operator with qubit-0 as control and qubit-1 as target cx_op ...
https://github.com/alejomonbar/Quantum-Supply-Chain-Manager
alejomonbar
%load_ext autoreload %autoreload 2 # pip install pennylane import pennylane as qml from pennylane import numpy as np from pennylane.optimize import NesterovMomentumOptimizer import tensorflow as tf import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import StandardScaler impor...
https://github.com/if-quantum/pairwise-tomography
if-quantum
# pylint: disable=missing-docstring import unittest import itertools import numpy as np from qiskit import QuantumRegister, QuantumCircuit, execute, Aer from qiskit.quantum_info import state_fidelity from qiskit.quantum_info import partial_trace from qiskit.quantum_info.states import DensityMatrix from ...
https://github.com/shantomborah/Quantum-Algorithms
shantomborah
import numpy as np from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import Aer, execute from qiskit.circuit import Gate from qiskit.visualization import plot_bloch_multivector from math import pi q = QuantumRegister(3, name='q') c = ClassicalRegister(2, name='c') circ = Quantu...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
#!/usr/bin/env python3 # 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. # # An...
https://github.com/quantum-tokyo/qiskit-handson
quantum-tokyo
# Qiskitライブラリーを導入 from qiskit import * # 描画のためのライブラリーを導入 import matplotlib.pyplot as plt %matplotlib inline # Qiskitバージョンの確認 qiskit.__qiskit_version__ # 1量子ビット回路を定義 q1 = QuantumCircuit(1) ## 回路を描画 q1.draw(output="mpl") # 量子ゲートで回路を作成 q1.x(0) q1.x(0) ## 回路を描画 q1.draw(output="mpl") # 状態ベクトルシミ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse d0 = pulse.DriveChannel(0) d1 = pulse.DriveChannel(1) with pulse.build() as pulse_prog: with pulse.align_right(): # this pulse will start at t=0 pulse.play(pulse.Constant(100, 1.0), d0) # this pulse will start at t=80 pulse.play(pulse.Constant(20,...
https://github.com/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 deriv...
https://github.com/ColibrITD-SAS/mpqp
ColibrITD-SAS
import pytest from mpqp.qasm.qasm_to_qiskit import qasm2_to_Qiskit_Circuit from qiskit import QuantumCircuit @pytest.mark.parametrize( "qasm_code, gate_names", [ ( """OPENQASM 2.0;""", [], ), ( """OPENQASM 2.0; include "qe...
https://github.com/Heisenbug-s-Dog/qnn_visualization
Heisenbug-s-Dog
# OpenMP: number of parallel threads. %env OMP_NUM_THREADS=1 # Plotting %matplotlib inline import matplotlib.pyplot as plt # PyTorch import torch import torch.nn as nn import torch.optim as optim from torch.optim import lr_scheduler import torchvision from torchvision import datasets, models, transforms ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.units import DistanceUnit from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver( atom="H 0 0 0; H 0 0 0.735", basis="sto3g", charge=0, spin=0, unit=DistanceUnit.ANGSTROM, ) es_problem = driver.run() from qiskit_nature.second_q.mappers import J...
https://github.com/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/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/qiskit-community/qiskit-translations-staging
qiskit-community
import qiskit.qasm3 program = """ OPENQASM 3.0; include "stdgates.inc"; input float[64] a; qubit[3] q; bit[2] mid; bit[3] out; let aliased = q[0:1]; gate my_gate(a) c, t { gphase(a / 2); ry(a) c; cx c, t; } gate my_phase(a) c { ctrl ...
https://github.com/PabloMartinezAngerosa/QAOA-uniform-convergence
PabloMartinezAngerosa
from tsp_qaoa import test_solution from qiskit.visualization import plot_histogram import networkx as nx import numpy as np import json import csv # Array of JSON Objects # Sort the JSON data based on the value of the brand key UNIFORM_CONVERGENCE_SAMPLE.sort(key=lambda x: x["mean"]) # genera las d...
https://github.com/soumya-s3/qiskit_developer_test_notebook
soumya-s3
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/sayana25/IQCQ-UPES-2023
sayana25
pip install qiskit !pip install pylatexenc pip install qiskit-aer pip install git+https://github.com/Qiskit/qiskit-terra.git import numpy as np # Importing standard Qiskit libraries from qiskit import QuantumCircuit, transpile, assemble, Aer, IBMQ, execute from qiskit.quantum_info import Statevector f...
https://github.com/qiskit-community/qiskit-dell-runtime
qiskit-community
# 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/jonasmaziero/computacao_quantica_qiskit_sbf_2023
jonasmaziero
def qc_alice_encoding(cb): from qiskit import QuantumCircuit qc = QuantumCircuit(1, name='AE') if cb == '00': qc.id(0) elif cb == '01': qc.x(0) elif cb == '10': qc.z(0) elif cb == '11': qc.x(0); qc.z(0) return qc cb = '11' qcae = qc_alice_encoding...
https://github.com/bagmk/Quantum_Machine_Learning_Express
bagmk
# The code below is a hack in case Travis' kernel fails. #import os #os.environ['KMP_DUPLICATE_LIB_OK'] ='True' import sys sys.path.append('../../Pyfiles') # Pull in the helper files. from experiments import * # Set up the experiment circuitID = 1 epochs = 20 import numpy as np import sys np.set_p...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import QuantumCircuit from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler from qiskit_finance.circuit.library import NormalDistribution # can be used in case a...
https://github.com/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/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 """ from qiskit import Aer, IBMQ # Do the necessary import for our program from qiskit.utils import QuantumInstance from qiskit.algorithms import Grover, AmplificationProblem from qiskit.circuit.libr...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer qreg = QuantumRegister(4) # quantum register with 4 qubits creg = ClassicalRegister(4) # cl...
https://github.com/qiskit-community/qiskit-cold-atom
qiskit-community
# 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/JamesTheZhang/Qiskit2023
JamesTheZhang
######################################## # ENTER YOUR NAME AND WISC EMAIL HERE: # ######################################## # Name: Rochelle Li # Email: rli484@wisc.edu ## Run this cell to make sure your grader is setup correctly %set_env QC_GRADE_ONLY=true %set_env QC_GRADING_ENDPOINT=https://qac-grading.q...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(3, 'q') anc = QuantumRegister(1, 'ancilla') cr = ClassicalRegister(3, 'c') qc = QuantumCircuit(qr, anc, cr) qc.x(anc[0]) qc.h(anc[0]) qc.h(qr[0:3]) qc.cx(qr[0:3], anc[0]) qc.h(qr[0:3]) qc.barrier(qr) qc.measure(qr,...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver() problem = driver.run() print(problem) from qiskit_nature.second_q.problems import ElectronicBasis driver.run_pyscf() problem = driver.to_problem(basis=ElectronicBasis.MO, include_dipole=True) print(problem.basis) ao_problem ...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
from sympy import * init_printing(use_unicode=True) %matplotlib inline p00,p01,p10,p11 = symbols('p_{00} p_{01} p_{10} p_{11}') th,ph = symbols('theta phi') Psi00 = Matrix([[cos(th)],[0],[0],[sin(th)]]) Psi01 = Matrix([[0],[sin(ph)],[cos(ph)],[0]]) Psi11 = Matrix([[0],[cos(ph)],[-sin(ph)],[0]]) Psi10 = Matrix...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Clifford, random_clifford qc = QuantumCircuit(3) cliff = random_clifford(2) qc.append(cliff, [0, 1]) qc.ccx(0, 1, 2) qc.draw('mpl')
https://github.com/Juan-Varela11/BNL_2020_Summer_Internship
Juan-Varela11
import numpy as np from qiskit import execute, QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.quantum_info.operators import Kraus, SuperOp from qiskit.providers.aer import QasmSimulator from qiskit.tools.visualization import plot_histogram # Qiskit Aer noise module imports from qiskit.providers....
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# load necessary Runtime libraries from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Session backend = "ibmq_qasm_simulator" # use the simulator from qiskit.circuit import Parameter from qiskit.opflow import I, X, Z mu = Parameter('$\\mu$') ham_pauli = mu * X cc = Parameter('$c$') ww = Para...
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/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, transpile from qiskit.visualization import plot_circuit_layout from qiskit.providers.fake_provider import FakeVigo backend = FakeVigo() ghz = QuantumCircuit(3, 3) ghz.h(0) ghz.cx(0,range(1,3)) ghz.barrier() ghz.measure(range(3), range(3)) ghz.draw(output='mpl')
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools from pprint import pprint import pickle import time import datetime # Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z) from qiskit.opflow import Zero, One, I, X, Y, Z from qiskit import QuantumCircuit, QuantumRegis...
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/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/PavanCyborg/Quantum-Algorithms-Benchmarking
PavanCyborg
#Assign these values as per your requirements. global min_qubits,max_qubits,skip_qubits,max_circuits,num_shots,Noise_Inclusion min_qubits=4 max_qubits=15 #reference files are upto 12 Qubits only skip_qubits=2 max_circuits=3 num_shots=4092 gate_counts_plots = True Noise_Inclusion = False saveplots = False...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import execute, pulse d0 = pulse.DriveChannel(0) with pulse.build() as pulse_prog: pulse.play(pulse.Constant(100, 1.0), d0) pulse_prog.draw()
https://github.com/noamsgl/IBMAscolaChallenge
noamsgl
import matplotlib.pyplot as plt import pandas as pd import seaborn as sns import numpy as np from ipywidgets import interact, interactive, fixed, interact_manual, FloatSlider, Layout import ipywidgets as widgets sns.set(style='whitegrid', palette='deep', font_scale=1.1, rc={'figure.figsize': [8, 5]}) plt.rcParam...
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
from qiskit_optimization.problems import QuadraticProgram # define a problem qp = QuadraticProgram() qp.binary_var("x") qp.integer_var(name="y", lowerbound=-1, upperbound=4) qp.maximize(quadratic={("x", "y"): 1}) qp.linear_constraint({"x": 1, "y": -1}, "<=", 0) print(qp.prettyprint()) from qiskit_optimizati...
https://github.com/veenaiyuri/qiskit-education
veenaiyuri
from QiskitEducation import * qc = QuantumAlgorithm(3,3) q = qc.q; c = qc.c qc.h(q[0]) qc.h(q[1]) qc.cx(q[1], q[2]) qc.cx(q[0], q[1]) qc.h(q[0]) qc.measure(q[0], c[0]) qc.measure(q[1], c[1]) qc.cx(q[1], q[2]) qc.cz(q[0], q[2]) qc.h(q[2]) qc.measure(q[2], c[2]) data = qc.execute(histogram=True) prin...
https://github.com/ohadlev77/sat-circuits-engine
ohadlev77
# Copyright 2022-2023 Ohad Lev. # 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, # or in the root directory of this package("LICE...
https://github.com/HuangJunye/Qiskit-for-GameDev
HuangJunye
#!/usr/bin/env python # # Copyright 2019 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unle...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
%matplotlib inline from qiskit_finance import QiskitFinanceError from qiskit_finance.data_providers import * import datetime import matplotlib.pyplot as plt from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() data = RandomDataProvider( tickers=["TICKER1", "TICKER2...
https://github.com/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/qiskit-community/qiskit-translations-staging
qiskit-community
# You can show the phase of each state and use # degrees instead of radians from qiskit.quantum_info import DensityMatrix import numpy as np from qiskit import QuantumCircuit from qiskit.visualization import plot_state_qsphere qc = QuantumCircuit(2) qc.h([0, 1]) qc.cz(0,1) qc.ry(np.pi/3, 0) qc.rx(np.pi/5,...
https://github.com/Pitt-JonesLab/clonk_transpilation
Pitt-JonesLab
import sys sys.path.append("..") from mock_backends.ibm import * import itertools from qiskit.circuit.library import CXGate from clonk.backend_utils.configurable_backend_v2 import ConfigurableFakeBackendV2 import rustworkx as rx from abc import ABC, abstractmethod class AbstractModularBackend(Configurab...
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/qiskit-community/qiskit-translations-staging
qiskit-community
# You can make the bars more transparent to better see the ones that are behind # if they overlap. import numpy as np from qiskit.quantum_info import Statevector from qiskit.visualization import plot_state_city from qiskit import QuantumCircuit qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc = QuantumCir...
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/deveshq/QC-with-qiskit
deveshq
#some necessary imports libraries import numpy as np from numpy import pi import qiskit from qiskit import * from qiskit.tools.monitor import job_monitor from qiskit.visualization import plot_histogram, plot_gate_map, plot_circuit_layout, array_to_latex from qiskit.providers.aer import noise from qiskit.quant...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from qiskit_chemistry import QiskitChemistry from qiskit import Aer # from qiskit import IBMQ # IBMQ.load_accounts() # backend = IBMQ.get_backend('ibmq_16_melbourne') from qiskit import Aer backend = Aer.get_backend('statevector_simulator') # Input dictionary to configure Qiskit AQUA Chemistry for the chem...
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/urwin419/QiskitChecker
urwin419
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) qc.cx(1, 0) return qc def encode_message(qc, qubit, msg): if len(msg) != 2 or not set([0,1]).issubset({0,1}): raise ValueError(f"message '{msg}' is invalid") if msg[1] == "1": q...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import pulse d0 = pulse.DriveChannel(0) x90 = pulse.Gaussian(10, 0.1, 3) x180 = pulse.Gaussian(10, 0.2, 3) with pulse.build() as hahn_echo: with pulse.align_equispaced(duration=100): pulse.play(x90, d0) pulse.play(x180, d0) pulse.play(x90, d0) hahn_echo.draw()
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import json import time import warnings import matplotlib.pyplot as plt import numpy as np from IPython.display import clear_output from qiskit import ClassicalRegister, QuantumRegister from qiskit import QuantumCircuit from qiskit.algorithms.optimizers import COBYLA from qiskit.circuit.library import RealAm...
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_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) # plot using a Statevector state = Statevector(qc) plot_state_city(state)
https://github.com/QuSTaR/kaleidoscope
QuSTaR
# -*- 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/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...