Mask assignable operators

Issue #11 resolved
edanor repo owner created an issue

One of the requested features is to have syntax like this:

vec1[mask] = vec2

This can be possible using the same design pattern as std::mask_arrays are using. Overloading assign operators could give a very nice syntactic feature to the users.

This feature should be tested for performance.

Comments (2)

  1. edanor reporter

    Added modifiable mask subscript operators to all classes. The mask subscript can now be used on LHS of assignment operators:

    =, +=, -=, *=, /=, &=, |=, ^=, <<=, >>=, %=
    

    Also added some generic unit tests to verify this.

    Seems that this approach works, however I am not sure what will be the output performance. For now this should be treated as an experimental feature for 'mask and assign' operations. If the observed performance is dropping down, please replace the operator version with:

    • vec0[mask] = vec1 + vec2; -> vec0 = vec1.add(mask, vec2);
    • vec0[mask] += vec1; -> vec0.adda(mask, vec1);
    • vec0[mask] *= vec1; -> vec0.mula(mask, vec1);

    etc.

    If the [mask] operator causes problems in some more elaborate syntax, please report it here.

  2. Log in to comment