mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-11 08:10:56 +00:00
code style Update Phpml\Math\Distance\Manhattan::distance() method. (#154)
I think this will be better.
This commit is contained in:
parent
f7537c049a
commit
ff80af2044
@ -18,13 +18,8 @@ class Manhattan implements Distance
|
|||||||
throw InvalidArgumentException::arraySizeNotMatch();
|
throw InvalidArgumentException::arraySizeNotMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$distance = 0;
|
return array_sum(array_map(function ($m, $n) {
|
||||||
$count = count($a);
|
return abs($m - $n);
|
||||||
|
}, $a, $b));
|
||||||
for ($i = 0; $i < $count; ++$i) {
|
|
||||||
$distance += abs($a[$i] - $b[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $distance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user