calculate square sum.

@param pvalue value to calculate square sum for
@return square sum
1982
private static int squareSum(final int pvalue) {
    int result = 0;
    for (final char valueDigit : String.valueOf(pvalue).toCharArray()) {
      result += Character.digit(valueDigit, 10);
    }
    return result;
  }
709919
def square_and_sum(a, s):
    
    cmin, cmax = thread_partition_array(a)
    map_noreturn(asqs, [(a, s, cmin[i], cmax[i]) for i in xrange(len(cmax))])
    return a
178939
public double getSum() {
        double sum = s.zero();
        for (int c = 0; c < this.values.length; c++) {
            sum = s.plus(sum, values[c]);
        }
        return sum;
    }
813343
public static double getPvalue(DataTable2D dataTable) {
        if(dataTable.isValid()==false) {
            throw new IllegalArgumentException("The provided Table does not have a rectangular format.");
        }

        //Estimate marginal scores and sum
        Map<Object, Double> XdotJ = new HashMap<>();
        Map<Object, Double> XIdot = new HashMap<>();
        double Xdotdot=0.0;

        for(Map.Entry<Object, AssociativeArray> entry1 : dataTable.entrySet()) {
            Object i = entry1.getKey();
            AssociativeArray row = entry1.getValue();
            
            for(Map.Entry<Object, Object> entry2 : row.entrySet()) {
                Object j = entry2.getKey();
                
                double v = TypeInference.toDouble(entry2.getValue());
                
                //Summing the columns
                if(XdotJ.containsKey(j)==false) {
                    XdotJ.put(j, v);
                }
                else {
                    XdotJ.put(j, XdotJ.get(j) + v);
                }

                //Summing the rows
                if(XIdot.containsKey(i)==false) {
                    XIdot.put(i, v);
                }
                else {
                    XIdot.put(i, XIdot.get(i) + v);
                }
                
                Xdotdot+=v;
            }
        }

        int k=XdotJ.size();
        int n=XIdot.size();

        //Calculating Qscore        
        double SumOfSquaredXdotJ=0.0;
        for(Double value : XdotJ.values()) {
            SumOfSquaredXdotJ+=value*value;
        }
        //XdotJ=null;

        double SumOfSquaredXIdot=0;
        double SumOfXIdot=0;
        for(Double value : XIdot.values()) {
            SumOfSquaredXIdot+=value*value;
            SumOfXIdot+=value;
        }
        //XIdot=null;

        double Qscore=(k-1.0)*(k*SumOfSquaredXdotJ-Xdotdot*Xdotdot)/(k*SumOfXIdot-SumOfSquaredXIdot);

        double pvalue = scoreToPvalue(Qscore, n, k);

        return pvalue;
    }
691154
public double getVariance() {
        if (!DATA_LIST.isEmpty()) {
            double sum = 0;
            double sumOfSquares = 0;
            double average = 0;
            for (DataPoint dataPoint : DATA_LIST) {
                sumOfSquares += (dataPoint.getValue() * dataPoint.getValue());
                sum += dataPoint.getValue();
            }
            average = sum / DATA_LIST.size();
            return (sumOfSquares / DATA_LIST.size()) - average * average;
        }
        return 0;
    }
456204
public static float Sum(float[] data) {
        float sum = 0;
        for (int i = 0; i < data.length; i++) {
            sum += data[i];
        }
        return sum;
    }
421731
public static double[] xVals(double[] vector) {


        if (vector == null)
            return null;
        double[] x = new double[vector.length / 2];
        int count = 0;
        for (int i = 0; i < vector.length; i++) {
            if (i % 2 != 0)
                x[count++] = vector[i];
        }
        return x;
    }
687099
protected double calcDistTSAndPattern(double[] ts, double[] pValue) {
    double INF = 10000000000000000000f;
    double bestDist = INF;
    int patternLen = pValue.length;

    int lastStartP = ts.length - pValue.length + 1;
    if (lastStartP < 1)
      return bestDist;

    Random rand = new Random();
    int startP = rand.nextInt((lastStartP - 1 - 0) + 1);

    double[] slidingWindow = new double[patternLen];

    System.arraycopy(ts, startP, slidingWindow, 0, patternLen);
    bestDist = eculideanDistNorm(pValue, slidingWindow);

    for (int i = 0; i < lastStartP; i++) {
      System.arraycopy(ts, i, slidingWindow, 0, patternLen);

      double tempDist = eculideanDistNormEAbandon(pValue, slidingWindow, bestDist);

      if (tempDist < bestDist) {
        bestDist = tempDist;
      }
    }

    return bestDist;
  }
249221
private double arith(int rowIndex){

        if(params.length != 3){
            throw new IllegalArgumentException("Wrong number of Parameters for arithmetic expression");
        }

        double res = 0;
        try{
            final RecordList.Record currentRecord = recordList.getRecords().get(rowIndex);
            String operator = params[2];

            double firstValue = Double.parseDouble(currentRecord.getValueByFieldName(params[0]));

            double secondValue = Double.parseDouble(currentRecord.getValueByFieldName(params[1]));


            if("+".equals(operator)){
                res = firstValue + secondValue;
            }else if("-".equals(operator)){
                res = firstValue - secondValue;
            }else if("*".equals(operator)){
                res = firstValue * secondValue;
            }else if("/".equals(operator)){
                res = firstValue / secondValue;
            }else if("%".equals(operator)){
                res = (firstValue / secondValue) * 100;
            }

            NumberFormat decimalFormat = NumberFormat.getFormat(".##");
            res = Double.parseDouble(decimalFormat.format(res));
        }catch(Exception e){
            System.err.println("Error calculating table arithmetic function");
        }
        return res;

    }
71420
static double expint(int p, final double result[]) {
        //double x = M_E;
        final double xs[] = new double[2];
        final double as[] = new double[2];
        final double ys[] = new double[2];
        //split(x, xs);
        //xs[1] = (double)(2.7182818284590452353602874713526625L - xs[0]);
        //xs[0] = 2.71827697753906250000;
        //xs[1] = 4.85091998273542816811e-06;
        //xs[0] = Double.longBitsToDouble(0x4005bf0800000000L);
        //xs[1] = Double.longBitsToDouble(0x3ed458a2bb4a9b00L);

        /* E */
        xs[0] = 2.718281828459045;
        xs[1] = 1.4456468917292502E-16;

        split(1.0, ys);

        while (p > 0) {
            if ((p & 1) != 0) {
                quadMult(ys, xs, as);
                ys[0] = as[0]; ys[1] = as[1];
            }

            quadMult(xs, xs, as);
            xs[0] = as[0]; xs[1] = as[1];

            p >>= 1;
        }

        if (result != null) {
            result[0] = ys[0];
            result[1] = ys[1];

            resplit(result);
        }

        return ys[0] + ys[1];
    }
1062768
public static Long getLong(long pValue) {
        if (pValue >= LONG_LOWER_BOUND &&
                pValue <= LONG_UPPER_BOUND) {
            return mLongs[((int) pValue) - LONG_LOWER_BOUND];
        } else {
            return new Long(pValue);
        }
    }
721670
public static double sum(final Iterable<Double> values) {
    double ret = 0.0;
    for (final double d : values) {
      ret += d;
    }
    return ret;
  }
642417
protected void setNextValue(final long pValue, final int pLength, final int pMaxSize) {
		long value = pValue;
		// Set to max value if pValue cannot be stored on pLength bits.
		long bitMax = (long) Math.pow(2, Math.min(pLength, pMaxSize));
		if (pValue > bitMax) {
			value = bitMax - 1;
		}
		// size to wrote
		int writeSize = pLength;
		while (writeSize > 0) {
			// modulo
			int mod = currentBitIndex % BYTE_SIZE;
			byte ret = 0;
			if (mod == 0 && writeSize <= BYTE_SIZE || pLength < BYTE_SIZE - mod) {
				// shift left value
				ret = (byte) (value << BYTE_SIZE - (writeSize + mod));
			} else {
				// shift right
				long length = Long.toBinaryString(value).length();
				ret = (byte) (value >> writeSize - length - (BYTE_SIZE - length - mod));
			}
			byteTab[currentBitIndex / BYTE_SIZE] |= ret;
			long val = Math.min(writeSize, BYTE_SIZE - mod);
			writeSize -= val;
			currentBitIndex += val;
		}
	}
1136666
function (v) {
            var a = this.val,
                x = v.x,
                y = v.y;

            v.x = x * a[0] + y * a[3] + a[6];
            v.y = x * a[1] + y * a[4] + a[7];

            return v;
        }
439547
public static double sumOfProducts(double[]... nums) {
        if (nums == null || nums.length < 1)
            return 0;
        double sum = 0;

        for (int i = 0; i < nums.length; i++) {
            /* The ith column for all of the rows */
            double[] column = column(i, nums);
            sum += times(column);

        }
        return sum;
    }
867158
public double sum() {
	double res = 0.0;
	for (int i = 0; i < len; i++) {
	    res += vect[i];
	}
	return res;	
    }
153746
@Override
	public double getVariance() {
		if(isDeterministic()) {
			return 0.0;
		}
		if(size() == 0) {
			return Double.NaN;
		}

		double sum			= 0.0;
		double sumOfSquared = 0.0;
		double errorOfSum			= 0.0;
		double errorOfSumSquared	= 0.0;
		for(int i=0; i<realizations.length; i++) {
			double value	= realizations[i] - errorOfSum;
			double newSum	= sum + value;
			errorOfSum		= (newSum - sum) - value;
			sum				= newSum;

			double valueSquared		= realizations[i] * realizations[i] - errorOfSumSquared;
			double newSumOfSquared	= sumOfSquared + valueSquared;
			errorOfSumSquared		= (newSumOfSquared-sumOfSquared) - valueSquared;
			sumOfSquared			= newSumOfSquared;
		}
		return (sumOfSquared/realizations.length - sum/realizations.length*sum/realizations.length);
	}