public static Matrix randomSequentialAccessSparseMatrix(int numRows,
int nonNullRows,
int numCols,
int entriesPerRow,
double entryMean) {
SparseRowMatrix m = new SparseRowMatrix(new int[]{numRows, numCols});
//double n = 0;
Random r = new Random(1234L);
for (int i = 0; i < nonNullRows; i++) {
SequentialAccessSparseVector v = new SequentialAccessSparseVector(numCols);
for (int j = 0; j < entriesPerRow; j++) {
int col = r.nextInt(numCols);
double val = r.nextGaussian();
v.set(col, val * entryMean);
}
int c = r.nextInt(numRows);
if (r.nextBoolean() || numRows == nonNullRows) {
m.assignRow(numRows == nonNullRows ? i : c, v);
} else {
Vector other = m.getRow(r.nextInt(numRows));
if (other != null && other.getLengthSquared() > 0) {
m.assignRow(c, other.clone());
}
}
//n += m.getRow(c).getLengthSquared();
}
return m;