protected final function mult($a, $b)
{
$val = 0;
if (count($a) != count($a)) {
throw new Exception("Array shape mismatch");
}
foreach ($a as $index => $value) {
if (!isset($b[$index])) {
throw new Exception("Array shape mismatch");
}
$val += $b[$index] * $value;
}
return $val;
}