| 59 | //------------------------------------------------------------------------------ |
| 60 | |
| 61 | GrB_Info GB_transpose // C=A', C=(ctype)A' or C=op(A') |
| 62 | ( |
| 63 | GrB_Matrix C, // output matrix C, possibly modified in-place |
| 64 | GrB_Type ctype, // desired type of C; if NULL use A->type. |
| 65 | // ignored if op is present (cast to op->ztype) |
| 66 | const bool C_is_csc, // desired CSR/CSC format of C |
| 67 | const GrB_Matrix A, // input matrix; C == A if done in place |
| 68 | // no operator is applied if op is NULL |
| 69 | const GB_Operator op_in, // unary/idxunop/binop to apply |
| 70 | const GrB_Scalar scalar, // scalar to bind to binary operator |
| 71 | bool binop_bind1st, // if true, binop(x,A) else binop(A,y) |
| 72 | bool flipij, // if true, flip i,j for user idxunop |
| 73 | GB_Context Context |
| 74 | ) |
| 75 | { |
| 76 | |
| 77 | //-------------------------------------------------------------------------- |
| 78 | // check inputs and determine if transpose is done in-place |
| 79 | //-------------------------------------------------------------------------- |
| 80 | |
| 81 | GrB_Info info ; |
| 82 | ASSERT (C != NULL) ; |
| 83 | ASSERT (A != NULL) ; |
| 84 | bool in_place = (A == C) ; |
| 85 | GB_WERK_DECLARE (Count, int64_t) ; |
| 86 | int64_t *iwork = NULL ; size_t iwork_size = 0 ; |
| 87 | int64_t *jwork = NULL ; size_t jwork_size = 0 ; |
| 88 | GB_void *Swork = NULL ; size_t Swork_size = 0 ; |
| 89 | struct GB_Matrix_opaque T_header ; |
| 90 | GrB_Matrix T = NULL ; |
| 91 | GB_CLEAR_STATIC_HEADER (T, &T_header) ; |
| 92 | |
| 93 | ASSERT_MATRIX_OK (A, "A input for GB_transpose", GB0) ; |
| 94 | ASSERT_TYPE_OK_OR_NULL (ctype, "ctype for GB_transpose", GB0) ; |
| 95 | ASSERT_OP_OK_OR_NULL (op_in, "unop/binop for GB_transpose", GB0) ; |
| 96 | ASSERT_SCALAR_OK_OR_NULL (scalar, "scalar for GB_transpose", GB0) ; |
| 97 | |
| 98 | if (in_place) |
| 99 | { |
| 100 | GBURBLE ("(in-place transpose) ") ; |
| 101 | } |
| 102 | |
| 103 | // get the current sparsity control of A |
| 104 | float A_hyper_switch = A->hyper_switch ; |
| 105 | float A_bitmap_switch = A->bitmap_switch ; |
| 106 | int A_sparsity_control = A->sparsity_control ; |
| 107 | int64_t avlen = A->vlen ; |
| 108 | int64_t avdim = A->vdim ; |
| 109 | |
| 110 | // wait if A has pending tuples or zombies; leave jumbled unless avdim == 1 |
| 111 | if (GB_PENDING (A) || GB_ZOMBIES (A) || (avdim == 1 && GB_JUMBLED (A))) |
| 112 | { |
| 113 | GB_OK (GB_wait (A, "A", Context)) ; |
| 114 | } |
| 115 | ASSERT (!GB_PENDING (A)) ; |
| 116 | ASSERT (!GB_ZOMBIES (A)) ; |
| 117 | ASSERT (GB_JUMBLED_OK (A)) ; |
| 118 | ASSERT (GB_IMPLIES (avdim == 1, !GB_JUMBLED (A))) ; |
no test coverage detected