final double[] data = new double[size];
if (m.addr.isContiguous()) {
System.arraycopy(m.$, 0, data, 0, size);
} else {
//FIXME: this code is probably wrong
final MatrixOffset offset = m.addr.offset();
final int cols = m.cols();
for (int row=0; row<m.rows(); row++) {
System.arraycopy(m.$, offset.op(), data, row*cols, cols);
offset.nextRow();
}
}
return data;
}