/** {@inheritDoc} */ @Override public OpenMapRealVector mapAddToSelf(double d) { for (int i = 0; i < virtualSize; i++) { setEntry(i, getEntry(i) + d); } return this; }
while (iter.hasNext()) { iter.advance(); double test = other.getEntry(iter.key()); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(iter.value())) { return false; iter.advance(); double test = iter.value(); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(getEntry(iter.key()))) { return false;
/** {@inheritDoc} */ @Override public OpenMapRealVector ebeDivide(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); OpenMapRealVector res = new OpenMapRealVector(this); /* * MATH-803: it is not sufficient to loop through non zero entries of * this only. Indeed, if this[i] = 0d and v[i] = 0d, then * this[i] / v[i] = NaN, and not 0d. */ final int n = getDimension(); for (int i = 0; i < n; i++) { res.setEntry(i, this.getEntry(i) / v.getEntry(i)); } return res; }
/** * Optimized method to compute distance. * * @param v Vector to compute distance to. * @return the distance from {@code this} and {@code v}. * @throws DimensionMismatchException if the dimensions do not match. */ public double getDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); Iterator iter = entries.iterator(); double res = 0; while (iter.hasNext()) { iter.advance(); int key = iter.key(); double delta; delta = iter.value() - v.getEntry(key); res += delta * delta; } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key)) { final double value = iter.value(); res += value * value; } } return FastMath.sqrt(res); }
/** * Optimized method to compute LInfDistance. * * @param v Vector to compute distance from. * @return the LInfDistance. * @throws DimensionMismatchException if the dimensions do not match. */ private double getLInfDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); double max = 0; Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); double delta = FastMath.abs(iter.value() - v.getEntry(iter.key())); if (delta > max) { max = delta; } } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key) && iter.value() > max) { max = iter.value(); } } return max; }
while (iter.hasNext()) { iter.advance(); double delta = FastMath.abs(iter.value() - v.getEntry(iter.key())); max += delta;
/** {@inheritDoc} */ @Override public OpenMapRealVector mapAddToSelf(double d) { for (int i = 0; i < virtualSize; i++) { setEntry(i, getEntry(i) + d); } return this; }
/** {@inheritDoc} */ @Override public OpenMapRealVector mapAddToSelf(double d) { for (int i = 0; i < virtualSize; i++) { setEntry(i, getEntry(i) + d); } return this; }
while (iter.hasNext()) { iter.advance(); double test = other.getEntry(iter.key()); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(iter.value())) { return false; iter.advance(); double test = iter.value(); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(getEntry(iter.key()))) { return false;
while (iter.hasNext()) { iter.advance(); double test = other.getEntry(iter.key()); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(iter.value())) { return false; iter.advance(); double test = iter.value(); if (Double.doubleToLongBits(test) != Double.doubleToLongBits(getEntry(iter.key()))) { return false;
/** {@inheritDoc} */ @Override public OpenMapRealVector ebeDivide(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); OpenMapRealVector res = new OpenMapRealVector(this); /* * MATH-803: it is not sufficient to loop through non zero entries of * this only. Indeed, if this[i] = 0d and v[i] = 0d, then * this[i] / v[i] = NaN, and not 0d. */ final int n = getDimension(); for (int i = 0; i < n; i++) { res.setEntry(i, this.getEntry(i) / v.getEntry(i)); } return res; }
/** {@inheritDoc} */ @Override public OpenMapRealVector ebeDivide(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); OpenMapRealVector res = new OpenMapRealVector(this); /* * MATH-803: it is not sufficient to loop through non zero entries of * this only. Indeed, if this[i] = 0d and v[i] = 0d, then * this[i] / v[i] = NaN, and not 0d. */ final int n = getDimension(); for (int i = 0; i < n; i++) { res.setEntry(i, this.getEntry(i) / v.getEntry(i)); } return res; }
while (iter.hasNext()) { iter.advance(); double delta = Math.abs(iter.value() - v.getEntry(iter.key())); max += delta;
/** * Optimized method to compute distance. * * @param v Vector to compute distance to. * @return the distance from {@code this} and {@code v}. * @throws DimensionMismatchException if the dimensions do not match. */ public double getDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); Iterator iter = entries.iterator(); double res = 0; while (iter.hasNext()) { iter.advance(); int key = iter.key(); double delta; delta = iter.value() - v.getEntry(key); res += delta * delta; } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key)) { final double value = iter.value(); res += value * value; } } return Math.sqrt(res); }
/** * Optimized method to compute LInfDistance. * * @param v Vector to compute distance from. * @return the LInfDistance. * @throws DimensionMismatchException if the dimensions do not match. */ private double getLInfDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); double max = 0; Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); double delta = Math.abs(iter.value() - v.getEntry(iter.key())); if (delta > max) { max = delta; } } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key) && iter.value() > max) { max = iter.value(); } } return max; }
/** * Optimized method to compute distance. * * @param v Vector to compute distance to. * @return the distance from {@code this} and {@code v}. * @throws DimensionMismatchException if the dimensions do not match. */ public double getDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); Iterator iter = entries.iterator(); double res = 0; while (iter.hasNext()) { iter.advance(); int key = iter.key(); double delta; delta = iter.value() - v.getEntry(key); res += delta * delta; } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key)) { final double value = iter.value(); res += value * value; } } return FastMath.sqrt(res); }
/** * Optimized method to compute LInfDistance. * * @param v Vector to compute distance from. * @return the LInfDistance. * @throws DimensionMismatchException if the dimensions do not match. */ private double getLInfDistance(OpenMapRealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); double max = 0; Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); double delta = FastMath.abs(iter.value() - v.getEntry(iter.key())); if (delta > max) { max = delta; } } iter = v.getEntries().iterator(); while (iter.hasNext()) { iter.advance(); int key = iter.key(); if (!entries.containsKey(key) && iter.value() > max) { max = iter.value(); } } return max; }
while (iter.hasNext()) { iter.advance(); double delta = FastMath.abs(iter.value() - v.getEntry(iter.key())); max += delta;