|
| 1 | +""" |
| 2 | + GrB_reduce(arg1, arg2, arg3, arg4, ...) |
| 3 | +
|
| 4 | +Generic method for matrix/vector reduction to a vector or scalar. |
| 5 | +""" |
| 6 | +function GrB_reduce(arg1::T, arg2, arg3::U, arg4::V, args...) where {T, U, V} |
| 7 | + if T <: GrB_Vector |
| 8 | + if V <: GrB_Monoid |
| 9 | + return GrB_Matrix_reduce_Monoid(arg1, arg2, arg3, arg4, args...) |
| 10 | + elseif V <: GrB_BinaryOp |
| 11 | + return GrB_Matrix_reduce_BinaryOp(arg1, arg2, arg3, arg4, args...) |
| 12 | + end |
| 13 | + elseif T <: valid_accum_types |
| 14 | + if U <: GrB_Vector |
| 15 | + return GrB_Vector_reduce(arg1, arg2, arg3, arg4) |
| 16 | + elseif U <: GrB_Matrix |
| 17 | + return GrB_Matrix_reduce(arg1, arg2, arg3, arg4) |
| 18 | + end |
| 19 | + end |
| 20 | +end |
| 21 | + |
1 | 22 | """
|
2 | 23 | GrB_Matrix_reduce_Monoid(w, mask, accum, monoid, A, desc)
|
3 | 24 |
|
4 |
| -Reduce the entries in a matrix to a vector. By default these methods compute a column vector w |
| 25 | +Reduce the entries in a matrix to a vector. By default these methods compute a column vector w |
5 | 26 | such that w(i) = sum(A(i,:)), where "sum" is a commutative and associative monoid with an identity value.
|
6 | 27 | A can be transposed, which reduces down the columns instead of the rows.
|
7 | 28 |
|
@@ -34,12 +55,12 @@ GrB_SUCCESS::GrB_Info = 0
|
34 | 55 |
|
35 | 56 | julia> @GxB_fprint(w, GxB_COMPLETE)
|
36 | 57 |
|
37 |
| -GraphBLAS vector: w |
| 58 | +GraphBLAS vector: w |
38 | 59 | nrows: 4 ncols: 1 max # entries: 2
|
39 | 60 | format: standard CSC vlen: 4 nvec_nonempty: 1 nvec: 1 plen: 1 vdim: 1
|
40 | 61 | hyper_ratio 0.0625
|
41 | 62 | GraphBLAS type: int64_t size: 8
|
42 |
| -number of entries: 2 |
| 63 | +number of entries: 2 |
43 | 64 | column: 0 : 2 entries [0:1]
|
44 | 65 | row 0: int64 30
|
45 | 66 | row 2: int64 70
|
|
68 | 89 | """
|
69 | 90 | GrB_Matrix_reduce_BinaryOp(w, mask, accum, op, A, desc)
|
70 | 91 |
|
71 |
| -Reduce the entries in a matrix to a vector. By default these methods compute a column vector w such that |
72 |
| -w(i) = sum(A(i,:)), where "sum" is a commutative and associative binary operator. A can be transposed, |
| 92 | +Reduce the entries in a matrix to a vector. By default these methods compute a column vector w such that |
| 93 | +w(i) = sum(A(i,:)), where "sum" is a commutative and associative binary operator. A can be transposed, |
73 | 94 | which reduces down the columns instead of the rows.
|
74 | 95 |
|
75 | 96 | # Examples
|
@@ -101,12 +122,12 @@ GrB_SUCCESS::GrB_Info = 0
|
101 | 122 |
|
102 | 123 | julia> @GxB_fprint(w, GxB_COMPLETE)
|
103 | 124 |
|
104 |
| -GraphBLAS vector: w |
| 125 | +GraphBLAS vector: w |
105 | 126 | nrows: 4 ncols: 1 max # entries: 2
|
106 | 127 | format: standard CSC vlen: 4 nvec_nonempty: 1 nvec: 1 plen: 1 vdim: 1
|
107 | 128 | hyper_ratio 0.0625
|
108 | 129 | GraphBLAS type: int64_t size: 8
|
109 |
| -number of entries: 2 |
| 130 | +number of entries: 2 |
110 | 131 | column: 0 : 2 entries [0:1]
|
111 | 132 | row 0: int64 200
|
112 | 133 | row 2: int64 1200
|
|
0 commit comments