Normalize the moments

@param sum Sums
@param nmom Number of moments
504169
private static void normalizeLMR(double[] sum, int nmom) {
    for(int k = nmom - 1; k >= 1; --k) {
      double p = ((k & 1) == 0) ? +1 : -1;
      double temp = p * sum[0];
      for(int i = 0; i < k; i++) {
        double ai = i + 1.;
        p *= -(k + ai) * (k - i) / (ai * ai);
        temp += p * sum[i + 1];
      }
      sum[k] = temp;
    }
  }
85529
public final void mSUM() throws RecognitionException {
		try {
			int _type = SUM;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// hql.g:62:5: ( 'sum' )
			// hql.g:62:7: 'sum'
			{
			match("sum"); if (state.failed) return;

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
1365815
public static void normalizeColumns(final double[][] m1) {
    final int columndimension = getColumnDimensionality(m1);
    for(int col = 0; col < columndimension; col++) {
      double norm = 0.0;
      for(int row = 0; row < m1.length; row++) {
        final double v = m1[row][col];
        norm += v * v;
      }
      if(norm > 0) {
        norm = FastMath.sqrt(norm);
        for(int row = 0; row < m1.length; row++) {
          m1[row][col] /= norm;
        }
      }
    }
  }
13518
public void combine(IntSummaryStatistics other) {
        count += other.count;
        sum += other.sum;
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }
984133
public double[] znorm(double[] series, double normalizationThreshold) {
    double[] res = new double[series.length];
    double sd = stDev(series);
    if (sd < normalizationThreshold) {
      // return series.clone();
      // return array of zeros
      return res;
    }
    double mean = mean(series);
    for (int i = 0; i < res.length; i++) {
      res[i] = (series[i] - mean) / sd;
    }
    return res;
  }
474454
public final void mLONG_SUM() throws RecognitionException {
		try {
			int _type = LONG_SUM;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// druidG.g:609:10: ( ( 'LONG_SUM' ) )
			// druidG.g:609:12: ( 'LONG_SUM' )
			{
			// druidG.g:609:12: ( 'LONG_SUM' )
			// druidG.g:609:13: 'LONG_SUM'
			{
			match("LONG_SUM"); 

			}

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
425181
public static void doubleCenterSymmetric(double[][] m) {
    final int size = m.length;
    // Storage for mean values - initially all 0.
    double[] means = new double[size];
    for(int x = 0; x < m.length; x++) {
      final double[] rowx = m[x];
      // We already added "x" values in previous iterations.
      // Fake-add 0: mean + (0 - mean) / (x + 1)
      double rmean = means[x] - means[x] / (x + 1);
      for(int y = x + 1; y < rowx.length; y++) {
        final double nv = rowx[y];
        final double dx = nv - rmean, dy = nv - means[y];
        // For x < y, this is the yth entry.
        rmean += dx / (y + 1);
        // For y > x, this is the xth entry
        means[y] += dy / (x + 1);
      }
      means[x] = rmean;
    }
    // Compute total mean by averaging column means.
    double mean = means[0];
    for(int x = 1; x < size; x++) {
      double dm = means[x] - mean;
      mean += dm / (x + 1);
    }
    // Row and column center; also make symmetric.
    for(int x = 0; x < size; x++) {
      m[x][x] = -2. * means[x] + mean;
      for(int y = x + 1; y < size; y++) {
        final double nv = m[x][y] - means[x] - means[y] + mean;
        m[x][y] = nv;
        m[y][x] = nv;
      }
    }
  }
273256
def reduce(self, sum1, sum2, *args):
        
        self.sum1g[...] += sum1
        if not self.pts_only: self.sum2g[...] += sum2

        if self.compute_mean_coords:
            N, centers_sum = args
            self.N[...] += N
            for i in range(self.bins.Ndim):
                self.centers[i][...] += centers_sum[i]
298128
def _mom(self, k, dist, cache):
        """"""
        return (-1)**numpy.sum(k)*evaluation.evaluate_moment(
            dist, k, cache=cache)
175565
public void put(Mean other) {
    if(other.n == 0) {
      return;
    }
    this.sum += other.sum;
    this.n = other.n + this.n;
  }
93095
private void accumulateNormal(final Element center, final Element pre,
            final Element post) {
        double cx = center.getDouble("x");
        double cy = center.getDouble("y");
        double cz = center.getDouble("z");

        double ax = post.getDouble("x") - cx;
        double ay = post.getDouble("y") - cy;
        double az = post.getDouble("z") - cz;
        double a = Math.sqrt(ax * ax + ay * ay + az * az);
        if (a < EPSILON) {
            return;
        }

        double bx = pre.getDouble("x") - cx;
        double by = pre.getDouble("y") - cy;
        double bz = pre.getDouble("z") - cz;
        double b = Math.sqrt(bx * bx + by * by + bz * bz);
        if (b < EPSILON) {
            return;
        }

        double nx = ay * bz - az * by;
        double ny = az * bx - ax * bz;
        double nz = ax * by - ay * bx;
        double n = Math.sqrt(nx * nx + ny * ny + nz * nz);
        if (n < EPSILON) {
            return;
        }

        double sin = n / (a * b);
        double dot = ax * bx + ay * by + az * bz;

        double angle;
        if (dot < 0) {
            angle = Math.PI - Math.asin(sin);
        } else {
            angle = Math.asin(sin);
        }
        double factor = angle / n;
        nx *= factor;
        ny *= factor;
        nz *= factor;

        center.setDouble("nx", center.getDouble("nx") + nx);
        center.setDouble("ny", center.getDouble("ny") + ny);
        center.setDouble("nz", center.getDouble("nz") + nz);
    }
474544
function sum(transform) {
  let sum = 0;
  let seq = typeof transform === 'function' ? this.select(transform) : this;

  for (let item of seq) {
    sum += Number.parseFloat(item);
  }

  return sum;
}
762507
public static int sum( InterleavedS8 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
70148
protected void removeNormalization( TrifocalTensor solution ) {
		DMatrixRMaj N2_inv = N2.matrixInv();
		DMatrixRMaj N3_inv = N3.matrixInv();

		DMatrixRMaj N1 = this.N1.matrix();

		for( int i = 0; i < 3; i++ ) {
			DMatrixRMaj T = solution.getT(i);
			for( int j = 0; j < 3; j++ ) {
				for( int k = 0; k < 3; k++ ) {

					double sum = 0;

					for( int r = 0; r < 3; r++ ) {
						double n1 = N1.get(r,i);
						DMatrixRMaj TN = solutionN.getT(r);
	                    for( int s = 0; s < 3; s++ ) {
							double n2 = N2_inv.get(j,s);
							for( int t = 0; t < 3; t++ ) {
								sum += n1*n2*N3_inv.get(k,t)*TN.get(s,t);
							}
						}
					}

					T.set(j,k,sum);
				}
			}
		}
	}
421859
public static double sum( InterleavedF64 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
536117
@Override
  public MeanVarianceMinMax put(double[] vals) {
    final int l = vals.length;
    if(l < 2) {
      if(l == 1) {
        put(vals[0]);
      }
      return this;
    }
    // First pass:
    double s1 = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i];
      s1 += v;
      min = v < min ? v : min;
      max = v > max ? v : max;
    }
    final double om1 = s1 / l;
    // Second pass:
    double om2 = 0., err = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i] - om1;
      om2 += v * v;
      err += v;
    }
    s1 += err;
    om2 += err / l;
    if(n <= 0) {
      n = l;
      sum = s1;
      m2 = om2;
      return this;
    }
    final double tmp = n * s1 - sum * l;
    final double oldn = n; // tmp copy
    n += l;
    sum += s1 + err;
    m2 += om2 + tmp * tmp / (l * n * oldn);
    return this;
  }
1000541
@Override
    public <N extends Number> Expression<N> sum(Expression<N> arg0)
    {
        // TODO Auto-generated method stub
        return null;
    }