use of gov.sandia.n2a.linear.MatrixSparse in project n2a by frothga.
the class Matrix method factory.
public static Matrix factory(Path path) throws EvaluationException {
try (BufferedReader reader = Files.newBufferedReader(path)) {
char[] buffer = new char[10];
reader.mark(buffer.length + 1);
// just assume buffer is filled completely
reader.read(buffer);
String line = new String(buffer);
reader.reset();
if (line.toLowerCase().startsWith("sparse"))
return new MatrixSparse(reader);
// TODO: import Matlab format.
return new MatrixDense(reader);
} catch (IOException exception) {
throw new EvaluationException("Can't open matrix file");
}
}
Aggregations