You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DMatrixRMaj can be converted from a double-dimensional array (doulbe[][]) but not the other way around. Can we natively provide an interface for easier testing?
To be more specific, a DMatrixRMaj can be converted from a single-dimensional array or a double-dimensional array, as we can see from the constructors. One use case is asserting the exported matrix is the same as the input matrix. We also have convenience methods to process a Java Matrix or DenseMatrix following processing a DMatrixRMaj.
public class DMatrixRMaj extends DMatrix1Row {
public DMatrixRMaj(double[][] data) {
this(1, 1);
this.set(data);
}
public DMatrixRMaj(double[] data) {
this.data = (double[])data.clone();
this.numRows = this.data.length;
this.numCols = 1;
}
A DMatrixRMaj can export a single-dimensional array, as this is how the data is stored internally. But shouldn't we support all types from input to output as well?
It could be as simple as this, or converting from the double[] data to a double[][], but I do think this should be natively supported in the library natively.
/**
* Convert a {@link DMatrixRMaj} to a two-dimensional array
*
* @param matrix is an input DMatrixRMaj
* @return a 2D array
*/
public double[][] get2DData(DMatrixRMaj matrix) {
double[][] array = new double[matrix.numRows][matrix.numCols];
for (int row = 0; row < matrix.numRows; row++) {
for (int column = 0; column < matrix.numCols; column++) {
array[row][column] = matrix.get(row, column);
}
}
return array;
}
Thanks for the suggestion. I think this is a good idea. If you submit a PR for adding this to DMatrixRMaj with a unit test I'll go over it, but otherwise I'll get around to it this weekend or next week.
DMatrixRMaj
can be converted from a double-dimensional array (doulbe[][]
) but not the other way around. Can we natively provide an interface for easier testing?To be more specific, a
DMatrixRMaj
can be converted from a single-dimensional array or a double-dimensional array, as we can see from the constructors. One use case is asserting the exported matrix is the same as the input matrix. We also have convenience methods to process a Java Matrix or DenseMatrix following processing aDMatrixRMaj
.ejml/main/ejml-core/src/org/ejml/data/DMatrixRMaj.java
Line 93 in c305711
A
DMatrixRMaj
can export a single-dimensional array, as this is how the data is stored internally. But shouldn't we support all types from input to output as well?ejml/main/ejml-core/src/org/ejml/data/DMatrixD1.java
Line 60 in c305711
The text was updated successfully, but these errors were encountered: