/** * Constructs directional survey data from the specified file. The file is in Excel CSV * (comma-delimited) format. * * @param fileName file containing directional survey data. */ public Data(String fileName) { try { FileInputStream fis = new FileInputStream(fileName); Scanner s = new Scanner(fis); long id = -1; DoubleList zl = new DoubleList(); DoubleList tl = new DoubleList(); DoubleList pl = new DoubleList(); while (s.hasNextLine()) { String line = s.nextLine(); String[] fields = line.split(","); if (fields.length < 4) continue; long idline = WellLog.idFromString(fields[0]); if (idline < 0) continue; if (id < 0) { id = idline; } else if (id != idline || !s.hasNextLine()) { DirectionalSurvey ds = new DirectionalSurvey(); ds.id = id; ds.z = zl.trim(); ds.t = tl.trim(); ds.p = pl.trim(); if (id == 490252304800L) { // Swap theta,phi for this survey! double[] temp = ds.t; ds.t = ds.p; ds.p = temp; } ds.n = ds.z.length; _data.put(id, ds); id = idline; zl = new DoubleList(); tl = new DoubleList(); pl = new DoubleList(); } zl.add(Double.parseDouble(fields[1])); tl.add(Double.parseDouble(fields[2])); pl.add(Double.parseDouble(fields[3])); } s.close(); } catch (IOException e) { throw new RuntimeException(e); } }
public void testSingletonDoubleList() { DoubleList list = DoubleCollections.singletonDoubleList((double) 17); assertEquals(1, list.size()); assertEquals(17, list.get(0), (double) 0); try { list.add((double) 18); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { // expected } }
private void resizeCols(int row, int col) { DoubleList cols = (DoubleList) rows.get(row); while (cols.size() <= col) cols.add(0); }