Пример #1
0
 public static void println(double[] p, PrintStream ps) {
   for (int i = 0; i < p.length; i++) {
     ps.print(i > 0 ? " " : "");
     ps.print(String.format("%.2f", p[i]));
   }
   ps.println();
 }
Пример #2
0
  public void save(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    String[] genes = genes();

    Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>();
    for (int j = 0; j < coefs.size(); j++) {
      maps.add(coefs.get(j).geneValues(args.compare));
    }

    ps.print("gene");
    for (int i = 0; i < coefs.size(); i++) {
      ps.print(" " + keys.get(i));
    }
    ps.println();

    for (int i = 0; i < genes.length; i++) {
      ps.print(String.format("%s", genes[i]));

      for (int j = 0; j < coefs.size(); j++) {
        Map<String, Double> map = maps.get(j);
        Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null;

        ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A"));
      }

      ps.println();
    }

    ps.println();
    ps.close();
  }