8000 Fix output array for logical ops AND, OR and NEQ · arrayfire/arrayfire-rust@412510c · GitHub
[go: up one dir, main page]

Skip to content

Commit 412510c

Browse files
committed
Fix output array for logical ops AND, OR and NEQ
Earlier, these functions were using binary_func macro which picks output based on the input arrays types. However, as these are logical operations which always result in boolean output, the correct macro to use for this is overloaded_logic_func. With this fix, ::and, ::or and ::neq functions have acquired an additional feature i.e. the user can also use scalars as one of the inputs of these functions.
1 parent d9ae5b4 commit 412510c

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/core/arith.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,6 @@ binary_func!(
316316
bitxor,
317317
af_bitxor
318318
);
319-
binary_func!(
320-
"Elementwise not equals comparison of two Arrays",
321-
neq,
322-
af_neq
323-
);
324-
binary_func!(
325-
"Elementwise logical and operation of two Arrays",
326-
and,
327-
af_and
328-
);
329-
binary_func!("Elementwise logical or operation of two Arrays", or, af_or);
330319
binary_func!(
331320
"Elementwise minimum operation of two Arrays",
332321
minof,
@@ -495,7 +484,7 @@ overloaded_binary_func!(
495484
overloaded_binary_func!("Compute root", root, root_helper, af_root);
496485
overloaded_binary_func!("Computer power", pow, pow_helper, af_pow);
497486

498-
macro_rules! overloaded_compare_func {
487+
macro_rules! overloaded_logic_func {
499488
($doc_str: expr, $fn_name: ident, $help_name: ident, $ffi_name: ident) => {
500489
fn $help_name<A, B>(lhs: &Array<A>, rhs: &Array<B>, batch: bool) -> Array<bool>
501490
where
@@ -563,36 +552,54 @@ macro_rules! overloaded_compare_func {
563552
};
564553
}
565554

566-
overloaded_compare_func!(
555+
overloaded_logic_func!(
567556
"Perform `less than` comparison operation",
568557
lt,
569558
lt_helper,
570559
af_lt
571560
);
572-
overloaded_compare_func!(
561+
overloaded_logic_func!(
573562
"Perform `greater than` comparison operation",
574563
gt,
575564
gt_helper,
576565
af_gt
577566
);
578-
overloaded_compare_func!(
567+
overloaded_logic_func!(
579568
"Perform `less than equals` comparison operation",
580569
le,
581570
le_helper,
582571
af_le
583572
);
584-
overloaded_compare_func!(
573+
overloaded_logic_func!(
585574
"Perform `greater than equals` comparison operation",
586575
ge,
587576
ge_helper,
588577
af_ge
589578
);
590-
overloaded_compare_func!(
579+
overloaded_logic_func!(
591580
"Perform `equals` comparison operation",
592581
eq,
593582
eq_helper,
594583
af_eq
595584
);
585+
overloaded_logic_func!(
586+
"Elementwise `not equals` comparison of two Arrays",
587+
neq,
588+
neq_helper,
589+
af_neq
590+
);
591+
overloaded_logic_func!(
592+
"Elementwise logical AND operation of two Arrays",
593+
and,
594+
and_helper,
595+
af_and
596+
);
597+
overloaded_logic_func!(
598+
"Elementwise logical OR operation of two Arrays",
599+
or,
600+
or_helper,
601+
af_or
602+
);
596603

597604
fn clamp_helper<X, Y>(
598605
inp: &Array<X>,

0 commit comments

Comments
 (0)
0