public static FloatColumn create(final String name) { return new FloatColumn(name, new FloatArrayList()); }
public static FloatColumn create(final String name, final float[] arr) { return new FloatColumn(name, new FloatArrayList(arr)); }
public static FloatColumn create(final String name, final int initialSize) { FloatColumn column = new FloatColumn(name, new FloatArrayList(initialSize)); for (int i = 0; i < initialSize; i++) { column.appendMissing(); } return column; }
/** Creates a new instance of PerfQuery */ public PerfQuery() { results = new FloatArrayList[4]; results[BRUTE_FORCE] = new FloatArrayList(); results[HAND_CODED] = new FloatArrayList(); results[INDEXED] = new FloatArrayList(); results[INDEX_CREATE] = new FloatArrayList(); }
public FloatToIdMap() { _valueToIdMap = new Float2IntOpenHashMap(); _valueToIdMap.defaultReturnValue(INVALID_KEY); _idToValueMap = new FloatArrayList(); }
@Override public FloatColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final float[] dest = new float[size()]; final int destPos = n <= 0 ? 0 : n; final int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = FloatColumnType.missingValueIndicator(); } float[] array = data.toFloatArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new FloatColumn(name() + " lag(" + n + ")", new FloatArrayList(dest)); }
private static float[] filterFloats(FloatSet floatSet, float[] source) { FloatList floatList = new FloatArrayList(); for (float value : source) { if (floatSet.contains(value)) { floatList.add(value); } } if (floatList.size() == source.length) { return source; } else { return floatList.toFloatArray(); } }
@Override public FloatColumn top(int n) { FloatArrayList top = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new FloatColumn(name() + "[Top " + n + "]", top); }
@Override public FloatColumn bottom(final int n) { FloatArrayList bottom = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new FloatColumn(name() + "[Bottoms " + n + "]", bottom); }
/** * Returns a new FloatColumn containing a value for each value in this column, truncating if necessary. * * A widening primitive conversion from an int to a float does not lose information about the overall magnitude * of a numeric value. It may, however, result in loss of precision - that is, the result may lose some of the * least significant bits of the value. In this case, the resulting floating-point value will be a correctly * rounded version of the integer value, using IEEE 754 round-to-nearest mode. * * Despite the fact that a loss of precision may occur, a widening primitive conversion never results in a * run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public FloatColumn asFloatColumn() { FloatArrayList values = new FloatArrayList(); for (int d : data) { values.add(d); } values.trim(); return FloatColumn.create(this.name(), values.elements()); }
/** * Returns a new FloatColumn containing a value for each value in this column, truncating if necessary. * * A widening primitive conversion from an int to a float does not lose information about the overall magnitude * of a numeric value. It may, however, result in loss of precision - that is, the result may lose some of the * least significant bits of the value. In this case, the resulting floating-point value will be a correctly * rounded version of the integer value, using IEEE 754 round-to-nearest mode. * * Despite the fact that a loss of precision may occur, a widening primitive conversion never results in a * run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public FloatColumn asFloatColumn() { FloatArrayList values = new FloatArrayList(); for (int d : data) { values.add(d); } values.trim(); return FloatColumn.create(this.name(), values.elements()); }
/** * Returns a new FloatColumn containing a value for each value in this column * * A widening primitive conversion from a long to a float does not lose information about the overall magnitude * of a numeric value. It may, however, result in loss of precision - that is, the result may lose some of the * least significant bits of the value. In this case, the resulting floating-point value will be a correctly * rounded version of the integer value, using IEEE 754 round-to-nearest mode. * * Despite the fact that a loss of precision may occur, a widening primitive conversion never results in a * run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public FloatColumn asFloatColumn() { FloatArrayList values = new FloatArrayList(); for (long d : data) { values.add(d); } values.trim(); return FloatColumn.create(this.name(), values.elements()); }
/** * Returns a new FloatColumn containing a value for each value in this column, truncating if necessary. * * A narrowing primitive conversion such as this one may lose information about the overall magnitude of a * numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value * of large magnitude or negative infinity), the result is the smallest representable value of type float. * * Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the * largest representable value of type float. * * Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive * conversion never results in a run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public FloatColumn asFloatColumn() { FloatArrayList values = new FloatArrayList(); for (double d : data) { values.add((float) d); } values.trim(); return FloatColumn.create(this.name(), values.elements()); } }
@Override protected List<?> buildPrimitiveList(int capacity) { _type = Float.class; return capacity > 0 ? new FloatArrayList(capacity) : new FloatArrayList(); }
@Override public FloatArrayList clone() { FloatArrayList c = new FloatArrayList(size); System.arraycopy(a, 0, c.a, 0, size); c.size = size; return c; } /**
public static FloatColumn create(final String name, final int initialSize) { FloatColumn column = new FloatColumn(name, new FloatArrayList(initialSize)); for (int i = 0; i < initialSize; i++) { column.appendMissing(); } return column; }
public FloatArrayList toFloatArray() { FloatArrayList output = new FloatArrayList(data.size()); for (short aData : data) { output.add(aData); } return output; }
public FloatArrayList toFloatArray() { FloatArrayList output = new FloatArrayList(data.size()); for (long aData : data) { output.add(aData); } return output; }
@Override public FloatColumn top(int n) { FloatArrayList top = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new FloatColumn(name() + "[Top " + n + "]", top); }
@Override public FloatColumn bottom(final int n) { FloatArrayList bottom = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new FloatColumn(name() + "[Bottoms " + n + "]", bottom); }