Relational operators and optimizations for `all()`
I realized that the most common use of all()
is for relational expressions like all(X > 3)
, and there is actually some complexity in those. Based on Armadillo's implementation, I adapted the relevant classes to Bandicoot:
- There are now several
mtop_rel_*
classes to handle relational expressions against a scalar (likeX > 3
). If evaluated, like Armadillo, they return acoot::Mat<uword>
. Kernels were required for every possible relational operation (>
,<
,>=
,<=
,==
,!=
). - Scalar relational expressions are twoway kernels, and so there is extra support to optimize relational expressions on conversions, like
conv_to<Mat<eT2>>::from(X) > 3
. - The
mtGlue
class needed to be added, to handle glue-expressions with a different output type. - The
Glue_traits
types were adapted from Armadillo for BandicootGlue
types. - Several
mtglue_rel_*
classes are added to handle elementwise relational expressions likeX > Y
or similar. - Integrating conversions into elementwise relational operations is a bit trickier, so this is not done.
- A couple extra optimizations for
all()
are added; e.g.,all(X > 0)
for unsigned integerX
is equivalent toall(X)
. - Tests are added for all of these things.
I'll let this sit for a few days and then merge it.
The support here will be needed for any()
, which is what I will implement next. :)