Get the sum total of a given array's values.
@param array with values
@return int || float
486883
public static function total($array = false, $decimals = 2) {

        if($array && Validate::isArray($array)) {

            return self::round(array_sum($array), $decimals);
        }

        return false;
    }
504936
public static int sum (int[] list)
    {
        int total = 0, lsize = list.length;
        for (int ii = 0; ii < lsize; ii++) {
            total += list[ii];
        }
        return total;
    }
1054415
private function calculate1(array $array)
    {
        for ($i=count($array)-1; $i>=0; $i--) {
            if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1])
            && $array[$i] === '^') {
                $otp = 1;
                $this->checkInf($array[$i-1], $array[$i+1]);
                if (is_numeric($array[$i-1]) && is_numeric($array[$i+1])) {
                    if ($array[$i-1] < 0) {
                        $a = pow($array[$i-1]*-1, $array[$i+1]);
                        $otp = 2;
                    } else {
                        $a = pow($array[$i-1], $array[$i+1]);
                    }
                } else {
                    $this->correct = 0;
                    break;
                }
                unset($array[$i-1], $array[$i+1]);
                $array[$i] = ($otp == 1) ? $a : $a*-1;
                $array = array_values($array);
                $i = count($array)-1;
            }
        }
        return $array;
    }
337642
public static double median(Array array) throws ExpressionException {

	int len = array.size();

	if (len == 0) return 0;

	if (array.getDimension() > 1) throw new ExpressionException("Median() can only be calculated for one dimensional arrays");

	double[] arr = new double[len];

	for (int i = 0; i < len; i++)
	    arr[i] = _toDoubleValue(array, i + 1);

	Arrays.sort(arr);

	double result = arr[len / 2];

	if (len % 2 == 0) {

	    return (result + arr[(len - 2) / 2]) / 2;
	}

	return result;
    }
737309
protected function setAmountsPrecision($array)
    {
        $amounts = explode(',', str_replace(' ', '', $array['amounts']));
        unset($array['amounts']);
        $temp = [];

        try {
            foreach ($amounts as $amount) {
                $temp[] = bcadd($amount, '0', 8);
            }

            return array_merge(
                        ['amounts' => implode(',', array_values($temp))],
                        $array
                    );
        } catch (Exception $e) {
            $e->getMessage();
        }
    }
345961
public static double computeEnergy( float []array  ) {
		double total = 0;

		for( int i = 0; i < array.length; i++ ) {
			total += array[i]*array[i];
		}

		return total;
	}
205450
public function sum($cb = null)
    {
        $sum = 0;

        $this->recursive(
            $this->storage,
            function ($value) use (& $sum) {
                if (is_numeric($value)) {
                    $sum += $value;
                }
            }
        );

        if ($cb !== null) {
            call_user_func_array($cb, [$sum]);
        }

        return $sum;
    }
258676
public static double kthSmallestValue(int[] array, int k) {

    int[] index = new int[array.length];
    
    for (int i = 0; i < index.length; i++) {
      index[i] = i;
    }

    return array[index[select(array, index, 0, array.length - 1, k)]];
  }
673895
public static int count(float[] array, float val) {
        int count = 0;
        for (int i=0; i<array.length; i++) {
            if (array[i] == val) {
                count++;
            }
        }
        return count;
    }
243208
public function sum($key = null)
    {
        $callback = $this->valueAccessor($key);

        return $this->reduce(function ($result, $item) use ($callback) {
            return $result + $callback($item);
        }, 0);
    }
668306
function array_sum (arr) {
		var ans = 0;
		for (k = 0; k < arr.length; k++) {
			ans += arr[k];
		}
		return ans;
	}
1027252
function array_sum_intervals($array_external, $intervals){

        $n_intervals=explode(";", $intervals);
        $array_amount = count($n_intervals);
        $result = 0;
        for($i=0; $i < $array_amount ; $i++){
            $result += $this->array_sum_interval($array_external, $n_intervals[$i]);
        }
        return $result;

    }
938405
function (array) {
                        var total = 0,
                            i;
                        for (i = 0; i < array.length; i += 1) {
                            if (isNaN(array[i])) {
                                total = undefined;
                                break;
                            } else {
                                total += parseFloat(array[i]);
                            }
                        }
                        return total;
                    }
110827
public int sum() {
        int total = 0;
        int N = getNumElements();
        for (int i = 0; i < N; i++) {
            if( data[i] )
                total += 1;
        }
        return total;
    }
502846
public static double sum(double[] a, int fromIndex, int toIndex) {
    double result = 0.0;
    for (int i = fromIndex; i < toIndex; i++) {
      result += a[i];
    }
    return result;
  }
174977
public static int count(int[] array, int value) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == value) {
                count++;
            }
        }
        return count;
    }
264634
public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'filters'  => [],
            'include'  => [],
            'exclude'  => [],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['filters']  = (array) $args['filters'];
        $args['include']  = (array) $args['include'];
        $args['exclude']  = (array) $args['exclude'];
        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total post types in the query.

        $post_types = get_post_types($args['filters'], 'objects');
        $post_types = $args['include'] ? array_intersect_key($post_types, array_fill_keys($args['include'], true)) : $post_types;
        $post_types = $args['exclude'] ? array_diff_key($post_types, array_fill_keys($args['exclude'], true)) : $post_types;

        return $total = count($post_types);
    }