Closed victorstewart closed 4 years ago
If you want to create a mask vector that is mostly true, and use it as a mask in a subsequent GrB operation, like GrB_whatever (C, mask, ...), then it would be better to use a complemented mask. Set the mask to be true according to the list you have. Then when you use the mask, use a complemented descriptor.
Okay is that way more efficient than say building a mostly false with GrB_Vector_build
then using GrB_Vector_apply
with GrB_LNOT
to make it mostly true? If GrB_Vector
maintains its sparsity throughout these operations then surely.
I'm unsure what you mean by a "mostly false" mask. Do you mean very sparse? Do you mean all entries present but mostly equal to false? Those are very different.
GrB_Vector_apply will preserve the sparsity pattern. There are 3 states to consider: entry present and true, entry present and false, entry not present.
If a mask is used as a valued-mask (not structural) and not complemented, then "entry present and true" says the entry C for GrB_whatever (C,mask, ...) can be modified.
If a mask is used as a structural mask and not complemented, then the values are ignored, just if the entry is present. So C(i) is modified if mask(i) is present. GrB_Vector apply to negate the entries has no effect.
If the mask descriptor is complemented, then negate those statements above, that is "C(i) is modified" becomes "C(i) is not modified".
oh i see! I was unaware of the 3 states I thought an entry not present was equivalent to false. My first day delving into GraphBLAS.
so in the usage of GrB_vxm
the mask is a valued mask not a structural one? So if a mask entry is present and true and complemented then C(i) can NOT be modified, but every other entry in C can be modified. And if the mask entry is present and true and NOT complemented then the corresponding C(i) entries are the only ones that can be modified?
and generally which functions use values vs structural masks?
All functions can use any option: no mask, valued mask, complemented valued mask, structural mask, complemented structural mask, and (yes) even "complemented no mask" which unusual. It does nothing, except for GrB_assign on a submatrix.
I'm constructing a mask, and I have a list of
GrB_Index
that specifies which indexes are to be made false, but all the rest I want true (so I can probe them in the matrix).I wanted to just use
GrB_assign
to set all the values to true, and then useGrB_Vector_build
to feed in tuples of the indexes I want set to False... but obviously we aren't allowed to build on the GrB_Vector if it is nonempty.So what's the most efficient way to accomplish this?