Skip to main content

NDArray::subtract

public static function subtract(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;

Subtract two arrays element-wise


Parameters

$a $b

  • Type - NDArray | array | scalar
  • Input arrays

Return

NDArray

  • Element-wise subtraction of $a and $b element-wise

Notes

tip

GPU SUPPORTED

This operation is supported by GPU (VRAM) and contains a custom CUDA kernel.


Examples

use \NDArray as nd;

$a = new nd([[1, 2], [3, 4]]);
$b = new nd([[1, 2], [3, 4]]);

$c = nd::subtract($a, $b);

print_r($c);
[[0, 0],
[0, 0]]