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
- Example 1
- Example 2
- Example 3
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]]
use \NDArray as nd;
$a = new nd([[2, -2], [1, -1]]);
$b = new nd([[3, -3], [2, -1]]);
$c = nd::multiply($a, $b);
print_r($c);
[[6, 6],
[2, 1]]
use \NDArray as nd;
$a = new nd([3, 2]);
$b = new nd([-1, -1]);
$c = nd::multiply($a, $b);
print_r($c);
[-3, -2]