Euclidean optimization (#42)

* Euclidean optimization

* Euclidean with foreach
This commit is contained in:
Mustafa Karabulut 2017-02-09 12:30:38 +03:00 committed by Arkadiusz Kondas
parent 1d73503958
commit 0a58a71d77

View File

@ -24,10 +24,9 @@ class Euclidean implements Distance
}
$distance = 0;
$count = count($a);
for ($i = 0; $i < $count; ++$i) {
$distance += pow($a[$i] - $b[$i], 2);
foreach ($a as $i => $val) {
$distance += ($val - $b[$i]) ** 2;
}
return sqrt((float) $distance);