/** {@inheritDoc} */ public double value(double x) { return FastMath.signum(x); } }
/** {@inheritDoc} * @since 3.2 */ public Decimal64 signum() { return new Decimal64(FastMath.signum(value)); }
/** {@inheritDoc} */ public SparseGradient signum() { return createConstant(FastMath.signum(value)); }
@Override public int compare(IndexedLineSegment a, IndexedLineSegment b) { return (int) FastMath.signum(a.distance(coord) - b.distance(coord)); } }
/** {@inheritDoc} * @since 3.2 */ public DerivativeStructure signum() { return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), FastMath.signum(data[0])); }
final double correction = (FastMath.signum(y2) * FastMath.signum(y3)) * (x3 - x1) / FastMath.sqrt(delta); final double x = x3 - correction; // correction != 0 if (FastMath.signum(y1) + FastMath.signum(y) == 0.0) { x2 = x; y2 = y; if (FastMath.signum(y2) + FastMath.signum(y) == 0.0) { x1 = x; y1 = y;
/** {@inheritDoc} */ public double value(double x) { return FastMath.signum(x); } }
/** {@inheritDoc} * @since 3.2 */ public Decimal64 signum() { return new Decimal64(FastMath.signum(value)); }
/** {@inheritDoc} */ public SparseGradient signum() { return createConstant(FastMath.signum(value)); }
private void formatCoordinate(StringBuffer buff, double d) { String s = sexagesimalFormatFactory.create(decimal).format(d); if (StringUtils.startsWith(s, "-")) { s = s.substring(1); } buff.append(s); if (signum(d) > 0.0) { buff.append(WHITE); buff.append(EAST); } else { buff.append(WHITE); buff.append(WEST); } }
private void formatCoordinate(StringBuffer buff, double d) { String s = sexagesimalFormatFactory.create(decimal).format(d); if (StringUtils.startsWith(s, "-")) { s = s.substring(1); } buff.append(s); if (signum(d) > 0.0) { buff.append(" "); buff.append(NORTH); } else { buff.append(" "); buff.append(SOUTH); } }
@Override public void run() { for (long k = firstIdx; k < lastIdx; k++) { res.setByte(k, (byte) FastMath.signum(a.getDouble(k))); } } });
/** {@inheritDoc} * @since 3.2 */ public DerivativeStructure signum() { return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), FastMath.signum(data[0])); }
/** * Complex square root. * <p> * @param a complex number * <p> * @return sqrt(a) */ public static float[] complexSqrt(float[] a) { float[] res = new float[2]; double mod = FastMath.sqrt(a[0] * a[0] + a[1] * a[1]); res[0] = (float) FastMath.sqrt((a[0] + mod) / 2.0); res[1] = (float) (FastMath.signum(a[1]) * FastMath.sqrt((-a[0] + mod) / 2.0)); return res; }
/** * Complex square root. * <p> * @param a complex number * <p> * @return sqrt(a) */ public static double[] complexSqrt(double[] a) { double[] res = new double[2]; double mod = FastMath.sqrt(a[0] * a[0] + a[1] * a[1]); res[0] = FastMath.sqrt((a[0] + mod) / 2.0); res[1] = FastMath.signum(a[1]) * FastMath.sqrt((-a[0] + mod) / 2.0); return res; }
private double updateWeight(DoubleVector newWeights, DoubleVector toBeUpdated, double shrinkageVal, int i, double weight) { double absWeight = FastMath.abs(weight); double newWeight = FastMath.signum(weight) * FastMath.max(0.0, absWeight - shrinkageVal); if (FastMath.abs(newWeight) < tol) { newWeight = 0; } toBeUpdated.set(i, newWeight); return absWeight; }
@Override public void run() { float[] elem_res = new float[2]; for (long k = firstIdx; k < lastIdx; k++) { float[] elem_a = _ac.getComplexFloat(k); double mod = FastMath.sqrt(elem_a[0] * elem_a[0] + elem_a[1] * elem_a[1]); elem_res[0] = (float) (FastMath.sqrt((elem_a[0] + mod) / 2.0)); elem_res[1] = (float) (FastMath.signum(elem_a[1]) * FastMath.sqrt((-elem_a[0] + mod) / 2.0)); resc.setComplexFloat(k, elem_res); } } });
@Override public void run() { double[] elem_res = new double[2]; for (long k = firstIdx; k < lastIdx; k++) { double[] elem_a = _ac.getComplexDouble(k); double mod = FastMath.sqrt(elem_a[0] * elem_a[0] + elem_a[1] * elem_a[1]); elem_res[0] = FastMath.sqrt((elem_a[0] + mod) / 2.0); elem_res[1] = FastMath.signum(elem_a[1]) * FastMath.sqrt((-elem_a[0] + mod) / 2.0); resc.setComplexDouble(k, elem_res); } } });
@Override public DoubleVector prePredictionWeightUpdate( FeatureOutcomePair featureOutcome, DoubleVector theta, double learningRate, long iteration) { if (squaredPreviousGradient == null) { // initialize zeroed vectors of the same type as the weights squaredPreviousGradient = theta.deepCopy().multiply(0); perCoordinateWeights = theta.deepCopy().multiply(0); } Iterator<DoubleVectorElement> iterateNonZero = featureOutcome.getFeature() .iterateNonZero(); while (iterateNonZero.hasNext()) { DoubleVectorElement next = iterateNonZero.next(); double gradientValue = next.getValue(); int index = next.getIndex(); double zi = perCoordinateWeights.get(index); double ni = squaredPreviousGradient.get(index); if (FastMath.abs(zi) <= l1) { theta.set(index, 0); } else { double value = -1d / (((beta + FastMath.sqrt(ni)) / learningRate) + l2); value = value * (zi - FastMath.signum(gradientValue) * l1); theta.set(index, value); } } return theta; }