repo stringclasses 900
values | file stringclasses 754
values | content stringlengths 4 215k |
|---|---|---|
https://github.com/C2QA/bosonic-qiskit | C2QA | from math import sqrt, pi
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
import oracle_simple
import composed_gates
def get_circuit(n, oracles):
"""
Build the circuit composed by the oracle black box and the other quantum gates.
:param n: The number of qubits (not including... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import math
import qiskit
from c2qa.circuit import CVCircuit
from c2qa.kraus import PhotonLossNoisePass
from c2qa.parameterized_unitary_gate import ParameterizedUnitaryGate
def discretize_circuits(
circuit: CVCircuit,
segments_per_gate: int = 10,
keep_state: bool = True,
... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import warnings
import qiskit
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit import Gate
from qiskit.circuit.library import UnitaryGate
from qiskit.circuit.parameter import ParameterExpression
class ParameterizedUnitaryGate(Gate):
"""UnitaryGate sublcass that stores the operat... |
https://github.com/C2QA/bosonic-qiskit | C2QA | from qiskit import QuantumRegister
class QumodeRegister:
"""Wrapper to QisKit QuantumRegister to represent multiple qubits per qumode.
Implements __getitem__ to make QumodeRegister appear to work just like QuantumRegister with instances of CVCircuit.
"""
def __init__(
self, num_qum... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import json
import logging
import numpy as np
import warnings
from functools import wraps
from typing import Any, Callable, Optional, Tuple, Union
from qiskit import IBMQ, QuantumCircuit, assemble
from qiskit.circuit import Barrier, Gate, Instruction, Measure
from qiskit.circuit.library import UGate, U3Ga... |
https://github.com/C2QA/bosonic-qiskit | C2QA | from pathlib import Path
import numpy
import pytest
import qiskit
import c2qa
def __build_subcircuit():
# Define Hamiltonian parameters
omega_R = 2
omega_Q = 5
chi = 0.1
# Set number of qubits per qumode
num_qubits_per_qumode = 3
# Choose alpha for coherent state
... |
https://github.com/C2QA/bosonic-qiskit | C2QA | from qiskit import QuantumCircuit
from . import circuit_constructor, circuit_eq
def test_circuit_constructor():
gates_list = ["h", "hs", "hs", "i", "i", "h"]
result = circuit_constructor(gates_list)
result_dag = circuit_constructor(gates_list, True)
expected = QuantumCircuit(6)
expected... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import c2qa
import pytest
import qiskit
import math
import numpy
import random
def test_cv_c_d(capsys):
"""The cv_c_d gate should discretize all params (i.e., default behavior)"""
with capsys.disabled():
num_qumodes = 2
num_qubits_per_qumode = 2
qmr = c2qa.QumodeRegister(n... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import random
import c2qa
import numpy
import qiskit
def count_nonzero(statevector: qiskit.quantum_info.Statevector):
"""Re-implement numpy.count_nonzero using numpy.isclose()."""
nonzero = len(statevector.data)
for state in statevector.data:
if numpy.isclose(state, 0):
nonz... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import numpy
import qiskit
import qiskit_aer
import scipy.linalg
import c2qa
# Define parameters
num_qubits_per_qumode = 2
cutoff = 2**num_qubits_per_qumode
alpha = numpy.sqrt(numpy.pi)
def displacement_operator(arg):
"""Create displacement operator matrix"""
a = numpy.diag(numpy.sqrt(ran... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import math
from pathlib import Path
import pytest
import random
import c2qa
import numpy as np
import qiskit
import qiskit_aer.noise as noise
from qiskit_aer.noise.noiseerror import NoiseError
from qiskit_aer.noise.passes.relaxation_noise_pass import RelaxationNoisePass
from qiskit.visualization impo... |
https://github.com/C2QA/bosonic-qiskit | C2QA | from pathlib import Path
import c2qa
import numpy
import qiskit
def assert_changed(state, result):
assert result.success
# print()
# print(circuit.draw("text"))
# print(state)
# TODO - better understand what the state vector results should be
assert count_nonzero(state) > 1
... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import qiskit
import qiskit_aer
def test_qiskit():
"""Verify we can do a simple QisKit circuit without our custom gates."""
qr = qiskit.QuantumRegister(6)
cr = qiskit.ClassicalRegister(6)
circuit = qiskit.circuit.QuantumCircuit(qr, cr)
circuit.cx(qr[0:1], qr[2])
circuit.save_statevec... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # 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/C2QA/bosonic-qiskit | C2QA | from pathlib import Path
import c2qa
import numpy
import qiskit
def test_plot_zero(capsys):
with capsys.disabled():
qmr = c2qa.QumodeRegister(num_qumodes=1, num_qubits_per_qumode=4)
qr = qiskit.QuantumRegister(size=1)
circuit = c2qa.CVCircuit(qmr, qr)
# dist = nump... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Import packages that will be used
import c2qa
import numpy as np... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import scqubits as sc
tmon = sc.Transmon(
EJ = 31,
EC = .8,
ng = 0,
ncut = 110
)
evals = tmon.eigenvals()[:5]
omega = evals[1]-evals[0]
osc = sc.Oscillator(
E_osc = omega
)
import numpy as np
from matplotlib import pyplot as plt
xlist = np.linspace(-np.pi,np.pi,100)
mineng = min... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
import c2qa
import numpy as np
import qiskit
# Define Hamil... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Import packages that will be used
import c2qa
import numpy as np... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # The C2QA pacakge is currently not published to PyPI.
# To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to g... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/CQCL/pytket-qiskit | CQCL | # Copyright 2019 Cambridge Quantum Computing
#
# 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 ... |
https://github.com/CQCL/pytket-qiskit | CQCL | # Copyright 2020-2024 Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to ... |
https://github.com/CQCL/pytket-qiskit | CQCL | import qiskit
from qiskit.dagcircuit import DAGCircuit
from qiskit.providers import BaseBackend
from qiskit.transpiler.basepasses import TransformationPass, BasePass
from qiskit.converters import circuit_to_dag, dag_to_circuit
from pytket._transform import Transform
from pytket._routing import route, Architectu... |
https://github.com/CQCL/pytket-qiskit | CQCL | # -*- 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/CQCL/pytket-qiskit | CQCL | # Copyright 2019 Cambridge Quantum Computing
#
# 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 ... |
https://github.com/CQCL/pytket-qiskit | CQCL | ################################################################################
# © Copyright 2021-2022 Zapata Computing Inc.
################################################################################
import math
import os
from copy import deepcopy
import pytest
import qiskit
from qeqiskit.backend impo... |
https://github.com/CQCL/pytket-qiskit | CQCL | # Copyright 2020-2024 Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to ... |
https://github.com/CQCL/pytket-qiskit | CQCL | # Copyright 2019-2024 Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to ... |
https://github.com/mtreinish/qiskit-workshop | mtreinish | |
https://github.com/LauraGentini/QRL | LauraGentini | __author__ = 'QRL_team'
from qiskit import *
from qiskit.circuit.library import GroverOperator
from qiskit.quantum_info import Statevector
import numpy as np
from math import ceil
class GroverMazeLearner:
"""
Inits a quantum QLearner object for given environment.
Environment must be discrete ... |
https://github.com/LauraGentini/QRL | LauraGentini | # General imports
import numpy as np
import matplotlib.pyplot as plt
# Qiskit Circuit imports
from qiskit.circuit import QuantumCircuit, QuantumRegister, Parameter, ParameterVector, ParameterExpression
from qiskit.circuit.library import TwoLocal
# Qiskit imports
import qiskit as qk
from qiskit.utils import ... |
https://github.com/LauraGentini/QRL | LauraGentini | # General imports
import numpy as np
import matplotlib.pyplot as plt
# Qiskit imports
import qiskit as qk
from qiskit.utils import QuantumInstance
# Qiskit Machine Learning imports
import qiskit_machine_learning as qkml
from qiskit_machine_learning.neural_networks import CircuitQNN
from qiskit_machine_lear... |
https://github.com/LauraGentini/QRL | LauraGentini | """
Python script containing functions definitions for the Quantum Deep-Q Learning approach,
used in the DQN-analysis Jupyter Notebook.
Prepared for Qiskit Hackathon Europe by:
Stefano, Paolo, Jani & Laura, 2021.
"""
# General imports
import numpy as np
import matplotlib.pyplot as plt
# Qiskit Circ... |
https://github.com/LauraGentini/QRL | LauraGentini | __author__ = 'QRL_team'
from qiskit import *
from qiskit.circuit.library import GroverOperator
from qiskit.quantum_info import Statevector
import numpy as np
from math import ceil
from qttt import QTicTacToeEnv
class GroverQuantumBoardLearner:
"""
Inits a quantum QLearner object.
Chosen en... |
https://github.com/LauraGentini/QRL | LauraGentini | __author__ = 'QRL_team'
import numpy as np
from gym import spaces
from itertools import permutations
from qiskit import (
QuantumCircuit,
execute,
Aer)
from qiskit.circuit.library import (
HGate,
XGate,
CXGate)
class QTicTacToeEnv:
def __init__(self, grid_size):
"... |
https://github.com/clausia/qiskit-fall-fest-peru-2022 | clausia | from qiskit import QuantumRegister
qubit1 = QuantumRegister(1) # el parámetro indica cuántos qubits queremos
qubit2 = QuantumRegister(1, 'qreg') # se puede indicar un nombre al registro cuántico (parámetro opcional)
print(qubit1) # al no especificar el nombre, le asigna uno con una numeración consecutiva
prin... |
https://github.com/clausia/qiskit-fall-fest-peru-2022 | clausia | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
A = QuantumRegister(1, 'a')
B = QuantumRegister(1, 'b')
CarryIn = QuantumRegister(1, 'cin-sum')
cero = QuantumRegister(1, 'aux-cout')
adder = QuantumCircuit(A, B, CarryIn, cero)
adder.ccx(0, 1, 3)
adder.cx(0, 1)
adder.ccx(1, 2, 3)
adder.... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | import matplotlib.pyplot as plt
import numpy as np
# Calculate a 100 keV electron-beam path in an egg white resist based on the paper found at https://onlinelibrary.wiley.com/doi/epdf/10.1002/admi.201601223
# Full-access paper title: 'Water-Based Photo- and Electron-Beam Lithography Using Egg White as a Resist'
#... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | %load_ext autoreload
%autoreload 2
import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict
design = designs.DesignPlanar()
design.overwrite_enabled = True
gui = MetalGUI(design)
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
q1o... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | from qiskit_metal import draw, Dict
from qiskit_metal.toolbox_metal import math_and_overrides
from qiskit_metal.qlibrary.core import QComponent
import qiskit_metal as metal
design = metal.designs.DesignPlanar()
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
?TransmonPocket
face = d... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | # -*- coding: utf-8 -*-
# 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.... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | %load_ext autoreload
%autoreload 2
import qiskit_metal as metal
from qiskit_metal import designs, MetalGUI
from qiskit_metal import Dict, Headings
design = designs.DesignPlanar()
gui = MetalGUI(design)
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
from qiskit_metal.qlibrary.tline... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | %load_ext autoreload
%autoreload 2
import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict, open_docs
%metal_heading Welcome to Qiskit Metal!
from qiskit_metal.qlibrary.qubits.transmon_pocket_6 import TransmonPocket6
from qiskit_metal.qlibrary.qubits.tran... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | %load_ext autoreload
%autoreload 2
import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict, open_docs
%metal_heading Welcome to Qiskit Metal!
design = designs.DesignPlanar()
gui = MetalGUI(design)
# Select a QComponent to create (The QComponent is a py... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | %load_ext autoreload
%autoreload 2
import qiskit_metal as metal
from qiskit_metal import designs, MetalGUI
from qiskit_metal import Dict, Headings
design = designs.DesignPlanar()
gui = MetalGUI(design)
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
from qiskit_metal.qlibrary.tline... |
https://github.com/OJB-Quantum/Qiskit-Metal-to-Litho | OJB-Quantum | import numpy as np
import qiskit_metal as metal
from qiskit_metal import designs, draw, MetalGUI, Dict, open_docs
#design.overwrite_enabled = True
#design.chips.main
#design.chips.main.size.size_x = '11mm'
#design.chips.main.size.size_y = '9mm'
# To launch the qiskit metal GUI,use the method MetalGUI.
desig... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | # This cell is added by sphinx-gallery
# It can be customized to whatever you like
%matplotlib inline
import pennylane as qml
from pennylane import numpy as np
dev1 = qml.device("default.qubit", wires=1)
def circuit(params):
qml.RX(params[0], wires=0)
qml.RY(params[1], wires=0)
return qml.exp... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #@title 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 agreed to in writing, software
# distribute... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | try:
import cirq
except ImportError:
print("installing cirq...")
%pip install --quiet cirq
print("installed cirq.")
import cirq
# One Qubit
q = cirq.NamedQubit("a")
# Create a Circuit A and NOT the qubit, then measure
circuit = cirq.Circuit(cirq.X(q), cirq.measure(q, key='measured value'... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #@title 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 agreed to in writing, software
# distribute... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | from qiskit import QuantumCircuit, Aer, execute, IBMQ
from qiskit.utils import QuantumInstance
import numpy as np
from qiskit.algorithms import Shor
IBMQ.enable_account('ENTER API TOKEN HERE') # Enter your API token here
provider = IBMQ.get_provider(hub='ibm-q')
backend = Aer.get_backend('qasm_simulator')
qu... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | try:
import cirq
except ImportError:
print("installing cirq...")
!pip install --quiet cirq
print("installed cirq.")
import fractions
import math
import random
import matplotlib.pyplot as plt
import numpy as np
import sympy
from typing import Callable, List, Optional, Sequence, Union
imp... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #@title 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 agreed to in writing, software
# distribute... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #@title 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 agreed to in writing, software
# distribute... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #@title 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 agreed to in writing, software
# distribute... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | # Importing Libraries
import torch
from torch import cat, no_grad, manual_seed
from torch.utils.data import DataLoader
from torchvision import transforms
import torch.optim as optim
from torch.nn import (
Module,
Conv2d,
Linear,
Dropout2d,
NLLLoss
)
import torch.nn.functional as F
impo... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | import numpy as np
from qiskit.algorithms.linear_solvers.numpy_linear_solver import NumPyLinearSolver
from qiskit.algorithms.linear_solvers.hhl import HHL
matrix = np.array([[1, -1/3], [-1/3, 1]])
vector = np.array([1, 0])
naive_hhl_solution = HHL().solve(matrix, vector)
classical_solution = NumPyLinearSolver()... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #!/usr/bin/env python
# coding: utf-8
# # Solving linear systems of equations using HHL and its Qiskit implementation
# In this tutorial, we introduce the HHL algorithm, derive the circuit, and implement it using Qiskit. We show how to run the HHL on a simulator and on a five qubit device.
# ## Contents
# 1.... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | 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/lynnlangit/learning-quantum | lynnlangit | """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/lynnlangit/learning-quantum | lynnlangit | ## import qiskit.tools.jupyter
## %qiskit_version_table |
https://github.com/lynnlangit/learning-quantum | lynnlangit | 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 QuantumRe... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi
qreg_alice = QuantumRegister(1, 'alice')
qreg_fiber = QuantumRegister(1, 'fiber')
qreg_bob = QuantumRegister(1, 'bob')
creg_ahad = ClassicalRegister(1, 'ahad')
creg_aval = ClassicalRegister(1, 'aval')
creg_fval = Classic... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | from qiskit import QuantumCircuit, Aer, execute, IBMQ
from qiskit.utils import QuantumInstance
import numpy as np
from qiskit.algorithms import Shor
IBMQ.enable_account('ENTER API TOKEN HERE') # Enter your API token here
provider = IBMQ.get_provider(hub='ibm-q')
backend = Aer.get_backend('qasm_simulator')
qu... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | try:
import cirq
except ImportError:
print("installing cirq...")
!pip install --quiet cirq
print("installed cirq.")
import fractions
import math
import random
import matplotlib.pyplot as plt
import numpy as np
import sympy
from typing import Callable, List, Optional, Sequence, Union
imp... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | # Code blocks for qiskit notebook
## Block 1 - Setup
import math
import numpy as np
from qiskit import Aer
from qiskit.utils import QuantumInstance
from qiskit.algorithms import Shor
## Block 2 - Run
N = 15
backend = Aer.get_backend('aer_simulator')
quantum_instance = QuantumInstance(backend, shots=102... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | 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/lynnlangit/learning-quantum | lynnlangit | # This cell is added by sphinx-gallery
# It can be customized to whatever you like
%matplotlib inline
import pennylane as qml
from pennylane import numpy as np
dev1 = qml.device("default.qubit", wires=1)
def circuit(params):
qml.RX(params[0], wires=0)
qml.RY(params[1], wires=0)
return qml.exp... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | import numpy as np
from qiskit.algorithms.linear_solvers.numpy_linear_solver import NumPyLinearSolver
from qiskit.algorithms.linear_solvers.hhl import HHL
matrix = np.array([[1, -1/3], [-1/3, 1]])
vector = np.array([1, 0])
naive_hhl_solution = HHL().solve(matrix, vector)
classical_solution = NumPyLinearSolver()... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | #!/usr/bin/env python
# coding: utf-8
# # Solving linear systems of equations using HHL and its Qiskit implementation
# In this tutorial, we introduce the HHL algorithm, derive the circuit, and implement it using Qiskit. We show how to run the HHL on a simulator and on a five qubit device.
# ## Contents
# 1.... |
https://github.com/lynnlangit/learning-quantum | lynnlangit | import numpy as np
v = np.array([1,2])
A = np.array([[2,3],
[5,2]])
t = A@v
print (t)
import numpy as np
v = np.array([1,2])
A = np.array([[2,3],
[5,2],
[1,1]])
t = A@v
print (t)
import numpy as np
v = np.array([1,2])
A = np.array([[1,2],
... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | # required imports:
from qiskit.visualization import array_to_latex
from qiskit.quantum_info import Statevector, random_statevector
from qiskit.quantum_info.operators import Operator, Pauli
from qiskit import QuantumCircuit
from qiskit.circuit.library import HGate, CXGate
import numpy as np
ket0 = [[1],[0]]
... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit.circuit import QuantumCircuit
from qiskit.primitives import Estimator, Sampler
from qiskit.quantum_info import SparsePauliOp
from qiskit.visualization import plot_histogram
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('dark_background') # optional
# create excited |1> state
q... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit import QuantumCircuit, Aer, execute
import numpy as np
from qiskit.visualization import plot_histogram
import matplotlib.pyplot as plt
from math import gcd
#QFT Circuit
def qft(n):
"""Creates an n-qubit QFT circuit"""
circuit = QuantumCircuit(n)
def swap_registers(circuit, n):
... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
import numpy as np
def step_1_circuit(qr: QuantumRegister, cr: ClassicalRegister) -> QuantumCircuit:
# qr is a quantum register with 2 qubits
# cr is a classical register with 2 bits
qc = QuantumCircuit(qr, cr)
####### y... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit import QuantumCircuit, QuantumRegister
from qiskit.quantum_info import SparsePauliOp
def heisenberg_hamiltonian(
length: int, jx: float = 1.0, jy: float = 0.0, jz: float = 0.0
) -> SparsePauliOp:
terms = []
for i in range(length - 1):
if jx:
terms.append(("XX", [i... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | # required imports:
from qiskit.visualization import array_to_latex
from qiskit.quantum_info import Statevector, random_statevector
from qiskit.quantum_info.operators import Operator, Pauli
from qiskit import QuantumCircuit
from qiskit.circuit.library import HGate, CXGate
import numpy as np
ket0 = [[1],[0]]
... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | %set_env QC_GRADE_ONLY=true
from qiskit.circuit import QuantumCircuit
from qiskit.primitives import Estimator, Sampler
from qiskit.quantum_info import SparsePauliOp
from qiskit.visualization import plot_histogram
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('dark_background') # optional
... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
import numpy as np
def step_1_circuit(qr: QuantumRegister, cr: ClassicalRegister) -> QuantumCircuit:
# qr is a quantum register with 2 qubits
# cr is a classical register with 2 bits
qc = QuantumCircuit(qr, cr)
####### y... |
https://github.com/qiskit-community/qgss-2023 | qiskit-community | from qiskit import QuantumCircuit, QuantumRegister
from qiskit.quantum_info import SparsePauliOp
def heisenberg_hamiltonian(
length: int, jx: float = 1.0, jy: float = 0.0, jz: float = 0.0
) -> SparsePauliOp:
terms = []
for i in range(length - 1):
if jx:
terms.append(("XX", [i... |
https://github.com/HuangJunye/Qiskit-for-GameDev | HuangJunye | import sys
sys.path.append('/Users/kirais/Documents/GitHub/Qiskit-for-GameDev/pygame/')
from qgame import CircuitGridModel, CircuitGridNode, MeasurementsHistogram
from qgame import circuit_node_types as node_types
from qiskit import QuantumCircuit
circuit_grid_model = CircuitGridModel(4, 18)
circuit_grid_mo... |
https://github.com/HuangJunye/Qiskit-for-GameDev | HuangJunye | #
# 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/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/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/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/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/HuangJunye/Qiskit-for-GameDev | HuangJunye | from qiskit import QuantumCircuit
from circuit_grid import CircuitGridModel, CircuitGridNode
import circuit_node_types as node_types
from sympy import pi
import logging
id_gate = CircuitGridNode(node_types.ID)
x_gate = CircuitGridNode(node_types.X, 1)
y_gate = CircuitGridNode(node_types.Y, 1)
z_gate = Circu... |
https://github.com/HuangJunye/Qiskit-for-GameDev | HuangJunye | import sys
sys.path.append('/Users/kirais/Documents/GitHub/Qiskit-for-GameDev/pygame/')
from qgame import CircuitGridModel, CircuitGridNode
from qgame import circuit_node_types as node_types
from qiskit import QuantumCircuit
circuit_grid_model = CircuitGridModel(qubit_count=3, circuit_depth=6)
print(circuit... |
https://github.com/HuangJunye/Qiskit-for-GameDev | HuangJunye | import sys
sys.path.append('/Users/kirais/Documents/GitHub/Qiskit-for-GameDev/pygame/')
from qgame import CircuitGridModel, CircuitGridNode
from qgame import circuit_node_types as node_types
from qiskit import QuantumCircuit
circuit_grid_model = CircuitGridModel(qubit_count=3, circuit_depth=6)
print(circuit... |
https://github.com/HuangJunye/Qiskit-for-GameDev | HuangJunye | #
# 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/HuangJunye/Qiskit-for-GameDev | HuangJunye | #!/usr/bin/env python3
from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, Aer, execute
def run_qasm(qasm, backend_to_run="qasm_simulator"):
qc = QuantumCircuit.from_qasm_str(qasm)
backend = Aer.get_backend(backend_to_run)
job_sim = execute(qc, backend)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.