Skip to content

Eigen select

Reference issue

Fixes #2734 (closed)

What does this implement/fix?

Specialized the ternary evaluator to intercept common expressions like (a < b).select(c, d) to use typed, fully vectorized comparisons. Template specialization kicks in, if:

  • TernaryOp is scalar_boolean_select_op<Scalar, Scalar, bool>
  • Arg3Type is CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, false>, CmpLhsType, CmpRhsType>

and replaces the implementation with:

  • scalar_boolean_select_op<Scalar, Scalar, Scalar>
  • CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, true>, CmpLhsType, CmpRhsType>

Since the scalar type of the output has nothing to do with the internal comparison, it should be safe. And the usual vectorization logic should process the various expressions that are passed to it like normal.

Additional information

Edited by Charles Schlosser

Merge request reports

Loading