coeus_ops/binary/
comparison.rs1use super::kernel::elementwise_binary;
4use crate::backend_ops::{BinaryOp, ElementwiseOps};
5use coeus_core::Scalar;
6use coeus_tensor::Tensor;
7
8#[inline]
10pub fn eq<T: Scalar, B: ElementwiseOps<T>>(
11 a: &Tensor<T, B>,
12 b: &Tensor<T, B>,
13 backend: &B,
14) -> Result<Tensor<T, B>, B::Error> {
15 elementwise_binary(a, b, backend, BinaryOp::Eq)
16}
17
18#[inline]
20pub fn ne<T: Scalar, B: ElementwiseOps<T>>(
21 a: &Tensor<T, B>,
22 b: &Tensor<T, B>,
23 backend: &B,
24) -> Result<Tensor<T, B>, B::Error> {
25 elementwise_binary(a, b, backend, BinaryOp::Ne)
26}
27
28#[inline]
30pub fn lt<T: Scalar, B: ElementwiseOps<T>>(
31 a: &Tensor<T, B>,
32 b: &Tensor<T, B>,
33 backend: &B,
34) -> Result<Tensor<T, B>, B::Error> {
35 elementwise_binary(a, b, backend, BinaryOp::Lt)
36}
37
38#[inline]
40pub fn gt<T: Scalar, B: ElementwiseOps<T>>(
41 a: &Tensor<T, B>,
42 b: &Tensor<T, B>,
43 backend: &B,
44) -> Result<Tensor<T, B>, B::Error> {
45 elementwise_binary(a, b, backend, BinaryOp::Gt)
46}
47
48#[inline]
50pub fn le<T: Scalar, B: ElementwiseOps<T>>(
51 a: &Tensor<T, B>,
52 b: &Tensor<T, B>,
53 backend: &B,
54) -> Result<Tensor<T, B>, B::Error> {
55 elementwise_binary(a, b, backend, BinaryOp::Le)
56}
57
58#[inline]
60pub fn ge<T: Scalar, B: ElementwiseOps<T>>(
61 a: &Tensor<T, B>,
62 b: &Tensor<T, B>,
63 backend: &B,
64) -> Result<Tensor<T, B>, B::Error> {
65 elementwise_binary(a, b, backend, BinaryOp::Ge)
66}