| 21 | #include "GB_split.h" |
| 22 | |
| 23 | GrB_Info GB_split // split a matrix |
| 24 | ( |
| 25 | GrB_Matrix *Tiles, // 2D row-major array of size m-by-n |
| 26 | const GrB_Index m, |
| 27 | const GrB_Index n, |
| 28 | const GrB_Index *Tile_nrows, // array of size m |
| 29 | const GrB_Index *Tile_ncols, // array of size n |
| 30 | const GrB_Matrix A, // input matrix |
| 31 | GB_Context Context |
| 32 | ) |
| 33 | { |
| 34 | |
| 35 | //-------------------------------------------------------------------------- |
| 36 | // allocate workspace |
| 37 | //-------------------------------------------------------------------------- |
| 38 | |
| 39 | // set all Tiles to NULL |
| 40 | GrB_Info info ; |
| 41 | ASSERT (Tiles != NULL) ; |
| 42 | memset (Tiles, 0, m * n * sizeof (GrB_Matrix)) ; |
| 43 | |
| 44 | GB_WERK_DECLARE (Tile_rows, int64_t) ; |
| 45 | GB_WERK_DECLARE (Tile_cols, int64_t) ; |
| 46 | GB_WERK_PUSH (Tile_rows, m+1, int64_t) ; |
| 47 | GB_WERK_PUSH (Tile_cols, n+1, int64_t) ; |
| 48 | if (Tile_rows == NULL || Tile_cols == NULL) |
| 49 | { |
| 50 | // out of memory |
| 51 | GB_FREE_ALL ; |
| 52 | return (GrB_OUT_OF_MEMORY) ; |
| 53 | } |
| 54 | |
| 55 | //-------------------------------------------------------------------------- |
| 56 | // check inputs |
| 57 | //-------------------------------------------------------------------------- |
| 58 | |
| 59 | ASSERT_MATRIX_OK (A, "A input for GB_split", GB0) ; |
| 60 | GB_MATRIX_WAIT (A) ; |
| 61 | if (A->iso) |
| 62 | { |
| 63 | GBURBLE ("(iso split) ") ; |
| 64 | } |
| 65 | |
| 66 | //-------------------------------------------------------------------------- |
| 67 | // check the sizes of each tile |
| 68 | //-------------------------------------------------------------------------- |
| 69 | |
| 70 | int64_t nrows = GB_NROWS (A) ; |
| 71 | int64_t ncols = GB_NCOLS (A) ; |
| 72 | |
| 73 | int64_t s = 0 ; |
| 74 | for (int64_t i = 0 ; i < m ; i++) |
| 75 | { |
| 76 | GrB_Index tile_nrows = Tile_nrows [i] ; // # of rows in Tile{i,:} |
| 77 | if (tile_nrows < 0 || tile_nrows > nrows) |
| 78 | { |
| 79 | return (GrB_DIMENSION_MISMATCH) ; |
| 80 | } |
no test coverage detected