Skip to content

Commit 47c959f

Browse files
committed
[Code] Pycubool:
- Minor structure refactoring - Add matrix properties query - Add matrix values extraction - Fix types of passed indices - Fix args types for ctypes (cuboolinstance, cuboolmatrix) - Add cuboolinstancedesc fields setup
1 parent 167ef5f commit 47c959f

24 files changed

+509
-232
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44
# Build files
55
/cmake-build-debug
6-
/build
6+
/build
7+
8+
# Python cache
9+
/python/pycubool/__pycache__/

include/cubool/cubool.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ CUBOOL_EXPERIMENTAL CUBOOL_API CuBoolStatus CuBool_MatrixDense_Build(
293293
*
294294
* @return Error code on this operation
295295
*/
296-
CUBOOL_EXPERIMENTAL CUBOOL_API CuBoolStatus CuBool_MatrixDense_ExtractPairs(
296+
CUBOOL_EXPERIMENTAL CUBOOL_API CuBoolStatus CuBool_MatrixDense_ExtractPairsExt(
297297
CuBoolInstance instance,
298298
CuBoolMatrixDense matrix,
299299
CuBoolIndex_t** rows,
@@ -403,6 +403,27 @@ CUBOOL_API CuBoolStatus CuBool_Matrix_Build(
403403
CuBoolSize_t nvals
404404
);
405405

406+
/**
407+
* Reads matrix data to the host visible CPU buffer as an array of values pair.
408+
* The arrays must be provided by the user and the size of this arrays must
409+
* be greater or equal the values count of the matrix.
410+
*
411+
* @param instance An instance object reference to perform this operation
412+
* @param matrix Matrix handle to perform operation on
413+
* @param[in,out] rows Allocated buffer with row indices
414+
* @param[in,out] cols Allocated buffer with column indices
415+
* @param[in,out] nvals Total number of the pairs
416+
*
417+
* @return Error code on this operation
418+
*/
419+
CUBOOL_API CuBoolStatus CuBool_Matrix_ExtractPairs(
420+
CuBoolInstance instance,
421+
CuBoolMatrix matrix,
422+
CuBoolIndex_t* rows,
423+
CuBoolIndex_t* cols,
424+
CuBoolSize_t* nvals
425+
);
426+
406427
/**
407428
* Reads matrix data to the host visible CPU buffer as an array of values pair.
408429
* The indices of the i-th pair can be evaluated as (r=rows[i],c=cols[i]).
@@ -418,7 +439,7 @@ CUBOOL_API CuBoolStatus CuBool_Matrix_Build(
418439
*
419440
* @return Error code on this operation
420441
*/
421-
CUBOOL_API CuBoolStatus CuBool_Matrix_ExtractPairs(
442+
CUBOOL_API CuBoolStatus CuBool_Matrix_ExtractPairsExt(
422443
CuBoolInstance instance,
423444
CuBoolMatrix matrix,
424445
CuBoolIndex_t** rows,

python/pycubool/CuBoolWrapper/__init__.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

python/pycubool/CuBoolWrapper/add.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

python/pycubool/CuBoolWrapper/codes.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

python/pycubool/CuBoolWrapper/ctypesWrapper.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

python/pycubool/CuBoolWrapper/matrix.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

python/pycubool/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .wrapper import *
2+
3+
from .matrix import *
4+
from .add import *
5+
6+
# Setup global module state
7+
init_wrapper()

python/pycubool/add.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+
6+
__all__ = [
7+
"add"
8+
]
9+
10+
11+
def add(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix):
12+
status = wrapper.loaded_dll.CuBool_Matrix_Add(wrapper.instance,
13+
result_matrix.hnd,
14+
a_matrix.hnd)
15+
16+
dll.check(status)

0 commit comments

Comments
 (0)