code: private static double[][] rowsum(double[][] rr, ArrayList<String> sets) throws Exception {
  		LinkedHashMap<String, Double> sumMap = new LinkedHashMap<String, Double>();
  		if (rr.length != sets.size()) {
  			throw new Exception("Cluster value for each sample are not of equal length n=" + rr.length + " cluster length=" + sets.size());
  		}
  		double[][] sum = null;
  		for (int j = 0; j < rr[0].length; j++) {
  			for (int i = 0; i < sets.size(); i++) {
  				String s = sets.get(i);
  				Double v = sumMap.get(s); //get in order
  				if (v == null) {
  					v = 0.0;
  				}
  				v = v + rr[i][j];
  				sumMap.put(s, v);
  
  			}
  			if (sum == null) {
  				sum = new double[sumMap.size()][rr[0].length];
  			}
  
  			ArrayList<String> index = new ArrayList<String>(sumMap.keySet());
  			//sorting does seem to make a difference in test cases at the .0000000001
  	   //     ArrayList<Integer> in = new ArrayList<Integer>();
  	   //     for (String s : index) {
  	   //         in.add(Integer.parseInt(s));
  	   //     }
  	   //     Collections.sort(index);
  
  			for (int m = 0; m < index.size(); m++) {
  				String key = index.get(m);
  				sum[m][j] = sumMap.get(key);
  			}
  
  			sumMap.clear();
  		}
  
  		return sum;
  
  	}
docs: From R in residuals.coxph.S rowsum(rr, collapse)
  
  @param rr
  @param sets
  @return