* @return a new sparse matrix from the stream.
* @throws IOException in case of an IO error.
*/
public static SparseDoubleRowMatrix readSparseMatrix(DataInput in)
throws IOException {
SparseDoubleRowMatrix mat = new SparseDoubleRowMatrix(in.readInt(),
in.readInt());
final int numRowIndices = in.readInt();
for (int i = 0; i < numRowIndices; i++) {
final int rowIndex = in.readInt();
final int numColumns = in.readInt();
DoubleVector row = new SparseDoubleVector(mat.getColumnCount());
for (int j = 0; j < numColumns; j++) {
row.set(in.readInt(), in.readDouble());
}
mat.setRowVector(rowIndex, row);
}
return mat;
}