/** * @param sample * @return */ private int getDomainElementIndex(final double sample) { int i = -1; // Special 'binarySearch' for NaN i = PiecewiseUtilities.binarySearch(minimums, sample); if (i >= 0) { // The value is exactly equals to one of minimum, // or is one of NaN values. There is nothing else to do. assert Double.doubleToRawLongBits(sample) == Double.doubleToRawLongBits(minimums[i]); return i; } assert i == Arrays.binarySearch(minimums, sample) : i; // 'binarySearch' found the index of "insertion point" (-(insertion // point) - 1). The // insertion point is defined as the point at which the key would be // inserted into the list: the index of the first element greater than // the key, or list.size(), if all elements in the list are less than // the specified key. Note that this guarantees that the return value // will be >= 0 if and only if the key is found. i = -i - 1; return i; }
/** * @param sample * @return */ private int getDomainElementIndex(final double sample) { int i = -1; // Special 'binarySearch' for NaN i = PiecewiseUtilities.binarySearch(minimums, sample); if (i >= 0) { // The value is exactly equals to one of minimum, // or is one of NaN values. There is nothing else to do. assert Double.doubleToRawLongBits(sample) == Double.doubleToRawLongBits(minimums[i]); return i; } assert i == Arrays.binarySearch(minimums, sample) : i; // 'binarySearch' found the index of "insertion point" (-(insertion // point) - 1). The // insertion point is defined as the point at which the key would be // inserted into the list: the index of the first element greater than // the key, or list.size(), if all elements in the list are less than // the specified key. Note that this guarantees that the return value // will be >= 0 if and only if the key is found. i = -i - 1; return i; }