Skip to content
Holger Arndt edited this page Feb 10, 2016 · 2 revisions

Please visit https://ujmp.org for more info.

FAQ

How can I append a row (or several rows) to a dense or sparse matrix? The matrix should be empty in its initial state. The rows to append are represented by Java 1D arrays or ArrayList?

double[] array1 = new double[] { 1, 2, 3 };
double[] array2 = new double[] { 4, 5, 6 };
double[] array3 = new double[] { 7, 8, 9 };
Matrix row1 = Matrix.Factory.linkToArray(array1).transpose();
Matrix row2 = Matrix.Factory.linkToArray(array2).transpose();
Matrix m = Matrix.Factory.vertCat(row1, row2);
Matrix row3 = Matrix.Factory.linkToArray(array3).transpose();
m = m.appendVertically(Ret.NEW, row3);

How can I convert a sparse or dense matrix to a 2D Java array?

double[][] rawData= matrix.toDoubleArray();

How can missing values be represented? Do I have to use e.g. some custom values (-inv.) or is there a built in type?

Double.NaN, Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY are all treated as missing values. I would prefer Double.NaN.

Clone this wiki locally