MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / get_matrix

Function get_matrix

deps/GraphBLAS/Demo/Source/get_matrix.c:24–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "graphblas_demos.h"
23
24GB_PUBLIC
25GrB_Info get_matrix // get a matrix from stdin, or create random one
26(
27 GrB_Matrix *A_output, // matrix to create
28 int argc, // command-line arguments
29 char **argv,
30 bool no_self_edges, // if true, ensure the matrix has no self-edges
31 bool boolean, // if true, file is read as GrB_BOOL, else GrB_FP64
32 bool spones // if true, return all entries equal to 1
33)
34{
35
36 GrB_Info info ;
37 GrB_Index nrows = 1, ncols = 1, ntuples = 1, nvals ;
38 GrB_Matrix A = NULL ;
39 GrB_Matrix Mask = NULL ;
40 GrB_Descriptor desc = NULL ;
41 int kind = 0 ;
42
43 if (argc > 2)
44 {
45
46 //----------------------------------------------------------------------
47 // create a random matrix
48 //----------------------------------------------------------------------
49
50 kind = strtol (argv [1], NULL, 0) ;
51
52 if (kind == 0)
53 {
54
55 //------------------------------------------------------------------
56 // random pattern
57 //------------------------------------------------------------------
58
59 // usage: ./main 0 nrows ncols ntuples method
60
61 int method = 0 ; // 0:setElement, 1:build
62
63 if (argc > 2) nrows = strtol (argv [2], NULL, 0) ;
64 if (argc > 3) ncols = strtol (argv [3], NULL, 0) ;
65 if (argc > 4) ntuples = strtol (argv [4], NULL, 0) ;
66 if (argc > 5) method = strtol (argv [5], NULL, 0) ;
67
68 OK (random_matrix (&A, true, no_self_edges,
69 nrows, ncols, ntuples, method, false)) ;
70
71 // force completion, just to check timing
72 GrB_Matrix_nvals (&nvals, A) ;
73
74 // printf format warnings can vary with different compilers, so
75 // punt and type cast to double
76 printf ( "random %.16g by %.16g, nz: %.16g, method %d\n",
77 (double) nrows, (double) ncols, (double) nvals, method) ;
78
79 fprintf (stderr, "random %.16g by %.16g, nz: %.16g, method %d\n",
80 (double) nrows, (double) ncols, (double) nvals, method) ;
81

Callers

nothing calls this directly

Calls 11

random_matrixFunction · 0.85
GrB_Matrix_nvalsFunction · 0.85
GrB_Matrix_nrowsFunction · 0.85
GrB_Matrix_newFunction · 0.85
GrB_Descriptor_newFunction · 0.85
GrB_Descriptor_setFunction · 0.85
GrB_transposeFunction · 0.85
GrB_Matrix_freeFunction · 0.85
GrB_Descriptor_freeFunction · 0.85
read_matrixFunction · 0.85
GrB_Matrix_ncolsFunction · 0.85

Tested by

no test coverage detected