repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
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/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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.quantum_info import SparsePauliOp H2_op = SparsePauliOp.from_list( [ ("II", -1.052373245772859), ("IZ", 0.39793742484318045), ("ZI", -0.39793742484318045), ("ZZ", -0.01128010425623538), ("XX", 0.18093119978423156), ] ) print(f"Number of qubits: {...
https://github.com/Pitt-JonesLab/slam_decomposition
Pitt-JonesLab
# need to make figure which shows curved path to build CX and SWAP # ideally on the same weyl chamber plot from slam.utils.pd_playground import ParallelDrivenGateWidget, ImprovedCX, ImprovedSWAP import numpy as np from slam.utils.visualize import coordinate_2dlist_weyl from weylchamber import c1c2c3 cx = Impr...
https://github.com/SaashaJoshi/IBM-Qiskit-Summer-School-2020
SaashaJoshi
!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-aqt-provider
qiskit-community
# This code is part of Qiskit. # # (C) Copyright Alpine Quantum Technologies GmbH 2023 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # ...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# 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/mathelatics/QGSS-2023-From-Theory-to-Implementations
mathelatics
from qiskit import * %matplotlib inline from qiskit.tools.visualization import plot_histogram secret_number = '101001' qc = QuantumCircuit(6+1, 6) qc.h([0, 1, 2, 3, 4, 5]) qc.x(6) qc.h(6) qc.barrier() qc.draw(output='mpl') # building box of secret number qc.cx(5, 6) qc.cx(3, 6) qc.cx(0, 6) qc....
https://github.com/acfilok96/Quantum-Computation
acfilok96
from qiskit import * qr = QuantumRegister(2) cr = ClassicalRegister(2) circuit = QuantumCircuit(qr, cr) %matplotlib inline circuit.draw() circuit.h(qr[0]) circuit.draw(output = 'mpl') circuit.cx(qr[0], qr[1]) circuit.draw(output='mpl') circuit.measure(qr, cr) circuit.draw(output='mpl') ...
https://github.com/abhik-99/Qiskit-Summer-School
abhik-99
# -*- 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-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/jcylim/QiskitProject
jcylim
# useful additional packages import matplotlib.pyplot as plt #%matplotlib inline import numpy as np from pprint import pprint # importing QISKit from qiskit import QuantumProgram, QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import available_backends, execute, register, least_busy # import...
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/qiskit-community/qiskit-translations-staging
qiskit-community
# You can choose different colors for the real and imaginary parts of the density matrix. from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix from qiskit.visualization import plot_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) state = DensityMatrix(qc) plot_state_city(st...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit qc = QuantumCircuit(12) for idx in range(5): qc.h(idx) qc.cx(idx, idx+5) qc.cx(1, 7) qc.x(8) qc.cx(1, 9) qc.x(7) qc.cx(1, 11) qc.swap(6, 11) qc.swap(6, 9) qc.swap(6, 10) qc.x(6) qc.draw('mpl')
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)) depths = [] gate_counts = [] non_local_gate_counts = [] levels = [str(x) for x in range(4)...
https://github.com/bayesian-randomized-benchmarking/qiskit-advocates-bayes-RB
bayesian-randomized-benchmarking
#Import general libraries (needed for functions) import numpy as np import matplotlib.pyplot as plt #from IPython import display #Import Qiskit classes import qiskit from qiskit.tools.monitor import job_monitor from qiskit import Aer from qiskit.providers.aer.noise import NoiseModel from qiskit import Quant...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit qc = QuantumCircuit(2, 2) qc.h(0) qc.cx(0, 1) qc.measure([0, 1], [0, 1]) qc.draw('mpl')
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver( atom="H 0 0 0; H 0 0 0.72" # Two Hydrogen atoms, 0.72 Angstrom apart ) molecule = driver.run() from qiskit_nature.second_q.mappers import QubitConverter, ParityMapper qubit_converter = QubitConverter(ParityMapper()) hamiltonian =...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/jeevesh2002/QuantumKatasQiskit
jeevesh2002
# Run this cell using Ctrl+Enter (⌘+Enter on Mac). from testing import exercise from typing import Tuple import math Complex = Tuple[float, float] Polar = Tuple[float, float] @exercise def imaginary_power(n : int) -> int: # If n is divisible by 4 if n % 4 == 0: return 1 else: ...
https://github.com/UST-QuAntiL/qiskit-service
UST-QuAntiL
# ****************************************************************************** # Copyright (c) 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/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit_nature.second_q.hamiltonians import QuadraticHamiltonian # create Hamiltonian hermitian_part = np.array( [ [1.0, 2.0, 0.0, 0.0], [2.0, 1.0, 2.0, 0.0], [0.0, 2.0, 1.0, 2.0], [0.0, 0.0, 2.0, 1.0], ] ) antisymmetric_part = np.array( [...
https://github.com/tomtuamnuq/compare-qiskit-ocean
tomtuamnuq
import time from dwave.system import DWaveCliqueSampler, LeapHybridSampler from qiskit.optimization.algorithms import CplexOptimizer from random_lp.lp_random_gen import create_models from utilities.helpers import create_dwave_meo DIR = 'TEST_DATA' + "/" + "14_03_2021" + "/DENSE/" # select linear program t...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit_nature.second_q.drivers import PySCFDriver driver = PySCFDriver() problem = driver.run() fermionic_op = problem.hamiltonian.second_q_op() from qiskit_nature.second_q.mappers import JordanWignerMapper mapper = JordanWignerMapper() qubit_jw_op = mapper.map(fermionic_op) print(qubit_jw_op) fr...
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 import QuantumCircuit, execute from qiskit.visualization import plot_error_map from qiskit.providers.fake_provider import FakeVigoV2 backend = FakeVigoV2() plot_error_map(backend)
https://github.com/Qubit-MU/Qiskit_Fall_Fest_2023
Qubit-MU
######################################## # 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/AllenGabrielMarchen/HHL_implementation
AllenGabrielMarchen
#setup.py import numpy as np from scipy.linalg import expm from qiskit.extensions import UnitaryGate from qiskit.circuit.add_control import add_control from qiskit import Aer import circuit import hhl import tools #참고 논문 :Low Complexity Quantum Matrix Inversion A기gorithm for non-Hermitian Matrices d...
https://github.com/ttlion/ShorAlgQiskit
ttlion
""" This file allows to test the Multiplication blocks Ua. This blocks, when put together as explain in the report, do the exponentiation. The user can change N, n, a and the input state, to create the circuit: up_reg |+> ---------------------|----------------------- |+> ...
https://github.com/MadhavJivrajani/pyQSR
MadhavJivrajani
# -*- coding: utf-8 -*- # pylint: disable=no-member """An IBM Qiskit implementation of quantum shift registers.""" __author__ = "Madhav Jivrajani" from qiskit import QuantumCircuit, execute, Aer from qiskit.circuit.exceptions import CircuitError class QuantumLeftShift: """Circuit to implement a quant...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import sys, time sys.path.append("../") import Qconfig qx_config = { "APItoken": Qconfig.APItoken, "url": Qconfig.config['url']} print('Qconfig loaded from %s.' % Qconfig.__file__) # Imports import qiskit as qk from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qisk...
https://github.com/quantumjim/qreative
quantumjim
from qiskit import IBMQ IBMQ.save_account('MY_API_TOKEN') from qiskit import IBMQ IBMQ.load_accounts() from qiskit import IBMQ IBMQ.enable_account('MY_API_TOKEN') IBMQ.backends() import CreativeQiskit result = CreativeQiskit.bell_correlation('ZZ',device='ibmq_16_melbourne') print(' Probability of ...
https://github.com/urwin419/QiskitChecker
urwin419
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) ### added y gate ### qc.cx(0, 1) qc.cx(1, 0) return qc def encode_message(qc, qubit, msg): if len(msg) != 2 or not set([0,1]).issubset({0,1}): raise ValueError(f"message '{msg}' is ...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix from qiskit.visualization import plot_state_city qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) # plot using a DensityMatrix state = DensityMatrix(qc) plot_state_city(state)
https://github.com/agneya-1402/Quantum-HalfAdder
agneya-1402
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 import * # Loading your IBM Quantum account(s) #provider = IBMQ.load_account() ...
https://github.com/Herbrant/shor-algorithm-qiskit
Herbrant
"""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/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_lv0 = transpile(ghz, bac...
https://github.com/lancecarter03/QiskitLearning
lancecarter03
from qiskit import * from qiskit.tools.visualization import plot_histogram qr = QuantumRegister(2) cr = ClassicalRegister(2) circuit = QuantumCircuit(qr,cr) circuit.decompose().draw(output="mpl", initial_state=True) circuit.h(qr[0]) circuit.draw(output="mpl") circuit.cx(qr[0],qr[1]) circuit.draw(...
https://github.com/1chooo/Quantum-Oracle
1chooo
from qiskit import QuantumCircuit import math qc = QuantumCircuit(3) qc.rx(math.pi/2, 0) qc.ry(math.pi/2, 1) qc.rz(math.pi/2, 2) qc.draw("mpl")
https://github.com/sebasmos/QuantumVE
sebasmos
import sys sys.path.insert(0,'../') from __future__ import print_function import argparse import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from torch.utils.data import random...
https://github.com/jonasmaziero/computacao_quantica_qiskit
jonasmaziero
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/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
# General Imports import numpy as np # Visualisation Imports import matplotlib.pyplot as plt # Scikit Imports from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.svm import SVC from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler,...