ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Elementwise comparison, with array result

Open aldanor opened this issue 10 years ago • 3 comments

Would it make sense to have a.le(b) (also a.leq(b), a.ge(b), a.geq(b)) return boolean arrays? (where a, b : PartialOrd and properly broadcastable).

aldanor avatar Dec 27 '15 11:12 aldanor

Yes, but the comparison operators can't return this. Slightly differently named methods may.

bluss avatar Dec 27 '15 11:12 bluss

I meant PartialOrd of course -- and forgot that it already uses these method names :)

So ne, eq, ge, gt, le, lt are taken by traits, I guess the names could be something like equal, not_equal, less, less_or_equal (or less_than, leq_than), or something like that..

aldanor avatar Dec 27 '15 12:12 aldanor

Might be a good idea. In the meantime, one can use map_collect

let lt = Zip::from(&a).and(&b).map_collect(|&a, &b| a < b);

nilgoyette avatar May 17 '23 16:05 nilgoyette