static int indexOfMaxEntryInDoubleArray(double[] a) { if (empty(a)) ret -1; int bestIndex = 0; double bestValue = a[0]; int n = l(a); for (int i = 1; i < n; i++) { double x = a[i]; if (x > bestValue) { bestIndex = i; bestValue = x; } } ret bestIndex; }