Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit ce86e6a

Browse files
committed
adding logical ew binops
1 parent 157888f commit ce86e6a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/EWBinOp.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ namespace x {
8383
case LOGADDEXP:
8484
return operatorx<A>::mk_tx_(a_ptr, xt::log(xt::exp(a) + xt::exp(b)));
8585
case LOGICAL_AND:
86-
// return operatorx<A>::mk_tx_(a_ptr, a && b);
86+
return operatorx<A>::mk_tx_(a_ptr, xt::cast<bool>(a) && xt::cast<bool>(b));
8787
case LOGICAL_OR:
88-
// return operatorx<A>::mk_tx_(a_ptr, a || b);
88+
return operatorx<A>::mk_tx_(a_ptr, xt::cast<bool>(a) || xt::cast<bool>(b));
8989
case LOGICAL_XOR:
90-
// return operatorx<A>::mk_tx_(a_ptr, xt::not_equal(!a, !b));
91-
// FIXME
92-
throw std::runtime_error("Binary operation not implemented");
90+
{
91+
auto ba = xt::cast<bool>(a);
92+
auto bb = xt::cast<bool>(b);
93+
return operatorx<A>::mk_tx_(a_ptr, (b || a) && xt::not_equal(ba, bb));
94+
}
9395
}
9496
if constexpr (std::is_integral<A>::value && std::is_integral<typename T2::value_type>::value) {
9597
switch(bop) {

0 commit comments

Comments
 (0)