/** * Construct from native array * @param values the array of values */ public SparseFloatFV(float[] values) { this.values = new SparseBinSearchFloatArray(values); }
/** * Construct from an existing array of values * @param values the values */ public SparseBinSearchFloatArray(float[] values) { this(values.length); for (int i=0; i<values.length; i++) { if (values[i] != 0) set(i, values[i]); } }
@Override public float increment(int key, float value) { if (key < 0 || key >= length) throw new IndexOutOfBoundsException(Integer.toString(key)); int spot = Arrays.binarySearch(keys, 0, used, key); if (spot >= 0) return values[spot] += value; return update(-1 - spot, key, value); }
@Override public Iterable<DualEntry> unionEntries(final SparseFloatArray otherArray) { if (otherArray instanceof SparseBinSearchFloatArray) { return unionEntries((SparseBinSearchFloatArray) otherArray); } return super.unionEntries(otherArray); }
@Override public float set(int key, float value) { if (key < 0 || key >= length) throw new IndexOutOfBoundsException(Integer.toString(key)); int spot = Arrays.binarySearch(keys, 0, used, key); if (spot >= 0) return values[spot] = value; else return update(-1 - spot, key, value); }
/** * Construct empty FV with given number of bins * @param nbins the number of bins in each dimension */ public SparseFloatFV(int nbins) { values = new SparseBinSearchFloatArray(nbins); }
/** * Construct empty FV with given number of bins * @param nbins the number of bins in each dimension */ public SparseFloatFV(int nbins) { values = new SparseBinSearchFloatArray(nbins); }
/** * Construct from native array * @param values the array of values */ public SparseFloatFV(float[] values) { this.values = new SparseBinSearchFloatArray(values); }
@Override public SparseFloatArray copy() { SparseBinSearchFloatArray copy = new SparseBinSearchFloatArray(length); copy.used = used; copy.keys = Arrays.copyOf(keys, keys.length); copy.values = Arrays.copyOf(values, values.length); return copy; }
@Override public void readASCII(Scanner in) throws IOException { values = new SparseBinSearchFloatArray(0); values.readASCII(in); }
@Override public void readBinary(DataInput in) throws IOException { values = new SparseBinSearchFloatArray(0); values.readBinary(in); }
@Override public void readASCII(Scanner in) throws IOException { values = new SparseBinSearchFloatArray(0); values.readASCII(in); }
@Override public void readBinary(DataInput in) throws IOException { values = new SparseBinSearchFloatArray(0); values.readBinary(in); }
int pcount = 0; while (maxrows-- != 0) { final SparseFloatArray x = new SparseBinSearchFloatArray(0); final double y; if (binary) {
int pcount = 0; while (maxrows-- != 0) { final SparseFloatArray x = new SparseBinSearchFloatArray(0); final double y; if (binary) {