Skip to content

Commit

Permalink
Bump version (new Qrack)
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Oct 5, 2024
1 parent c2e16a5 commit 0d54a7c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
27 changes: 24 additions & 3 deletions pyqrack/qrack_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
isCpuGpuHybrid=True,
isOpenCL=True,
isHostPointer=False,
isNoisy=False,
noise=0,
pyzxCircuit=None,
qiskitCircuit=None,
):
Expand Down Expand Up @@ -90,14 +90,17 @@ def __init__(
isStabilizerHybrid,
isBinaryDecisionTree,
isPaged,
isNoisy,
(noise > 0),
isCpuGpuHybrid,
isOpenCL,
isHostPointer
)

self._throw_if_error()

if noise > 0:
self.set_noise_parameter(noise)

if pyzxCircuit is not None:
self.run_pyzx_gates(pyzxCircuit.gates)
elif qiskitCircuit is not None:
Expand Down Expand Up @@ -2148,7 +2151,7 @@ def in_ket(self, ket):
self._throw_if_error()

def out_ket(self):
"""Set state vector
"""Get state vector
Returns the raw state vector of the simulator.
Warning: State vector is not always the internal representation leading
Expand All @@ -2166,6 +2169,24 @@ def out_ket(self):
self._throw_if_error()
return [complex(r, i) for r, i in self._pairwise(ket)]

def out_probs(self):
"""Get basis dimension probabilities
Returns the probabilities of each basis dimension in the state vector
of the simulator.
Raises:
RuntimeError: QrackSimulator raised an exception.
Returns:
list representing the basis dimension probabilities.
"""
prob_count = 1 << self.num_qubits()
probs = self._qrack_real1_byref([0.0] * prob_count)
Qrack.qrack_lib.OutProbs(self.sid, probs)
self._throw_if_error()
return list(probs)

def prob_all(self, q):
"""Probabilities of all subset permutations
Expand Down
3 changes: 3 additions & 0 deletions pyqrack/qrack_system/qrack_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ def __init__(self):
# These next two methods need to have c_double pointers, if PyQrack is built with fp64.
self.qrack_lib.InKet.restype = None
self.qrack_lib.OutKet.restype = None
self.qrack_lib.OutProbs.restype = None

if self.fppow < 6:
self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_float)]
self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_float)]
self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_float)]
else:
self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_double)]
self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_double)]
self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_double)]

self.qrack_lib.init.restype = c_ulonglong
self.qrack_lib.init.argtypes = []
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup


VERSION = "1.30.32"
VERSION = "1.31.0"

# Read long description from README.
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
Expand Down

0 comments on commit 0d54a7c

Please sign in to comment.