The data is not necessarily stored as a double[][]
array. In fact, it is stored as a double[]
array. You can obtain the internal DenseMatrix64F
, and from this, you can obtain the double[]
array:
double data[] = cMatrix.getMatrix().getData();
This array stored the data in row-major format.
In order to store this in a single value, you can call
double singleValue = cMatrix.getMatrix().getData()[0];
EDIT: I think this was asked for in the comments, but I'm not sure....:
private static double[][] toArray(DenseMatrix64f matrix)
{
double array[][] = new double[matrix.getNumRows()][matrix.getNumCols()];
for (int r=0; r<matrix.getNumRows(); r++)
{
for (int c=0; c<matrix.getNumCols(); c++)
{
array[r][c] = matrix.get(r,c);
}
}
return array;
}