Skip to content
Snippets Groups Projects

Bit Flag Conditional

Merged Frederik Hennig requested to merge da15siwa/pystencils:bit_masks into master
All threads resolved!

This MR introduces a bit flag conditional that acts like a ternary operator for a single bit flag. It takes at least three arguments:

  • flag_bit specifies which bit of the mask is examined
  • mask_expression is an integer-typed expression which acts as a bit mask
  • then_expression is a SymPy expression of arbitrary type, and
  • optionally else_expression is a SymPy expression of arbitrary type

flag_cond examines the given bit of the given mask and takes the value of then_expression if the bit is set to 1. If not, it becomes either 0 or else_expression:

Three argument version:

    flag_cond(flag_bit, mask, expr) = expr if (flag_bit is set in mask) else 0

Four argument version:

    flag_cond(flag_bit, mask, expr_then, expr_else) = expr_then if (flag_bit is set in mask) else expr_else

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply