@Override public int computeHashCode(SparseDoubleArray array) { return (array.get(dimension) - shift) >= 0 ? 1 : 0; } }
@Override public int computeHashCode(SparseDoubleArray array) { return (array.get(dimension) - shift) >= 0 ? 1 : 0; } }
@Override public double getAsDouble(int i) { return values.get(i); }
@Override public double getAsDouble(int i) { return values.get(i); }
@Override public int computeHashCode(SparseDoubleArray array) { // which hash function if (bitsPerDim == 0) { return array.get(ham) == 0 ? 0 : 1; } else { // compact binary data final int m = ham % bitsPerDim; final int d = ham / bitsPerDim; return (int) (HammingHelper.convert(array.get(d)) >>> m & 1L); } } }
@Override public int computeHashCode(SparseDoubleArray array) { // which hash function if (bitsPerDim == 0) { return array.get(ham) == 0 ? 0 : 1; } else { // compact binary data final int m = ham % bitsPerDim; final int d = ham / bitsPerDim; return (int) (HammingHelper.convert(array.get(d)) >>> m & 1L); } } }
/** * Compute the dot product with another vector * @param vector the other vector * @return the dot product */ public double dotProduct(SparseDoubleArray vector) { double sum = 0; int tused = this.used(); int vused = vector.used(); SparseDoubleArray smaller = (tused < vused ? this : vector); SparseDoubleArray larger = (tused < vused ? vector : this); for (Entry e : smaller.entries()) { sum += e.value * larger.get(e.index); } return sum; }