@@ -237,16 +237,16 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_New(
237
237
/**
238
238
* Build sparse matrix from provided pairs array. Pairs are supposed to be stored
239
239
* as (rows[i],cols[i]) for pair with i-th index.
240
+ * By default automatically sorts values and reduces duplicates in the input arrays.
240
241
*
241
- * @note This function automatically reduces duplicates
242
242
* @note Pass `CUBOOL_HINT_VALUES_SORTED` if values already in the row-col order.
243
243
* @note Pass `CUBOOL_HINT_NO_DUPLICATES` if values has no duplicates
244
244
*
245
245
* @param matrix Matrix handle to perform operation on
246
246
* @param rows Array of pairs row indices
247
247
* @param cols Array of pairs column indices
248
248
* @param nvals Number of the pairs passed
249
- * @param hints Hits flags for processing.
249
+ * @param hints Hits flags for processing
250
250
*
251
251
* @return Error code on this operation
252
252
*/
@@ -436,14 +436,35 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Ncols(
436
436
/**
437
437
* Deletes sparse matrix object.
438
438
*
439
- * @param matrix Matrix handle to delete the matrix
439
+ * @param matrix Matrix handle to delete
440
440
*
441
441
* @return Error code on this operation
442
442
*/
443
443
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Free (
444
444
cuBool_Matrix matrix
445
445
);
446
446
447
+ /**
448
+ * Reduce the source matrix to the column vector.
449
+ * Pass optionally transpose hint to transpose matrix before the reduce.
450
+ * Formally: result = sum(cols of matrix M), where
451
+ * M = matrix, or M = matrix^T (if passed transpose hint)
452
+ *
453
+ * @note Pass `CUBOOL_HINT_TRANSPOSE` hint to reduce transposed matrix
454
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
455
+ *
456
+ * @param[out] result Vector handle where to store result
457
+ * @param matrix Source matrix to reduce
458
+ * @param hints Hints for the operation
459
+ *
460
+ * @return Error code on this operation
461
+ */
462
+ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce (
463
+ cuBool_Vector result ,
464
+ cuBool_Matrix matrix ,
465
+ cuBool_Hints hints
466
+ );
467
+
447
468
/**
448
469
* Reduce the source matrix to the column matrix result (column vector).
449
470
* Formally: result = sum(cols of matrix).
@@ -454,7 +475,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Free(
454
475
*
455
476
* @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
456
477
*
457
- * @param result [out] Matrix hnd where to store result
478
+ * @param[out] result Matrix handle where to store result
458
479
* @param matrix Source matrix to reduce
459
480
* @param hints Hints for the operation
460
481
*
@@ -466,12 +487,6 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce2(
466
487
cuBool_Hints hints
467
488
);
468
489
469
- CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce (
470
- cuBool_Vector result ,
471
- cuBool_Matrix matrix ,
472
- cuBool_Hints hints
473
- );
474
-
475
490
/**
476
491
* Performs result = left + right, where '+' is boolean semiring operation.
477
492
*
@@ -482,7 +497,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce(
482
497
*
483
498
* @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
484
499
*
485
- * @param result[out] Destination matrix for add-and-assign operation
500
+ * @param result[out] Destination matrix to store result
486
501
* @param left Source matrix to be added
487
502
* @param right Source matrix to be added
488
503
* @param hints Hints for the operation
@@ -496,40 +511,129 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseAdd(
496
511
cuBool_Hints hints
497
512
);
498
513
514
+ /**
515
+ * Creates new sparse vector with specified size.
516
+ *
517
+ * @param vector Pointer where to store created vector
518
+ * @param nrows Vector rows count
519
+ *
520
+ * @return Error code on this operation
521
+ */
499
522
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_New (
500
523
cuBool_Vector * vector ,
501
524
cuBool_Index nrows
502
525
);
503
526
527
+ /**
528
+ * Build sparse vector from provided indices array.
529
+ * By default automatically sorts values and reduces duplicates in the input array.
530
+ *
531
+ * @note Pass `CUBOOL_HINT_VALUES_SORTED` if values already in the row-col order.
532
+ * @note Pass `CUBOOL_HINT_NO_DUPLICATES` if values has no duplicates
533
+ *
534
+ * @param vector Vector handle to perform operation on
535
+ * @param rows Array of row indices
536
+ * @param nvals Number of the indices passed
537
+ * @param hints Hits flags for processing
538
+ *
539
+ * @return Error code on this operation
540
+ */
504
541
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Build (
505
542
cuBool_Vector vector ,
506
543
const cuBool_Index * rows ,
507
544
cuBool_Index nvals ,
508
545
cuBool_Hints hints
509
546
);
510
547
548
+ /**
549
+ * Sets specified (j) value of the vector to True.
550
+ *
551
+ * @note This function automatically reduces duplicates
552
+ *
553
+ * @param vector Vector handle to perform operation on
554
+ * @param i Row index
555
+ *
556
+ * @return Error code on this operation
557
+ */
511
558
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetElement (
512
559
cuBool_Vector vector ,
513
560
cuBool_Index i
514
561
);
515
562
563
+ /**
564
+ * Sets to the vector specific debug string marker.
565
+ * This marker will appear in the log messages as string identifier of the vector.
566
+ *
567
+ * @param vector Vector handle to perform operation on
568
+ * @param marker UTF-8 encoded null-terminated string marker name.
569
+ *
570
+ * @return Error code on this operation
571
+ */
516
572
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetMarker (
517
573
cuBool_Vector vector ,
518
574
const char * marker
519
575
);
520
576
577
+ /**
578
+ * Allows to get vector debug string marker.
579
+ *
580
+ * @note Pass null marker if you want to retrieve only the required marker buffer size.
581
+ * @note After the function call the actual size of the marker is stored in the size variable.
582
+ *
583
+ * @note size is set to the actual marker length plus null terminator symbol.
584
+ * For marker "vector" size variable will be set to 7.
585
+ *
586
+ * @param vector Vector handle to perform operation on
587
+ * @param[in,out] marker Where to store null-terminated UTF-8 encoded marker string.
588
+ * @param[in,out] size Size of the provided buffer in bytes to save marker string.
589
+ *
590
+ * @return Error code on this operation
591
+ */
521
592
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Marker (
522
593
cuBool_Vector vector ,
523
594
char * marker ,
524
595
cuBool_Index * size
525
596
);
526
597
598
+ /**
599
+ * Reads vector data to the host visible CPU buffer as an array of indices.
600
+ *
601
+ * The array must be provided by the user and the size of this array must
602
+ * be greater or equal the values count of the vector.
603
+ *
604
+ * @param vector Matrix handle to perform operation on
605
+ * @param[in,out] rows Buffer to store row indices
606
+ * @param[in,out] nvals Total number of the indices
607
+ *
608
+ * @return Error code on this operation
609
+ */
527
610
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractValues (
528
611
cuBool_Vector vector ,
529
612
cuBool_Index * rows ,
530
613
cuBool_Index * nvals
531
614
);
532
615
616
+ /**
617
+ * Extracts sub-vector of the input vector and stores it into result vector.
618
+ *
619
+ * @note The result sub-vector have nrows dimension,
620
+ * and includes [i;i+nrow) rows of the input vector.
621
+ *
622
+ * @note Result vector must have compatible size
623
+ * dim(result) = nrows
624
+ *
625
+ * @note Provided sub-vector region must be within the input vector.
626
+ *
627
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
628
+ *
629
+ * @param result[out] Vector handle where to store result of the operation
630
+ * @param vector Input vector to extract values from
631
+ * @param i First row id to extract
632
+ * @param nrows Number of rows to extract
633
+ * @param hints Hints for the operation
634
+ *
635
+ * @return Error code on this operation
636
+ */
533
637
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractSubVector (
534
638
cuBool_Vector result ,
535
639
cuBool_Vector vector ,
@@ -538,31 +642,91 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractSubVector(
538
642
cuBool_Hints hints
539
643
);
540
644
645
+ /**
646
+ * Creates new sparse vector, duplicates content and stores handle in the provided pointer.
647
+ *
648
+ * @param vector Vector handle to perform operation on
649
+ * @param duplicated[out] Pointer to the vector handle where to create and store created vector
650
+ *
651
+ * @return Error code on this operation
652
+ */
541
653
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Duplicate (
542
654
cuBool_Vector vector ,
543
655
cuBool_Vector * duplicated
544
656
);
545
657
658
+ /**
659
+ * Query number of non-zero values of the vector.
660
+ *
661
+ * @param vector Vector handle to perform operation on
662
+ * @param nvals[out] Pointer to the place where to store number of the non-zero elements of the vector
663
+ *
664
+ * @return Error code on this operation
665
+ */
546
666
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nvals (
547
667
cuBool_Vector vector ,
548
668
cuBool_Index * nvals
549
669
);
550
670
671
+ /**
672
+ * Query number of rows in the vector.
673
+ *
674
+ * @param vector Vector handle to perform operation on
675
+ * @param nrows[out] Pointer to the place where to store number of vector rows
676
+ *
677
+ * @return Error code on this operation
678
+ */
551
679
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nrows (
552
680
cuBool_Vector vector ,
553
681
cuBool_Index * nrows
554
682
);
555
683
684
+ /**
685
+ * Deletes sparse vector object.
686
+ *
687
+ * @param vector Vector handle to delete
688
+ *
689
+ * @return Error code on this operation
690
+ */
556
691
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Free (
557
692
cuBool_Vector vector
558
693
);
559
694
695
+
696
+ /**
697
+ * Reduces vector to single value (equals nnz of the vector for boolean case).
698
+ *
699
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
700
+ *
701
+ * @param result Pointer to index value where to store result
702
+ * @param vector Vector handle to perform operation on
703
+ * @param hints Hints for the operation
704
+ *
705
+ * @return Error code on this operation
706
+ */
560
707
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Reduce (
561
708
cuBool_Index * result ,
562
709
cuBool_Vector vector ,
563
710
cuBool_Hints hints
564
711
);
565
712
713
+ /**
714
+ * Performs result = left + right, where '+' is boolean semiring operation.
715
+ *
716
+ * @note Matrices must be compatible
717
+ * dim(result) = M
718
+ * dim(left) = M
719
+ * dim(right) = M
720
+ *
721
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
722
+ *
723
+ * @param result[out]Destination vector to store result
724
+ * @param left Source vector to be added
725
+ * @param right Source vector to be added
726
+ * @param hints Hints for the operation
727
+ *
728
+ * @return Error code on this operation
729
+ */
566
730
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_EWiseAdd (
567
731
cuBool_Vector result ,
568
732
cuBool_Vector left ,
@@ -596,17 +760,53 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxM(
596
760
cuBool_Hints hints
597
761
);
598
762
763
+ /**
764
+ * Performs result = left x right evaluation, where source '+' and 'x' are boolean semiring operations.
765
+ * Formally: column vector `right` multiplied to the matrix `left`. The result is column vector.
766
+ *
767
+ * @note To perform this operation matrix and vector must be compatible
768
+ * dim(left) = M x N
769
+ * dim(right) = N
770
+ * dim(result) = M
771
+ *
772
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
773
+ *
774
+ * @param result[out] Vector handle where to store operation result
775
+ * @param left Input left matrix
776
+ * @param right Input right vector
777
+ * @param hints Hints for the operation
778
+ *
779
+ * @return Error code on this operation
780
+ */
599
781
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxV (
600
782
cuBool_Vector result ,
601
- cuBool_Matrix matrix ,
602
- cuBool_Vector vector ,
783
+ cuBool_Matrix left ,
784
+ cuBool_Vector right ,
603
785
cuBool_Hints hints
604
786
);
605
787
788
+ /**
789
+ * Performs result = left x right evaluation, where source '+' and 'x' are boolean semiring operations.
790
+ * Formally: row vector `left` multiplied to the matrix `right`. The result is row vector.
791
+ *
792
+ * @note To perform this operation matrix and vector must be compatible
793
+ * dim(left) = M
794
+ * dim(right) = M x N
795
+ * dim(result) = N
796
+ *
797
+ * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time
798
+ *
799
+ * @param result[out] Vector handle where to store operation result
800
+ * @param left Input left vector
801
+ * @param right Input right matrix
802
+ * @param hints Hints for the operation
803
+ *
804
+ * @return Error code on this operation
805
+ */
606
806
CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_VxM (
607
807
cuBool_Vector result ,
608
- cuBool_Vector vector ,
609
- cuBool_Matrix matrix ,
808
+ cuBool_Vector left ,
809
+ cuBool_Matrix right ,
610
810
cuBool_Hints hints
611
811
);
612
812
0 commit comments