src/algorithm/LG_TriangleCount_SSGrB.c
static int tricount_prep        // return 0 if successful, < 0 on error
(
    GrB_Matrix *L,      // if present, compute L = tril (A,-1)
    GrB_Matrix *U,      // if present, compute U = triu (A, 1)
    GrB_Matrix A,       // input matrix
    char *msg
)
{
    GrB_Index n ;
    GxB_Scalar thunk ;
    GrB_TRY (GrB_Matrix_nrows (&n, A)) ;
    GrB_TRY (GxB_Scalar_new (&thunk, GrB_INT64)) ;

    if (L != NULL)
    {
        // L = tril (A,-1)
        GrB_TRY (GrB_Matrix_new (L, GrB_BOOL, n, n)) ;
        GrB_TRY (GxB_Scalar_setElement (thunk, -1)) ;
        GrB_TRY (GxB_select (*L, NULL, NULL, GxB_TRIL, A, thunk, NULL)) ;
    }

    if (U != NULL)
    {
        // U = triu (A,1)
        GrB_TRY (GrB_Matrix_new (U, GrB_BOOL, n, n)) ;
        GrB_TRY (GxB_Scalar_setElement (thunk, 1)) ;
        GrB_TRY (GxB_select (*U, NULL, NULL, GxB_TRIU, A, thunk, NULL)) ;
    }

    GrB_free (&thunk) ;
    return (0) ;
}
//------------------------------------------------------------------------------
// tricount_prep: construct L and U for LAGraph_TriangleCount_Methods
//------------------------------------------------------------------------------
construct L and U for LAGraph_TriangleCount_Methods
construct L and U for LAGraph_TriangleCount_Methods
static int tricount_prep        
(
    GrB_Matrix *L,      
    GrB_Matrix *U,      
    GrB_Matrix A,       
    char *msg
)
{
    GrB_Index n ;
    GxB_Scalar thunk ;
    GrB_TRY (GrB_Matrix_nrows (&n, A)) ;
    GrB_TRY (GxB_Scalar_new (&thunk, GrB_INT64)) ;
    if (L != NULL)
    {
        GrB_TRY (GrB_Matrix_new (L, GrB_BOOL, n, n)) ;
        GrB_TRY (GxB_Scalar_setElement (thunk, -1)) ;
        GrB_TRY (GxB_select (*L, NULL, NULL, GxB_TRIL, A, thunk, NULL)) ;
    }
    if (U != NULL)
    {
        GrB_TRY (GrB_Matrix_new (U, GrB_BOOL, n, n)) ;
        GrB_TRY (GxB_Scalar_setElement (thunk, 1)) ;
        GrB_TRY (GxB_select (*U, NULL, NULL, GxB_TRIU, A, thunk, NULL)) ;
    }
    GrB_free (&thunk) ;
    return (0) ;
}
static int tricount_prep ( GrB_Matrix * L , GrB_Matrix * U , GrB_Matrix A , char * msg ) { GrB_Index n ; GxB_Scalar thunk ; GrB_TRY ( GrB_Matrix_nrows ( & n , A ) ) ; GrB_TRY ( GxB_Scalar_new ( & thunk , GrB_INT64 ) ) ; if ( L != NULL ) { GrB_TRY ( GrB_Matrix_new ( L , GrB_BOOL , n , n ) ) ; GrB_TRY ( GxB_Scalar_setElement ( thunk , -1 ) ) ; GrB_TRY ( GxB_select ( * L , NULL , NULL , GxB_TRIL , A , thunk , NULL ) ) ; } if ( U != NULL ) { GrB_TRY ( GrB_Matrix_new ( U , GrB_BOOL , n , n ) ) ; GrB_TRY ( GxB_Scalar_setElement ( thunk , 1 ) ) ; GrB_TRY ( GxB_select ( * U , NULL , NULL , GxB_TRIU , A , thunk , NULL ) ) ; } GrB_free ( & thunk ) ; return ( 0 ) ; }
tricount_prep: construct L and U for LAGraph_TriangleCount_Methods
tricount_prep : construct L and U for LAGraph_TriangleCount_Methods
// return 0 if successful, < 0 on error // if present, compute L = tril (A,-1) // if present, compute U = triu (A, 1) // input matrix // L = tril (A,-1) // U = triu (A,1)