/** {@inheritDoc} */ @Override public RealVector mapAbsToSelf() { for (int i = 0; i < data.length; i++) { data[i] = FastMath.abs(data[i]); } return this; }
/** * Determine if this value is within epsilon of zero. * @param value The value to test * @return <code>true</code> if this value is within epsilon to zero, <code>false</code> otherwise * @since 2.1 */ protected boolean isDefaultValue(double value) { return FastMath.abs(value) < epsilon; }
/** {@inheritDoc} */ @Override public double value(double d) { return FastMath.abs(d); } };
/** {@inheritDoc} */ @Override public double getL1Norm() { double sum = 0; for (double a : data) { sum += FastMath.abs(a); } return sum; }
/** * Compute least significant bit (Unit in Last Position) for a number. * @param x number from which ulp is requested * @return ulp(x) */ public static double ulp(double x) { if (Double.isInfinite(x)) { return Double.POSITIVE_INFINITY; } return abs(x - Double.longBitsToDouble(Double.doubleToLongBits(x) ^ 1)); }
/** * Compute least significant bit (Unit in Last Position) for a number. * @param x number from which ulp is requested * @return ulp(x) */ public static float ulp(float x) { if (Float.isInfinite(x)) { return Float.POSITIVE_INFINITY; } return abs(x - Float.intBitsToFloat(Float.floatToIntBits(x) ^ 1)); }
/** {@inheritDoc} */ @Override public double getL1Distance(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double sum = 0; for (int i = 0; i < data.length; ++i) { final double delta = data[i] - v[i]; sum += FastMath.abs(delta); } return sum; }
/** {@inheritDoc} */ public void visit(final int row, final int column, final double value) { columnSum += FastMath.abs(value); if (row == endRow) { maxColSum = FastMath.max(maxColSum, columnSum); columnSum = 0; } }
/** {@inheritDoc} */ public boolean converged(final int iteration, final RealPointValuePair previous, final RealPointValuePair current) { final double p = previous.getValue(); final double c = current.getValue(); final double difference = FastMath.abs(p - c); final double size = FastMath.max(FastMath.abs(p), FastMath.abs(c)); return (difference <= (size * relativeThreshold)) || (difference <= absoluteThreshold); } }
/** Simple constructor. * @param h fixed time step (sign is not used) * @param handler fixed time step handler to wrap */ public StepNormalizer(final double h, final FixedStepHandler handler) { this.h = FastMath.abs(h); this.handler = handler; reset(); }
/** {@inheritDoc} */ @Override public double getLInfNorm() { double max = 0; for (double a : data) { max = FastMath.max(max, FastMath.abs(a)); } return max; }
/** {@inheritDoc} */ @Override public double getL1Distance(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double max = 0; for (int i = 0; i < v.length; i++) { double delta = FastMath.abs(getEntry(i) - v[i]); max += delta; } return max; }
/** {@inheritDoc} */ @Override public double getLInfDistance(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double max = 0; for (int i = 0; i < data.length; ++i) { final double delta = data[i] - v[i]; max = FastMath.max(max, FastMath.abs(delta)); } return max; }
/** {@inheritDoc} */ public double getLInfNorm() { double norm = 0; Iterator<Entry> it = sparseIterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { norm = FastMath.max(norm, FastMath.abs(e.getValue())); } return norm; }
/** {@inheritDoc} */ public double getL1Distance(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double d = 0; Iterator<Entry> it = iterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { d += FastMath.abs(e.getValue() - v[e.getIndex()]); } return d; }
/** {@inheritDoc} */ public double getL1Distance(RealVector v) throws IllegalArgumentException { checkVectorDimensions(v); double d = 0; Iterator<Entry> it = iterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { d += FastMath.abs(e.getValue() - v.getEntry(e.getIndex())); } return d; }
/** {@inheritDoc} */ public double getLInfDistance(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double d = 0; Iterator<Entry> it = iterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { d = FastMath.max(FastMath.abs(e.getValue() - v[e.getIndex()]), d); } return d; }
/** {@inheritDoc} */ public double getLInfDistance(RealVector v) throws IllegalArgumentException { checkVectorDimensions(v); double d = 0; Iterator<Entry> it = iterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { d = FastMath.max(FastMath.abs(e.getValue() - v.getEntry(e.getIndex())), d); } return d; }