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

25 lines
379 B
PHP
Raw Normal View History

2016-04-20 22:23:03 +00:00
<?php
2016-04-25 20:55:34 +00:00
declare (strict_types = 1);
2016-04-20 22:23:03 +00:00
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;
}
}