Skip to main content

NDArray::prod

public static function prod(NDArray|array|float|int $a, ?int $axis = NULL): NDArray|float|int;

Calculates the product of all elements in the array over a given axis along which a product is performed.

The default, axis=NULL, will calculate the product of all the elements in the input array.

Parameters

$a

  • Type - NDArray|array|scalar
  • Input array

$axis

  • Type - NDArray|array|scalar
  • The axis to perform the product. If $axis is NULL, will calculate the product of all the elements of $a.

Return

NDArray

  • The product of $a. If $axis is not NULL, the specified axis is removed.

Examples

use \NDArray as nd;

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

$c = nd::prod($a);

print_r($c);
24