|
7 | 7 |
|
8 | 8 | from . import wrapper
|
9 | 9 | from . import bridge
|
| 10 | +from . import vector |
10 | 11 |
|
11 | 12 |
|
12 | 13 | __all__ = [
|
@@ -490,6 +491,34 @@ def extract_matrix(self, i, j, shape, out=None, time_check=False):
|
490 | 491 | bridge.check(status)
|
491 | 492 | return out
|
492 | 493 |
|
| 494 | + def extract_row(self, i, out=None): |
| 495 | + if out is None: |
| 496 | + out = Vector.empty(self.ncols) |
| 497 | + |
| 498 | + status = wrapper.loaded_dll.cuBool_Matrix_ExtractRow( |
| 499 | + out.hnd, |
| 500 | + self.hnd, |
| 501 | + ctypes.c_uint(i), |
| 502 | + ctypes.c_uint(0) |
| 503 | + ) |
| 504 | + |
| 505 | + bridge.check(status) |
| 506 | + return out |
| 507 | + |
| 508 | + def extract_col(self, j, out=None): |
| 509 | + if out is None: |
| 510 | + out = Vector.empty(self.nrows) |
| 511 | + |
| 512 | + status = wrapper.loaded_dll.cuBool_Matrix_ExtractCol( |
| 513 | + out.hnd, |
| 514 | + self.hnd, |
| 515 | + ctypes.c_uint(j), |
| 516 | + ctypes.c_uint(0) |
| 517 | + ) |
| 518 | + |
| 519 | + bridge.check(status) |
| 520 | + return out |
| 521 | + |
493 | 522 | def mxm(self, other, out=None, accumulate=False, time_check=False):
|
494 | 523 | """
|
495 | 524 | Matrix-matrix multiplication in boolean semiring with "x = and" and "+ = or" operations.
|
@@ -532,6 +561,20 @@ def mxm(self, other, out=None, accumulate=False, time_check=False):
|
532 | 561 | bridge.check(status)
|
533 | 562 | return out
|
534 | 563 |
|
| 564 | + def mxv(self, other, out=None, time_check=False): |
| 565 | + if out is None: |
| 566 | + out = Vector.empty(self.nrows) |
| 567 | + |
| 568 | + status = wrapper.loaded_dll.cuBool_MxV( |
| 569 | + out.hnd, |
| 570 | + self.hnd, |
| 571 | + other.hnd, |
| 572 | + ctypes.c_uint(bridge.get_mxv_hints(time_check=time_check)) |
| 573 | + ) |
| 574 | + |
| 575 | + bridge.check(status) |
| 576 | + return out |
| 577 | + |
535 | 578 | def kronecker(self, other, out=None, time_check=False):
|
536 | 579 | """
|
537 | 580 | Matrix-matrix kronecker product with boolean "x = and" operation.
|
@@ -643,6 +686,20 @@ def reduce(self, time_check=False):
|
643 | 686 | bridge.check(status)
|
644 | 687 | return out
|
645 | 688 |
|
| 689 | + def reduce_vector(self, out=None, transpose=False, time_check=False): |
| 690 | + if out is None: |
| 691 | + nrows = self.ncols if transpose else self.nrows |
| 692 | + out = Vector.empty(nrows) |
| 693 | + |
| 694 | + status = wrapper.loaded_dll.cuBool_Matrix_Reduce( |
| 695 | + out.hnd, |
| 696 | + self.hnd, |
| 697 | + ctypes.c_uint(bridge.get_reduce_vector_hints(transpose=transpose, time_check=time_check)) |
| 698 | + ) |
| 699 | + |
| 700 | + bridge.check(status) |
| 701 | + return out |
| 702 | + |
646 | 703 | def equals(self, other) -> bool:
|
647 | 704 | """
|
648 | 705 | Compare two matrices. Returns true if they are equal.
|
|
0 commit comments