cmp method
Implementation
double cmp(List<dynamic> temp, List<dynamic> cand, int q) {
double dist = 0.0;
double diff = 0.0;
for (int i = 0; i < temp.length; i++) {
diff = (temp[i] - cand[i]).abs();
if (q == 1)
dist += diff;
else if (q == 2)
dist += diff * diff;
else if (q == INFINITY && diff > dist)
dist = diff;
else
dist += pow(diff, q);
}
if (q == 1 || q == INFINITY)
return dist;
else if (q == 2) return sqrt(dist);
return pow(dist, 1.0 / q).toDouble();
}