Unitize an array so that L1 norm of x is 1.

@param x an array of nonnegative double
978857
public static void unitize1(double[] x) {
        double n = norm1(x);

        for (int i = 0; i < x.length; i++) {
            x[i] /= n;
        }
    }
852116
public void add(final float x) {
        if(isInitializing) {
            q[ni++] = x;

            if(ni == 2*m+3+1) {
                Arrays.sort(q);
                isInitializing=false;
            }
        } else {
            addMeasurement(x);
        }
    }
480730
protected double norm(double x, int i) {
    if (Double.isNaN(m_Ranges[i][R_MIN]) || (m_Ranges[i][R_MAX] == m_Ranges[i][R_MIN]))
      return 0;
    else
      return (x - m_Ranges[i][R_MIN]) / (m_Ranges[i][R_WIDTH]);
  }
1014617
public double[] normOne(double[] data) {
    double[] res = new double[data.length];
    double max = max(data);
    for (int i = 0; i < data.length; i++) {
      res[i] = data[i] / max;
    }
    return res;
  }
564499
public float linear(float[] x, int m) {
    float result = (float) 1.0;
    int M = x.length;

    for (int i = 1; i <= M - m; i++) {
      result *= x[i - 1];
    }

    if (m != 1) {
      result *= (1 - x[M - m]);
    }

    return result;
  }
954475
@Override
    public void setDouble(int parameterIndex, double x) throws SQLException
    {
        checkParameterBounds(parameterIndex);
        this.parameters[parameterIndex-1] = x;
    }
1094609
public static double sigmoid(double x) {
    if (x<0) {
      double num = Math.exp(x);
      return num / (1.0 + num);
    }
    else {
      double den = 1.0 + Math.exp(-x);
      return 1.0 / den;
    }
  }
877520
@Override
    public double logLikelihood(double[] x) {
        double L = 0.0;
        
        for (double xi : x)
            L += logp(xi);
        
        return L;
    }
304175
public static double[] normalizeEquals(final double[] v1) {
    final double norm = 1. / euclideanLength(v1);
    if(norm < Double.POSITIVE_INFINITY) {
      for(int row = 0; row < v1.length; row++) {
        v1[row] *= norm;
      }
    }
    return v1;
  }
709904
public static double[] normalizeL1(double[] vector) {
		// compute vector 1-norm
		double norm1 = 0;
		for (int i = 0; i < vector.length; i++) {
			norm1 += Math.abs(vector[i]);
		}

		if (norm1 == 0) {
			Arrays.fill(vector, 1.0 / vector.length);
		} else {
			for (int i = 0; i < vector.length; i++) {
				vector[i] = vector[i] / norm1;
			}
		}
		return vector;
	}
1289063
public void add(double x) {
        Cell[] as; long b, v; int[] hc; Cell a; int n;
        if ((as = cells) != null ||
                !casBase(b = base,
                        Double.doubleToRawLongBits
                                (Double.longBitsToDouble(b) + x))) {
            boolean uncontended = true;
            if ((hc = threadHashCode.get()) == null ||
                    as == null || (n = as.length) < 1 ||
                    (a = as[(n - 1) & hc[0]]) == null ||
                    !(uncontended = a.cas(v = a.value,
                            Double.doubleToRawLongBits
                                    (Double.longBitsToDouble(v) + x))))
                retryUpdate(Double.doubleToRawLongBits(x), hc, uncontended);
        }
    }
202231
public static List<int[]> getNegativeRanges( double[] x ) {
        int firstNegative = -1;
        int lastNegative = -1;
        List<int[]> rangeList = new ArrayList<int[]>();

        for( int i = 0; i < x.length; i++ ) {
            double xValue = x[i];
            if (firstNegative == -1 && xValue < 0) {
                firstNegative = i;
            } else if (firstNegative != -1 && lastNegative == -1 && xValue > 0) {
                lastNegative = i - 1;
            }

            if (i == x.length - 1 && firstNegative != -1 && lastNegative == -1) {
                // need to close the range with the last value available, even if negative
                lastNegative = i;
            }

            if (firstNegative != -1 && lastNegative != -1) {
                rangeList.add(new int[]{firstNegative, lastNegative});
                firstNegative = -1;
                lastNegative = -1;
            }
        }

        return rangeList;
    }
1025283
private static double getNorm(double[] w)
  {
    double norm = 0;
    for (int i = 0; i < w.length; i++) {
      norm += w[i]*w[i];
    }
    return norm;
  }
281662
public double interpolate(double... x) {
        if (x.length != this.x[0].length) {
            throw new IllegalArgumentException(String.format("Invalid input vector size: %d, expected: %d", x.length, this.x[0].length));
        }

        double sum = 0.0, sumw = 0.0;
        for (int i = 0; i < this.x.length; i++) {
            double f = rbf.f(Math.distance(x, this.x[i]));
            sumw += w[i] * f;
            sum += f;
        }

        return normalized ? sumw / sum : sumw;
    }
1139926
public static double ulp(double x) {
        if (Double.isInfinite(x)) {
            return Double.POSITIVE_INFINITY;
        }
        return abs(x - Double.longBitsToDouble(Double.doubleToLongBits(x) ^ 1));
    }
640777
public static int max(int[] x) {
        int m = x[0];

        for (int n : x) {
            if (n > m) {
                m = n;
            }
        }

        return m;
    }
756220
public static FloatMatrix normalizeRows(FloatMatrix x) {
                FloatMatrix temp = new FloatMatrix(x.columns);
		for (int r = 0; r < x.rows; r++)
			x.putRow(r, normalize(x.getRow(r, temp)));
		return x;
	}