Skip to content

Commit 26cda4e

Browse files
committed
Update wrapper
- add Kron - add MxM - add Duplicate
1 parent e63acc4 commit 26cda4e

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

python/pycubool/dll.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ctypes
22

3-
43
__all__ = [
54
"CuBoolInstanceDesc",
65
"load_and_configure",
@@ -63,6 +62,11 @@ def load_and_configure(cubool_lib_path: str):
6362
ctypes.POINTER(ctypes.c_uint),
6463
ctypes.POINTER(ctypes.c_size_t)]
6564

65+
lib.CuBool_Matrix_Duplicate.restype = ctypes.c_uint
66+
lib.CuBool_Matrix_Duplicate.argtypes = [instance_p,
67+
matrix_p,
68+
p_to_matrix_p]
69+
6670
lib.CuBool_Matrix_Nrows.restype = ctypes.c_uint
6771
lib.CuBool_Matrix_Nrows.argtype = [instance_p,
6872
matrix_p,
@@ -83,6 +87,18 @@ def load_and_configure(cubool_lib_path: str):
8387
matrix_p,
8488
matrix_p]
8589

90+
lib.CuBool_MxM.restype = ctypes.c_uint
91+
lib.CuBool_MxM.argtypes = [instance_p,
92+
matrix_p,
93+
matrix_p,
94+
matrix_p]
95+
96+
lib.CuBool_Kron.restype = ctypes.c_uint
97+
lib.CuBool_Kron.argtypes = [instance_p,
98+
matrix_p,
99+
matrix_p,
100+
matrix_p]
101+
86102
return lib
87103

88104

python/pycubool/kron.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from . import wrapper
2+
from . import dll
3+
from . import matrix
4+
5+
__all__ = [
6+
"kron"
7+
]
8+
9+
10+
def kron(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix, b_matrix: matrix.Matrix):
11+
status = wrapper.loaded_dll.CuBool_Kron(wrapper.instance,
12+
result_matrix.hnd,
13+
a_matrix.hnd,
14+
b_matrix.hnd)
15+
16+
dll.check(status)

python/pycubool/matrix.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from . import wrapper
44
from . import dll
55

6-
76
__all__ = [
87
"Matrix"
98
]
@@ -63,7 +62,7 @@ def nrows(self) -> int:
6362
return int(result.value)
6463

6564
@property
66-
def nclos(self):
65+
def nclos(self) -> int:
6766
result = ctypes.c_uint(0)
6867

6968
status = wrapper.loaded_dll.CuBool_Matrix_Ncols(wrapper.instance,
@@ -103,3 +102,12 @@ def to_lists(self):
103102
dll.check(status)
104103

105104
return rows, cols
105+
106+
def duplicate(self):
107+
result_matrix = Matrix(self.nrows, self.nclos)
108+
status = wrapper.loaded_dll.CuBool_Matrix_Duplicate(wrapper.instance,
109+
self.hnd,
110+
result_matrix.hnd)
111+
112+
dll.check(status)
113+
return result_matrix

python/pycubool/mxm.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from . import wrapper
2+
from . import dll
3+
from . import matrix
4+
5+
__all__ = [
6+
"mxm"
7+
]
8+
9+
10+
def mxm(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix, b_matrix: matrix.Matrix):
11+
status = wrapper.loaded_dll.CuBool_MxM(wrapper.instance,
12+
result_matrix.hnd,
13+
a_matrix.hnd,
14+
b_matrix.hnd)
15+
16+
dll.check(status)

0 commit comments

Comments
 (0)