| 13 | // computed, with A optionally transposed. Determine if C is iso. |
| 14 | |
| 15 | GB_iso_code GB_iso_unop_code |
| 16 | ( |
| 17 | GrB_Matrix A, // input matrix |
| 18 | GB_Operator op, // unary/idxunop/binop, if present |
| 19 | bool binop_bind1st // if true, C = binop(x,A), else C = binop(A,y) |
| 20 | ) |
| 21 | { |
| 22 | |
| 23 | //-------------------------------------------------------------------------- |
| 24 | // check inputs |
| 25 | //-------------------------------------------------------------------------- |
| 26 | |
| 27 | ASSERT (A != NULL) ; |
| 28 | |
| 29 | //-------------------------------------------------------------------------- |
| 30 | // get the opcode |
| 31 | //-------------------------------------------------------------------------- |
| 32 | |
| 33 | GB_Opcode opcode = GB_NOP_code ; |
| 34 | if (op != NULL) opcode = op->opcode ; |
| 35 | |
| 36 | //-------------------------------------------------------------------------- |
| 37 | // positional ops or user-defined idxunops never result in an iso matrix |
| 38 | //-------------------------------------------------------------------------- |
| 39 | |
| 40 | // idxunops are either positional, valued, or user-defined. Positional and |
| 41 | // user-defined ops lead to a non-iso result even if the input is iso. A |
| 42 | // valued idxunop (such as GrB_VALUENE_FP32) has been renamed as a binary |
| 43 | // op, with bind_1st false. As a result, no remaining idxunops result in |
| 44 | // an iso-valued output. |
| 45 | |
| 46 | if (GB_OPCODE_IS_POSITIONAL (opcode) || GB_IS_INDEXUNARYOP_CODE (opcode)) |
| 47 | { |
| 48 | // this is the only case where C is non-iso even if A is iso |
| 49 | return (GB_NON_ISO) ; |
| 50 | } |
| 51 | |
| 52 | //-------------------------------------------------------------------------- |
| 53 | // C = unop (A) or pair (...) |
| 54 | //-------------------------------------------------------------------------- |
| 55 | |
| 56 | if ((opcode == GB_ONE_unop_code) || (opcode == GB_PAIR_binop_code)) |
| 57 | { |
| 58 | // if unop is ONE or binop is PAIR, then C is iso, with a value |
| 59 | // equal to 1 |
| 60 | return (GB_ISO_1) ; |
| 61 | } |
| 62 | |
| 63 | //-------------------------------------------------------------------------- |
| 64 | // C = binop (scalar,A) or binop (A,scalar) |
| 65 | //-------------------------------------------------------------------------- |
| 66 | |
| 67 | if ((opcode == GB_ANY_binop_code) || // C = any(...) |
| 68 | (opcode == GB_FIRST_binop_code && binop_bind1st) || // C = first(x,A) |
| 69 | (opcode == GB_SECOND_binop_code && !binop_bind1st)) // C = second(A,y) |
| 70 | { |
| 71 | // if binop is FIRST and binop_bind1st is true, or if binop is SECOND |
| 72 | // and binop_bind1st is false, or if binop is ANY, then C is iso, with |
no outgoing calls
no test coverage detected