php-ml/src/Phpml/Math/Product.php
2016-04-25 22:55:34 +02:00

25 lines
379 B
PHP

<?php
declare (strict_types = 1);
namespace Phpml\Math;
class Product
{
/**
* @param array $a
* @param array $b
*
* @return mixed
*/
public static function scalar(array $a, array $b)
{
$product = 0;
foreach ($a as $index => $value) {
$product += $value * $b[$index];
}
return $product;
}
}