php-ml/src/Phpml/Math/Product.php

26 lines
379 B
PHP
Raw Normal View History

2016-04-20 22:23:03 +00:00
<?php
declare(strict_types = 1);
namespace Phpml\Math;
class Product
{
/**
* @param array $a
* @param array $b
*
* @return mixed
*/
2016-04-21 20:12:45 +00:00
public static function scalar(array $a, array $b)
2016-04-20 22:23:03 +00:00
{
$product = 0;
foreach ($a as $index => $value) {
$product += $value * $b[$index];
}
return $product;
}
}