Java Collection Sum sum(Collection vec)

Here you can find the source of sum(Collection vec)

Description

sum

License

Apache License

Declaration

public static double[] sum(Collection<double[]> vec) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static double[] sum(Collection<double[]> vec) {
        Iterator<double[]> iter = vec.iterator();
        if (vec.size() <= 0)
            return null;
        double[] res = new double[iter.next().length];
        while (iter.hasNext()) {
            double[] tmp = iter.next();
            for (int i = 0; i < res.length; i++) {
                res[i] += tmp[i];/*from w  w  w .  j  a va2s.  com*/
            }
        }
        return res;
    }
}

Related

  1. sum(Collection list)
  2. sum(Collection values)
  3. sum(Collection values)
  4. sum(Collection values)
  5. sum(Collection values)
  6. sum(Collection values)
  7. sum(Collection collection)
  8. sum(final Collection values)
  9. sumDouble(Collection collection)