/** * Returns a float representation of the data at the given index. Some precision may be lost, and if the value is * to large to be cast to a float, an exception is thrown. * * @throws ClassCastException if the value can't be cast to ta float */ public float getFloat(int row) { return data.getFloat(row); }
@Override public Float get(int index) { return data.getFloat(index); }
@Override public double getDouble(int row) { float value = data.getFloat(row); if (isMissingValue(value)) { return FloatColumnType.missingValueIndicator(); } return value; }
/** * Returns a float representation of the data at the given index. Some precision may be lost, and if the value is * to large to be cast to a float, an exception is thrown. * * @throws ClassCastException if the value can't be cast to ta float */ public float getFloat(int row) { return data.getFloat(row); }
@Override public Float get(int index) { return data.getFloat(index); }
@Override public float getFloat(int index) { return data.getFloat(index); }
public float get(int index) { return data.getFloat(index); }
@Override public String getString(int row) { return String.valueOf(data.getFloat(row)); }
public float firstElement() { if (size() > 0) { return data.getFloat(0); } return MISSING_VALUE; }
static public void add(FloatArrayList list, int index, float inc) { list.set(index, list.getFloat(index)+inc); } }
/** * Get a particular entry of the vector. * * @param i the entry * @return the value of the entry. */ public float get(int i) { // The default value is 0.0 if (i >= entries.size()) { return 0.0f; } return entries.getFloat(i); }
@Override public void write(DataOutput out) throws IOException { out.writeBoolean(isSingleton); if (isSingleton) { out.writeInt(singletonIndex); out.writeFloat(singletonValue); } else { out.writeInt(entries.size()); for (int i = 0; i < entries.size(); ++i) { out.writeFloat(entries.getFloat(i)); } } }
@Override public double getDouble(int row) { float value = data.getFloat(row); if (isMissingValue(value)) { return FloatColumnType.missingValueIndicator(); } return value; }
public double[] toDoubleArray() { double[] output = new double[data.size()]; for (int i = 0; i < data.size(); i++) { output[i] = data.getFloat(i); } return output; }
@Override public int countUnique() { FloatSet floats = new FloatOpenHashSet(); for (int i = 0; i < size(); i++) { floats.add(data.getFloat(i)); } return floats.size(); }
public Selection select(FloatPredicate predicate) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { float next = data.getFloat(idx); if (predicate.test(next)) { bitmap.add(idx); } } return bitmap; }
public Selection select(FloatBiPredicate predicate, float value) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { float next = data.getFloat(idx); if (predicate.test(next, value)) { bitmap.add(idx); } } return bitmap; }
@Override public FloatColumn unique() { FloatSet floats = new FloatOpenHashSet(); for (int i = 0; i < size(); i++) { floats.add(data.getFloat(i)); } FloatColumn column = new FloatColumn(name() + " Unique values", floats.size()); floats.forEach(column::add); return column; }