Skip to content

Commit

Permalink
fix cupy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
K Nakaji committed Nov 13, 2023
1 parent def6d7a commit c5f1cc8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

ibmq/.ibmq_key
qwrapper/playground.py
ibmq/.ibmq_key
5 changes: 2 additions & 3 deletions qwrapper/hamiltonian.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import logging

import numpy

from qwrapper.obs import Hamiltonian
from qwrapper.operator import ControllablePauli

try:
import cupy as np
except ModuleNotFoundError:
print("cupy not found. numpy is used.")
import numpy as np


Expand Down Expand Up @@ -69,7 +68,7 @@ def to_matrix_hamiltonian(hamiltonian: Hamiltonian):
else:
result += (h + 0j) * o.to_matrix()
count += 1
return result + numpy.diag([hamiltonian._identity] * len(result))
return result + np.diag([hamiltonian._identity] * len(result))


def compute_ground_state(hamiltonian: Hamiltonian):
Expand Down
9 changes: 5 additions & 4 deletions qwrapper/obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
try:
import cupy as np
except ModuleNotFoundError:
print("cupy not found. numpy is used.")
import numpy as np


Expand All @@ -22,10 +23,10 @@ def build_operator_str(p_string):


class Pauli:
X = np.matrix([[0, 1], [1, 0]])
Y = np.matrix([[0, -1j], [1j, 0]])
Z = np.matrix([[1, 0], [0, -1]])
I = np.matrix([[1, 0], [0, 1]])
X = np.array([[0, 1], [1, 0]])
Y = np.array([[0, -1j], [1j, 0]])
Z = np.array([[1, 0], [0, -1]])
I = np.array([[1, 0], [0, 1]])


class Obs(abc.ABC):
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
qiskit>=0.30.0
Qulacs>=0.3.0
matplotlib>=3.0.0
pylatexenc>=2.0
qutip>=4.7.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="qwrapper",
version="0.4.25",
version="0.4.26",
author="kouhei nakaji",
author_email="[email protected]",
description="You can receive the message 'Hello!!!'",
Expand Down

0 comments on commit c5f1cc8

Please sign in to comment.