repo
stringclasses
900 values
file
stringclasses
754 values
content
stringlengths
4
215k
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
import sys, math, logging import numpy as np from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, QiskitError class HWEA: """ Class to implement a hardware efficient ansatz for the QAOA algorithm. Based on the community detection circuit implemented by Francois-Marie Le Régent. ...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
import sys import math import numpy as np from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister class QFT: """ Class which generates the circuit to perform the Quantum Fourier Transform (or its inverse) as described in Mike & Ike Chapter 5. (Michael A Nielsen and Isaac L Ch...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from qiskit import QuantumCircuit, QuantumRegister import sys import math import numpy as np class QWALK: """ Class to implement the Quantum Walk algorithm as described in Childs et al. (https://arxiv.org/abs/quant-ph/0209131) A circuit implementing the quantum walk can be generated for a ...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from .Qbit_original import Qbit from .cz_layer_generation import get_layers from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister import math import sys import numpy as np class Qgrid: """ Class to implement the quantum supremacy circuits as found in https://www.nature.com/artic...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from .Qbit_Sycamore import Qbit from .ABCD_layer_generation import get_layers from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister import math import sys import numpy as np class Qgrid: """ Class to implement the quantum supremacy circuits as found in Arute, F., Arya, K., Babbu...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
import sys from qiskit import Aer, execute from quantum_circuit_generator.generators import gen_hwea n = 6 circ = gen_hwea(n, 1) print(circ) simulator = Aer.get_backend("statevector_simulator") result = execute(circ, simulator).result() sv = result.get_statevector(circ) print(sv) # entanglement measur...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
""" Teague Tomesh - 3/25/2019 Implementation of the UCCSD ansatz for use in the VQE algorithm. Based on the description given in Whitfield et al. (https://arxiv.org/abs/1001.3855?context=physics.chem-ph) Adapted from a Scaffold implementation by Pranav Gokhale] (https://github.com/epiqc/ScaffCC) NOTE: ...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
import numpy as np import pytest from qiskit import Aer from qiskit.algorithms.gradients import ReverseEstimatorGradient from qiskit.circuit.library import TwoLocal from qiskit.primitives import Estimator from qiskit.quantum_info import SparsePauliOp np.random.seed(0) max_parallel_threads = 12 gpu = Fals...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from qiskit.providers.jobstatus import JobStatus from qiskit.transpiler import CouplingMap from datetime import timedelta, datetime from pytz import timezone import time, subprocess, os, pickle, logging, qiskit_ibm_provider import qiskit_ibm_provider.hub_group_project from qiskit_ibm_runtime import IBMBackend fr...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
import random, pickle, os, copy, random, qiskit_aer, psutil from qiskit import QuantumCircuit from qiskit.converters import circuit_to_dag, dag_to_circuit from qiskit.dagcircuit.dagcircuit import DAGCircuit from qiskit.quantum_info import Statevector import numpy as np from qiskit_helper_functions.conversions i...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
from qiskit import QuantumCircuit from qiskit.circuit.library import CPhaseGate, HGate, TGate, XGate, YGate, ZGate from qiskit.converters import circuit_to_dag, dag_to_circuit import random, itertools class RandomCircuit(object): def __init__(self, width, depth, connection_degree, num_hadamards, seed) -> N...
https://github.com/weiT1993/qiskit_helper_functions
weiT1993
# 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/fvarchon/qiskit-intros
fvarchon
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, Aer, execute from qiskit_aqua.algorithms import Grover from qiskit.ignis.verification.randomized_benchmarking import RBFitter from qiskit_chemistry import QiskitChemistry api_token = '' url = '' from qiskit import IB...
https://github.com/fvarchon/qiskit-intros
fvarchon
# Your first Qiskit application from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(2) # qubits indexed as qr[0], qr[1] and qr[2] cr = ClassicalRegister(2) # classical bits indexed as cr[0], cr[1] and cr[2] circuit = QuantumCircuit(qr, cr) circuit.h(qr[0]) circuit.cx(qr[...
https://github.com/fvarchon/qiskit-intros
fvarchon
# 30 qubits = 16 GB num_qubits = 32 memoryneeded_GB = 16 * 2 ** (num_qubits - 30) print(memoryneeded_GB) # qiskit imports from qiskit import Aer from qiskit import IBMQ, execute from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit.tools.visualization import plot_histogram, plot_st...
https://github.com/fvarchon/qiskit-intros
fvarchon
from qiskit import execute from qiskit import transpiler help(execute) from qiskit import Aer, BasicAer backend = Aer.get_backend("qasm_simulator") help(backend) backend = BasicAer.get_backend("qasm_simulator") help(backend)
https://github.com/obliviateandsurrender/Quantum-Approximate-Thermalization
obliviateandsurrender
# Libraries Import import itertools import numpy as np from functools import reduce, partial from scipy.optimize import minimize import matplotlib.pyplot as plt %matplotlib inline # Qiskit from qiskit import BasicAer, QuantumRegister, QuantumCircuit, ClassicalRegister from qiskit import execute from qiskit...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.visualization import * from os import environ #local environment variable to store the access token :) token = environ.get('ibmq_token') # Loading IBM Q account account = IBMQ.save_acco...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ, assemble from qiskit.visualization import * from os import environ #local environment variable to store the access token :) token = environ.get('ibmq_token') # Loading your IBM Q account(s) accoun...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ, assemble, extensions from qiskit.visualization import * from os import environ #local environment variable to store the access token :) token = environ.get('ibmq_token') # Loading your IBM Q acco...
https://github.com/cjsproject/qiskit_learning
cjsproject
import numpy as np from matplotlib.image import imread import matplotlib.pyplot as plt import torch from torchvision import transforms from torchvision.datasets import MNIST # the data is not normalized, and needs to be converted to a np array... digits = MNIST('data', train=True, download=False) # conver...
https://github.com/cjsproject/qiskit_learning
cjsproject
import numpy as np import matplotlib.pyplot as plt import seaborn as sns import sklearn from sklearn import datasets from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumRegister from qiskit import QuantumCircuit from qiskit import Aer, execute from math import pi,log from qiskit im...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * from os import environ # Grab env var token = environ.get('ibmq_token') # ...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ from os import environ print(environ.get('QISKIT_TOKEN')) # Loading your IBM Q account(s) provider = IBMQ.load_account() # quasm_sim simulator = Aer.get_backend('qasm_simulator') # circuit on ...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ, assemble from qiskit.visualization import * from os import environ #local environment variable to store the access token :) token = environ.get('ibmq_token') # Loading your IBM Q account(s) accoun...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ, assemble, extensions from qiskit.visualization import * from os import environ #local environment variable to store the access token :) token = environ.get('ibmq_token') # Loading your IBM Q acco...
https://github.com/cjsproject/qiskit_learning
cjsproject
import numpy as np from matplotlib.image import imread import matplotlib.pyplot as plt import torch from torchvision import transforms from torchvision.datasets import MNIST # the data is not normalized, and needs to be converted to a np array... digits = MNIST('data', train=True, download=False) # conver...
https://github.com/cjsproject/qiskit_learning
cjsproject
import numpy as np import matplotlib.pyplot as plt import seaborn as sns import sklearn from sklearn import datasets from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumRegister from qiskit import QuantumCircuit from qiskit import Aer, execute from math import pi,log from qiskit im...
https://github.com/cjsproject/qiskit_learning
cjsproject
%matplotlib inline # Importing standard Qiskit libraries from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * from ibm_quantum_widgets import * # Loading your IBM Q account(s) provider = IBMQ...
https://github.com/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
""" Test Script """ from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister qrx = QuantumRegister(1, 'q0') qry = QuantumRegister(1, 'q1') cr = ClassicalRegister(1, 'c') qc = QuantumCircuit(qrx, qry, cr) qc.h(qrx) qc.x(qry) qc.h(qry) qc.barrier() qc.x(qry) qc.barrier() qc.h(qrx) qc.h(q...
https://github.com/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# This code is part of Qiskit. # # (C) Copyright IBM 2018, 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
import sys import os current_dir = os.getcwd() sys.path.append(current_dir) from quantum_circuit import QuantumCircuit # import qiskit.providers.fake_provider from qiskit.transpiler import CouplingMap import qiskit_ibm_runtime.fake_provider from Backend.backend import Backend class FakeBackend(Backend): ...
https://github.com/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# -*- 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/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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/DaisukeIto-ynu/KosakaQ
DaisukeIto-ynu
# 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/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 ... else: ...
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/jeevesh2002/QuantumKatasQiskit
jeevesh2002
# Run this cell using Ctrl+Enter (⌘+Enter on Mac). from testing import exercise, create_empty_matrix from typing import List import math, cmath Matrix = List[List[complex]] @exercise def matrix_add(a : Matrix, b : Matrix) -> Matrix: # You can get the size of a matrix like this: rows = len(a) ...
https://github.com/jeevesh2002/QuantumKatasQiskit
jeevesh2002
# Run this cell using Ctrl+Enter (⌘+Enter on Mac). from testing import exercise, create_empty_matrix from typing import List import math, cmath Matrix = List[List[complex]] @exercise def matrix_add(a : Matrix, b : Matrix) -> Matrix: # You can get the size of a matrix like this: rows = len(a) ...
https://github.com/jeevesh2002/QuantumKatasQiskit
jeevesh2002
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector # Create a Quantum Circuit acting on the q register circuit = QuantumCircuit(1) # print the statevector print(f"Initial Statevector: {Statevector.from_instruction(circuit).data}\n\n") # Add an X gate followed by a H gate to put th...
https://github.com/jeevesh2002/QuantumKatasQiskit
jeevesh2002
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector # Create a quantum circuit with one qubit qc = QuantumCircuit(1) # Put the qubit into an uneven superposition # ry(theta) is a rotation around the y-axis by angle theta qc.ry(1.0, 0) # Print the statevector |𝜓❭ print(f"The Qubi...
https://github.com/jeevesh2002/QuantumKatasQiskit
jeevesh2002
%kata T1_ApplyY operation ApplyY (q : Qubit) : Unit is Adj+Ctl { Y(q); // As simple as that } %kata T2_GlobalPhaseI operation GlobalPhaseI (q : Qubit) : Unit is Adj+Ctl { Z(q); Y(q); X(q); } %kata T3_SignFlipOnZero operation SignFlipOnZero (q : Qubit) : Unit is Adj+Ctl { X(q); ...
https://github.com/Slope86/QiskitExtension
Slope86
from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 circuit_EPR = qc2(2) # 1. 在qubit 0 的位置放入一個Hadamard gate circuit_EPR.h(0) # 2. 放入一個CNOT gate, 控制qubit為0, 目標qubit為1 circuit_EPR.cx(0, 1) # 3. 繪製電路圖 circuit_EPR.show_circ() ...
https://github.com/Slope86/QiskitExtension
Slope86
import math import random from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 state_unknown = sv2.from_label((random.random(), "0"), (random.random(), "1")) state_unknown.show_state() # Create a 2bits quantum circuit circ_init ...
https://github.com/Slope86/QiskitExtension
Slope86
import math from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 # Create a 4bits quantum circuit circ_init = qc2(4) # Make ground state qubit(0,1) and qubit(2,3) entangled into two EPR pairs circ_init.h([0,2]) circ_init.cx([0,2...
https://github.com/Slope86/QiskitExtension
Slope86
from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 circuit_EPR = qc2(2) # 1. put a Hadamard gate in the qubit 0 position circuit_EPR.h(0) # 2. put a CNOT gate, control qubit 0, target qubit 1 circuit_EPR.cx(0, 1) # 3. draw t...
https://github.com/Slope86/QiskitExtension
Slope86
import math import random from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 state_unknown = sv2.from_label((random.random(), "0"), (random.random(), "1")) state_unknown.show_state() # Create a 2bits quantum circuit circ_init ...
https://github.com/Slope86/QiskitExtension
Slope86
import math from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2 from qiskit_extension.state_vector2 import StateVector2 as sv2 # Create a 4bits quantum circuit circ_init = qc2(4) # Make ground state qubit(0,1) and qubit(2,3) entangled into two EPR pairs circ_init.h([0,2]) circ_init.cx([0,2...
https://github.com/Slope86/QiskitExtension
Slope86
"""Module to construct, simulate, and visualize quantum circuit""" from __future__ import annotations import itertools import typing from typing import List import numpy as np from IPython.display import Latex from numpy.typing import NDArray from qiskit import ClassicalRegister, QuantumCircuit, QuantumRe...
https://github.com/Slope86/QiskitExtension
Slope86
"""Module to store, manipulate and visualize quantum state vector.""" from __future__ import annotations import copy import itertools import re from typing import Iterable, List, Tuple import numpy as np from IPython.display import Latex from numpy.typing import NDArray from qiskit import QuantumCircuit ...
https://github.com/Tojarieh97/VQE
Tojarieh97
import numpy as np from qiskit.opflow import X, Z, I from qiskit.algorithms.optimizers import L_BFGS_B from qiskit.circuit.library import EfficientSU2 bfgs_optimizer = L_BFGS_B(maxiter=60) a_1 = np.random.random_sample() a_2 = np.random.random_sample() J_21 = np.random.random_sample() H_transverse_ising =...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.circuit.library.standard_gates import RXGate, RZGate, CXGate, CZGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister def anzats_circ(thetas, phis, D1, D2): qr = QuantumRegister(4, name="q") cr = ClassicalRegister(4, name='c') qc = QuantumCircuit(qr, cr) for d in...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.circuit.library.standard_gates import RXGate, RZGate, CXGate, CZGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister def anzats_circ1(thetas, D2, in_state): qr = QuantumRegister(4, name="q") qc = QuantumCircuit(qr) qc.initialize(in_state) for d in rang...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.circuit.library.standard_gates import RXGate, RZGate, CXGate, CZGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister import numpy as np def anzats_circ(thetas, D1, D2, in_state): qr = QuantumRegister(4, name="q") qc = QuantumCircuit(qr) qc.initialize(in_state) ...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.opflow import X, Z, I H2_op = (-1.052373245772859 * I ^ I) + \ (0.39793742484318045 * I ^ Z) + \ (-0.39793742484318045 * Z ^ I) + \ (-0.01128010425623538 * Z ^ Z) + \ (0.18093119978423156 * X ^ X) import numpy as np from qiskit.opflow import X, Z, I N = 2 H = 0...
https://github.com/Tojarieh97/VQE
Tojarieh97
import numpy as np np.random.seed(999999) target_distr = np.random.rand(2) # We now convert the random vector into a valid probability vector target_distr /= sum(target_distr) print(target_distr) from qiskit.circuit.library import EfficientSU2 ansatz = EfficientSU2(num_qubits=2, entanglement='linear') print(a...
https://github.com/Tojarieh97/VQE
Tojarieh97
import sys sys.path.append('../../') import numpy as np from qiskit import QuantumCircuit from qiskit.opflow import I, X, Y, Z import matplotlib.pyplot as plt from volta.observables import sample_hamiltonian from volta.hamiltonians import BCS_hamiltonian EPSILONS = [3, 3, 3, 3] V = -2 hamiltonian = 1 / ...
https://github.com/Tojarieh97/VQE
Tojarieh97
from openfermion.chem import MolecularData from openfermion.transforms import get_fermion_operator, jordan_wigner from openfermion.linalg import get_ground_state, get_sparse_operator import numpy import scipy import scipy.linalg # Load saved file for LiH. diatomic_bond_length = 1.2 geometry = [('H', (0., 0., ...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.algorithms import VQE from qiskit.algorithms.optimizers import SLSQP, L_BFGS_B from qiskit.circuit.library import TwoLocal num_qubits = 2 ansatz = TwoLocal(num_qubits, 'ry', 'cz') opt = SLSQP(maxiter=60) bfgs_optimizer = L_BFGS_B(maxiter=60) vqe = VQE(ansatz, optimizer=opt) ansatz.draw() from...
https://github.com/Tojarieh97/VQE
Tojarieh97
import sys sys.path.append('../../') import numpy as np from qiskit import QuantumCircuit from qiskit.opflow import I, X, Y, Z import matplotlib.pyplot as plt from volta.observables import sample_hamiltonian from volta.hamiltonians import BCS_hamiltonian EPSILONS = [3, 3] V = -2 hamiltonian = BCS_hamilt...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 from qiskit.circuit.library.standard_gates import RXGate, RZGate, RYGate, CXGate, CZGate, SGate, HGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister import numpy as np def get_linear_entangelment_ansatz(num_of_qubits, thetas, input_state, circuit_dep...
https://github.com/Tojarieh97/VQE
Tojarieh97
from qiskit.algorithms import VQE from qiskit import Aer from qiskit.utils import QuantumInstance, algorithm_globals seed = 50 algorithm_globals.random_seed = seed backend = Aer.get_backend('qasm_simulator') quantum_instance = QuantumInstance(backend=backend, shots=800, seed_transpiler=seed, seed_simulator...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 50 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qiski...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 50 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qiski...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 from qiskit.circuit.library.standard_gates import RXGate, RZGate, RYGate, CXGate, CZGate, SGate, HGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister import numpy as np def get_linear_entangelment_ansatz(num_of_qubits, thetas, input_state, circuit_dep...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 1000 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qis...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 100 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qisk...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 50 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qiski...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 from qiskit.circuit.library.standard_gates import RXGate, RZGate, RYGate, CXGate, CZGate, SGate, HGate from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister import numpy as np def get_linear_entangelment_ansatz(num_of_qubits, thetas, input_state, circuit_dep...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 100 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qisk...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 100 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qisk...
https://github.com/Tojarieh97/VQE
Tojarieh97
%load_ext autoreload %autoreload 2 import nbimporter from typing import Dict, Tuple, List import numpy as np from tqdm import tqdm QUBITS_NUM = 4 N = 2**QUBITS_NUM NUM_SHOTS = 1024 NUM_ITERATIONS = 100 CIRCUIT_DEPTH = 3 PARAMS_NUM = 2*QUBITS_NUM*(CIRCUIT_DEPTH+1) from qiskit import Aer from qisk...