| 12 | #include "GB.h" |
| 13 | |
| 14 | GrB_Info GB_Mask_compatible // check type and dimensions of mask |
| 15 | ( |
| 16 | const GrB_Matrix M, // mask to check |
| 17 | const bool Mask_struct, // true if M is structural |
| 18 | const GrB_Matrix C, // C<M>= ... |
| 19 | const GrB_Index nrows, // size of output if C is NULL (see GB*assign) |
| 20 | const GrB_Index ncols, |
| 21 | GB_Context Context |
| 22 | ) |
| 23 | { |
| 24 | |
| 25 | //-------------------------------------------------------------------------- |
| 26 | // check the mask M |
| 27 | //-------------------------------------------------------------------------- |
| 28 | |
| 29 | if (M != NULL) |
| 30 | { |
| 31 | |
| 32 | if (!Mask_struct) |
| 33 | { |
| 34 | // M is typecast to boolean |
| 35 | if (!GB_Type_compatible (M->type, GrB_BOOL)) |
| 36 | { |
| 37 | GB_ERROR (GrB_DOMAIN_MISMATCH, |
| 38 | "M of type [%s] cannot be typecast to boolean", |
| 39 | M->type->name) ; |
| 40 | } |
| 41 | // if M is iso and can be typecasted to bool, Mask_struct has been |
| 42 | // set true by GB_get_mask |
| 43 | ASSERT (!M->iso) ; |
| 44 | } |
| 45 | |
| 46 | // check the mask dimensions |
| 47 | GrB_Index cnrows = (C == NULL) ? nrows : GB_NROWS (C) ; |
| 48 | GrB_Index cncols = (C == NULL) ? ncols : GB_NCOLS (C) ; |
| 49 | if (GB_NROWS (M) != cnrows || GB_NCOLS (M) != cncols) |
| 50 | { |
| 51 | GB_ERROR (GrB_DIMENSION_MISMATCH, |
| 52 | "M is " GBd "-by-" GBd "; " |
| 53 | "does not match output dimensions (" GBu "-by-" GBu ")", |
| 54 | GB_NROWS (M), GB_NCOLS (M), cnrows, cncols) ; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return (GrB_SUCCESS) ; |
| 59 | } |
| 60 |
no test coverage detected