ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
GraphBLAS.h

The graphs and the sparse matrices of ADS as matrices of SuiteSparse. More...

Files

file  ADS/interop/graphblas/GraphBLAS.h
 The graphs and the sparse matrices of ADS as matrices of SuiteSparse:GraphBLAS (https://github.com/DrTimothyAldenDavis/GraphBLAS), so that the operations of GraphBLAS, and the algorithms of LAGraph written on them, run on the structures of ADS, beyond the book:

Classes

class  ADS::graphblas::Matrix
 the owner of a GrB_Matrix, freed at its end More...

Macros

#define ADS_GRB_TYPED(F, T, ...)
 the call of the typed function of GraphBLAS F##_< T >, for the type T of the values of the arguments

Functions

void ADS::graphblas::check (GrB_Info r, const char *what)
 throws if \( r \) is not a success of GraphBLAS, naming what
template<class T>
GrB_Type ADS::graphblas::type (void)
 the type of GraphBLAS of the numbers T: GrB_BOOL, the integers of 8 to 64 bits with or without sign, GrB_FP32 and GrB_FP64
template<std::integral I>
GrB_Type ADS::graphblas::indexType (void)
 the type of GraphBLAS of the indices I, not negative, read by their size
template<CsrArrays G>
Matrix ADS::graphblas::view (const G &g)
 the \( n \times n \) matrix of the arcs of \( g \) by rows, its offsets, heads and weights read in place, iso-valued true if \( g \) is unweighted; a graph whose rows are not known to be sorted (an ArrayGraph, in the order of its edges) is checked in \( O( n + a ) \) time, and copied by copy() if the heads of some row do not increase, since GraphBLAS reads the columns of a row of a matrix that is not jumbled in increasing order
template<class T, class I, class P>
Matrix ADS::graphblas::view (const BasicCsrMatrix< T, I, P > &A)
 the \( m \times n \) matrix \( A \) by rows, its offsets, columns and values read in place
template<class G>
requires ( detail::ArcRows< G > )
Matrix ADS::graphblas::copy (const G &g)
 the \( n \times n \) matrix of the arcs of \( g \), copied by GrB_Matrix_build() (for the layouts that view() does not take), of the weights of \( g \), or true if it is unweighted
template<class T, class I = std::uint32_t, class P = ADS::detail::CsrOffset< I >>
BasicCsrMatrix< T, I, P > ADS::graphblas::toCsr (GrB_Matrix A)
 the matrix \( A \) of GraphBLAS copied into a BasicCsrMatrix of the values T, the columns I and the offsets P, by its triplets

Detailed description

The graphs and the sparse matrices of ADS as matrices of SuiteSparse.

Macro definition documentation

◆ ADS_GRB_TYPED

#define ADS_GRB_TYPED ( F,
T,
... )
Value:
[ & ]( void ) { \
if constexpr( std::is_same_v< T, bool > ) \
return( F##_BOOL( __VA_ARGS__ ) ); \
else if constexpr( std::is_floating_point_v< T > ) { \
if constexpr( sizeof( T ) == 4 ) \
return( F##_FP32( __VA_ARGS__ ) ); \
else \
return( F##_FP64( __VA_ARGS__ ) ); \
} \
else if constexpr( std::is_signed_v< T > ) { \
if constexpr( sizeof( T ) == 1 ) \
return( F##_INT8( __VA_ARGS__ ) ); \
else if constexpr( sizeof( T ) == 2 ) \
return( F##_INT16( __VA_ARGS__ ) ); \
else if constexpr( sizeof( T ) == 4 ) \
return( F##_INT32( __VA_ARGS__ ) ); \
else \
return( F##_INT64( __VA_ARGS__ ) ); \
} \
else { \
if constexpr( sizeof( T ) == 1 ) \
return( F##_UINT8( __VA_ARGS__ ) ); \
else if constexpr( sizeof( T ) == 2 ) \
return( F##_UINT16( __VA_ARGS__ ) ); \
else if constexpr( sizeof( T ) == 4 ) \
return( F##_UINT32( __VA_ARGS__ ) ); \
else \
return( F##_UINT64( __VA_ARGS__ ) ); \
} \
}()

the call of the typed function of GraphBLAS F##_< T >, for the type T of the values of the arguments

Function documentation

◆ check()

void ADS::graphblas::check ( GrB_Info r,
const char * what )
inline

throws if \( r \) is not a success of GraphBLAS, naming what

◆ copy()

template<class G>
requires ( detail::ArcRows< G > )
Matrix ADS::graphblas::copy ( const G & g)
nodiscard

the \( n \times n \) matrix of the arcs of \( g \), copied by GrB_Matrix_build() (for the layouts that view() does not take), of the weights of \( g \), or true if it is unweighted

Precondition
no two arcs of \( g \) have the same ends

◆ indexType()

template<std::integral I>
GrB_Type ADS::graphblas::indexType ( void )
nodiscard

the type of GraphBLAS of the indices I, not negative, read by their size

◆ toCsr()

template<class T, class I = std::uint32_t, class P = ADS::detail::CsrOffset< I >>
BasicCsrMatrix< T, I, P > ADS::graphblas::toCsr ( GrB_Matrix A)
nodiscard

the matrix \( A \) of GraphBLAS copied into a BasicCsrMatrix of the values T, the columns I and the offsets P, by its triplets

Precondition
the sizes fit, the columns fit I and the entries P

◆ type()

template<class T>
GrB_Type ADS::graphblas::type ( void )
nodiscard

the type of GraphBLAS of the numbers T: GrB_BOOL, the integers of 8 to 64 bits with or without sign, GrB_FP32 and GrB_FP64

◆ view() [1/2]

template<class T, class I, class P>
Matrix ADS::graphblas::view ( const BasicCsrMatrix< T, I, P > & A)
nodiscard

the \( m \times n \) matrix \( A \) by rows, its offsets, columns and values read in place

◆ view() [2/2]

template<CsrArrays G>
Matrix ADS::graphblas::view ( const G & g)
nodiscard

the \( n \times n \) matrix of the arcs of \( g \) by rows, its offsets, heads and weights read in place, iso-valued true if \( g \) is unweighted; a graph whose rows are not known to be sorted (an ArrayGraph, in the order of its edges) is checked in \( O( n + a ) \) time, and copied by copy() if the heads of some row do not increase, since GraphBLAS reads the columns of a row of a matrix that is not jumbled in increasing order