diff --git a/libqwqng-wrapper-x86-64.so b/libqwqng-wrapper-x86-64.so index d1c01cf..fe29393 100644 Binary files a/libqwqng-wrapper-x86-64.so and b/libqwqng-wrapper-x86-64.so differ diff --git a/libqwqng-wrapper.so b/libqwqng-wrapper.so index 9fe8fd8..5f31175 100644 Binary files a/libqwqng-wrapper.so and b/libqwqng-wrapper.so differ diff --git a/quanttp/data/qng_wrapper_linux.py b/quanttp/data/qng_wrapper_linux.py index 84be756..868b799 100644 --- a/quanttp/data/qng_wrapper_linux.py +++ b/quanttp/data/qng_wrapper_linux.py @@ -25,59 +25,59 @@ from ctypes import cdll, c_void_p, c_int, c_double, POINTER, c_char class QngWrapperLinux: def __init__(self): - self.libqwqng_wrapper = cdll.LoadLibrary('./libqwqng-wrapper-x86-64.so' if platform.machine().endswith('64') else './libqwqng-wrapper.so') - self.libqwqng_wrapper.GetQwqngInstance.restype = c_void_p - self.libqwqng_wrapper.RandInt32.argtypes = [c_void_p] - self.libqwqng_wrapper.RandInt32.restype = c_int - self.libqwqng_wrapper.RandUniform.argtypes = [c_void_p] - self.libqwqng_wrapper.RandUniform.restype = c_double - self.libqwqng_wrapper.RandNormal.argtypes = [c_void_p] - self.libqwqng_wrapper.RandNormal.restype = c_double - self.libqwqng_wrapper.RandBytes.argtypes = [c_void_p, c_int] - self.libqwqng_wrapper.RandBytes.restype = POINTER(c_char) - self.libqwqng_wrapper.Clear.argtypes = [c_void_p] - self.libqwqng_wrapper.Reset.argtypes = [c_void_p] - self.qng = self.libqwqng_wrapper.GetQwqngInstance() + self.qwqng_wrapper = cdll.LoadLibrary('./libqwqng-wrapper-x86-64.so' if platform.machine().endswith('64') else './libqwqng-wrapper.so') + self.qwqng_wrapper.GetQwqngInstance.restype = c_void_p + self.qwqng_wrapper.RandInt32.argtypes = [c_void_p] + self.qwqng_wrapper.RandInt32.restype = c_int + self.qwqng_wrapper.RandUniform.argtypes = [c_void_p] + self.qwqng_wrapper.RandUniform.restype = c_double + self.qwqng_wrapper.RandNormal.argtypes = [c_void_p] + self.qwqng_wrapper.RandNormal.restype = c_double + self.qwqng_wrapper.RandBytes.argtypes = [c_void_p, c_int] + self.qwqng_wrapper.RandBytes.restype = POINTER(c_char) + self.qwqng_wrapper.Clear.argtypes = [c_void_p] + self.qwqng_wrapper.Reset.argtypes = [c_void_p] + self.qng_pointer = self.qwqng_wrapper.GetQwqngInstance() def randint32(self): try: - return self.libqwqng_wrapper.RandInt32(self.qng) + return self.qwqng_wrapper.RandInt32(self.qng_pointer) except: - self.libqwqng_wrapper.Reset(self.qng) - return self.libqwqng_wrapper.RandInt32(self.qng) + self.qwqng_wrapper.Reset(self.qng_pointer) + return self.qwqng_wrapper.RandInt32(self.qng_pointer) def randuniform(self): try: - return self.libqwqng_wrapper.RandUniform(self.qng) + return self.qwqng_wrapper.RandUniform(self.qng_pointer) except: - self.libqwqng_wrapper.Reset(self.qng) - return self.libqwqng_wrapper.RandUniform(self.qng) + self.qwqng_wrapper.Reset(self.qng_pointer) + return self.qwqng_wrapper.RandUniform(self.qng_pointer) def randnormal(self): try: - return self.libqwqng_wrapper.RandNormal(self.qng) + return self.qwqng_wrapper.RandNormal(self.qng_pointer) except: - self.libqwqng_wrapper.Reset(self.qng) - return self.libqwqng_wrapper.RandNormal(self.qng) + self.qwqng_wrapper.Reset(self.qng_pointer) + return self.qwqng_wrapper.RandNormal(self.qng_pointer) def randbytes(self, length): try: return self._randbytes_arbitrary_length(length) except: - self.libqwqng_wrapper.Reset(self.qng) + self.qwqng_wrapper.Reset(self.qng_pointer) return self._randbytes_arbitrary_length(length) def _randbytes_arbitrary_length(self, length): if length <= 8192: - return self.libqwqng_wrapper.RandBytes(self.qng, length)[:length] + return self.qwqng_wrapper.RandBytes(self.qng_pointer, length)[:length] else: data = bytearray() for x in range(length // 8192): - data.extend(self.libqwqng_wrapper.RandBytes(self.qng, 8192)[:8192]) + data.extend(self.qwqng_wrapper.RandBytes(self.qng_pointer, 8192)[:8192]) bytes_needed = length % 8192 if bytes_needed != 0: - data.extend(self.libqwqng_wrapper.RandBytes(self.qng, bytes_needed)[:bytes_needed]) + data.extend(self.qwqng_wrapper.RandBytes(self.qng_pointer, bytes_needed)[:bytes_needed]) return bytes(data) def clear(self): - self.libqwqng_wrapper.Clear(self.qng) + self.qwqng_wrapper.Clear(self.qng_pointer)