pub fn div<T: Scalar, B: ElementwiseOps<T>>(
a: &Tensor<T, B>,
b: &Tensor<T, B>,
backend: &B,
) -> Result<Tensor<T, B>, B::Error>Expand description
Element-wise division.
ยงExamples
use coeus_tensor::Tensor;
use coeus_core::SequentialBackend;
use coeus_ops::div;
let backend = SequentialBackend::new();
let a = Tensor::<f32, SequentialBackend>::from_slice([4], &[6.0, 8.0, 10.0, 12.0])
.expect("example tensor allocation succeeds");
let b = Tensor::<f32, SequentialBackend>::from_slice([4], &[2.0, 4.0, 5.0, 6.0])
.expect("example tensor allocation succeeds");
let c = div(&a, &b, &backend).expect("example division succeeds");
let s = c.as_slice();
assert!((s[0] - 3.0).abs() < 1e-5);
assert!((s[1] - 2.0).abs() < 1e-5);
assert!((s[2] - 2.0).abs() < 1e-5);
assert!((s[3] - 2.0).abs() < 1e-5);