| 18 | #include "GB_concat.h" |
| 19 | |
| 20 | GrB_Info GB_concat_hyper // concatenate into a hypersparse matrix |
| 21 | ( |
| 22 | GrB_Matrix C, // input/output matrix for results |
| 23 | const bool C_iso, // if true, construct C as iso |
| 24 | const GB_void *cscalar, // iso value of C, if C is iso |
| 25 | const int64_t cnz, // # of entries in C |
| 26 | const GrB_Matrix *Tiles, // 2D row-major array of size m-by-n, |
| 27 | const GrB_Index m, |
| 28 | const GrB_Index n, |
| 29 | const int64_t *restrict Tile_rows, // size m+1 |
| 30 | const int64_t *restrict Tile_cols, // size n+1 |
| 31 | GB_Context Context |
| 32 | ) |
| 33 | { |
| 34 | |
| 35 | //-------------------------------------------------------------------------- |
| 36 | // allocate triplet workspace to construct C as hypersparse |
| 37 | //-------------------------------------------------------------------------- |
| 38 | |
| 39 | GrB_Info info ; |
| 40 | GrB_Matrix A = NULL ; |
| 41 | ASSERT_MATRIX_OK (C, "C input to concat hyper", GB0) ; |
| 42 | |
| 43 | int64_t *restrict Wi = NULL ; size_t Wi_size = 0 ; |
| 44 | int64_t *restrict Wj = NULL ; size_t Wj_size = 0 ; |
| 45 | GB_void *restrict Wx = NULL ; size_t Wx_size = 0 ; |
| 46 | |
| 47 | GrB_Type ctype = C->type ; |
| 48 | int64_t cvlen = C->vlen ; |
| 49 | int64_t cvdim = C->vdim ; |
| 50 | bool csc = C->is_csc ; |
| 51 | size_t csize = ctype->size ; |
| 52 | GB_Type_code ccode = ctype->code ; |
| 53 | |
| 54 | float hyper_switch = C->hyper_switch ; |
| 55 | float bitmap_switch = C->bitmap_switch ; |
| 56 | int sparsity_control = C->sparsity_control ; |
| 57 | |
| 58 | GB_phybix_free (C) ; |
| 59 | |
| 60 | Wi = GB_MALLOC (cnz, int64_t, &Wi_size) ; // becomes C->i |
| 61 | Wj = GB_MALLOC_WORK (cnz, int64_t, &Wj_size) ; // freed below |
| 62 | if (!C_iso) |
| 63 | { |
| 64 | Wx = GB_MALLOC_WORK (cnz * csize, GB_void, &Wx_size) ; // freed below |
| 65 | } |
| 66 | if (Wi == NULL || Wj == NULL || (!C_iso && Wx == NULL)) |
| 67 | { |
| 68 | // out of memory |
| 69 | GB_FREE_ALL ; |
| 70 | return (GrB_OUT_OF_MEMORY) ; |
| 71 | } |
| 72 | |
| 73 | GB_GET_NTHREADS_MAX (nthreads_max, chunk, Context) ; |
| 74 | |
| 75 | int64_t nouter = csc ? n : m ; |
| 76 | int64_t ninner = csc ? m : n ; |
| 77 |
no test coverage detected