Skip to content

Commit 5e7e535

Browse files
committed
feat: add reduce method
this patch brings reduce method that allows calculate reduced matrix by rows and column in lanegg Signed-off-by: Rodion Suvorov <[email protected]>
1 parent 16d96af commit 5e7e535

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

experimental/algorithm/LAGraph_RPQMatrix.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,23 @@ GrB_Info LAGraph_DestroyRpqMatrixPlan(RPQMatrixPlan *plan)
196196

197197
GrB_Info LAGraph_RPQMatrix_solver(RPQMatrixPlan *plan, char *msg) ;
198198

199+
GrB_Info LAGraph_RPQMatrix_reduce(GrB_Index *res, GrB_Matrix mat, uint8_t reduce_type)
200+
{
201+
GrB_Index nvals ;
202+
GrB_Vector reduce ;
203+
if (reduce_type == 0)
204+
{
205+
GrB_Matrix_reduce_Monoid(reduce,NULL,NULL,GxB_ANY_BOOL_MONOID,mat,NULL) ;
206+
}
207+
else if (reduce_type == 1)
208+
{
209+
GrB_Matrix_reduce_Monoid(reduce, NULL,NULL,GxB_ANY_BOOL_MONOID,mat,GrB_DESC_T0) ;
210+
}
211+
GrB_Vector_nvals(&nvals,reduce) ;
212+
*res = nvals ;
213+
return (GrB_SUCCESS) ;
214+
}
215+
199216
static GrB_Info LAGraph_RPQMatrixLor(RPQMatrixPlan *plan, char *msg)
200217
{
201218
LG_ASSERT(plan != NULL, GrB_NULL_POINTER) ;

include/LAGraphX.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,16 @@ GrB_Info LAGraph_RPQMatrix_label
974974
LAGRAPHX_PUBLIC
975975
GrB_Info LAGraph_DestroyRpqMatrixPlan(RPQMatrixPlan *plan) ;
976976

977+
LAGRAPHX_PUBLIC
978+
GrB_Info LAGraph_RPQMatrix_reduce(
979+
GrB_Index *res,
980+
GrB_Matrix mat,
981+
uint8_t reduce_type // reduce_type values:
982+
// 0 --- reduce by row
983+
// 1 --- reduce by col
984+
) ;
985+
986+
977987
//****************************************************************************
978988
LAGRAPHX_PUBLIC
979989
int LAGraph_VertexCentrality_Triangle // vertex triangle-centrality

0 commit comments

Comments
 (0)