NDArray::divide
public static function divide(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
Return the division between two arrays element-wise
Parameters
$a
$b
- Type - NDArray | array | scalar
- Input arrays
Return
NDArray
- Array with the division between
$a
and$b
element-wise
Notes
tip
GPU SUPPORTED
This operation is supported by GPU (VRAM) and contains a custom CUDA kernel.
Examples
- Example 1
- Example 2
- Example 3
use \NDArray as nd;
$c = nd::divide([5, 2, -3], [4, 3, 2]);
print_r($c);
[1.25, 0.666667, -1.5]
use \NDArray as nd;
$a = new nd([[1, 2], [3, 4]]);
$b = new nd([[1, 2], [3, 4]]);
$c = nd::divide($a, $b);
print_r($c);
[[1, 1],
[1, 1]]
use \NDArray as nd;
$a = new nd([[1, 2], [3, 4]]);
$b = new nd([[1, 2], [3, 4]]);
$c = $a / $b;
print_r($c);
[[1, 1],
[1, 1]]