| 11 | #define GB_FREE_ALL ; |
| 12 | |
| 13 | GrB_Info GB_Iterator_attach |
| 14 | ( |
| 15 | // input/output: |
| 16 | GxB_Iterator iterator, // iterator to attach to the matrix A |
| 17 | // input |
| 18 | GrB_Matrix A, // matrix to attach |
| 19 | GxB_Format_Value format, // by row, by col, or by entry (GxB_NO_FORMAT) |
| 20 | GrB_Descriptor desc |
| 21 | ) |
| 22 | { |
| 23 | |
| 24 | //-------------------------------------------------------------------------- |
| 25 | // check inputs |
| 26 | //-------------------------------------------------------------------------- |
| 27 | |
| 28 | GB_RETURN_IF_NULL (iterator) ; |
| 29 | GB_RETURN_IF_NULL_OR_FAULTY (A) ; |
| 30 | |
| 31 | if ((format == GxB_BY_ROW && A->is_csc) || |
| 32 | (format == GxB_BY_COL && !A->is_csc)) |
| 33 | { |
| 34 | return (GrB_NOT_IMPLEMENTED) ; |
| 35 | } |
| 36 | |
| 37 | //-------------------------------------------------------------------------- |
| 38 | // finish any pending work on the matrix |
| 39 | //-------------------------------------------------------------------------- |
| 40 | |
| 41 | if (GB_ANY_PENDING_WORK (A)) |
| 42 | { |
| 43 | GrB_Info info ; |
| 44 | GB_CONTEXT ("GxB_Iterator_attach") ; |
| 45 | if (desc != NULL) |
| 46 | { |
| 47 | // get the # of threads to use |
| 48 | Context->nthreads_max = desc->nthreads_max ; |
| 49 | Context->chunk = desc->chunk ; |
| 50 | } |
| 51 | GB_OK (GB_wait (A, "A", Context)) ; |
| 52 | } |
| 53 | |
| 54 | //-------------------------------------------------------------------------- |
| 55 | // clear the current position |
| 56 | //-------------------------------------------------------------------------- |
| 57 | |
| 58 | iterator->pstart = 0 ; |
| 59 | iterator->pend = 0 ; |
| 60 | iterator->p = 0 ; |
| 61 | iterator->k = 0 ; |
| 62 | |
| 63 | //-------------------------------------------------------------------------- |
| 64 | // get the matrix and save its contents in the iterator |
| 65 | //-------------------------------------------------------------------------- |
| 66 | |
| 67 | iterator->pmax = (GB_nnz (A) == 0) ? 0 : GB_nnz_held (A) ; |
| 68 | iterator->avlen = A->vlen ; |
| 69 | iterator->avdim = A->vdim ; |
| 70 | iterator->anvec = A->nvec ; |
no test coverage detected