Skip to main content

NDArray::multiply

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

Multiply arrays element-wise


Parameters

$a $b

  • Type - NDArray | array | scalar
  • The arrays to be multiplied.

Return

NDArray

  • The multiplication 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([[2, -2], [1, -1]]);
$b = new nd([[3, -3], [2, -1]]);

$c = $a * $b;

print_r($c);
[[6, 6],
[2, 1]]