Skip to content

Propose to add a double[][] convenience method to convert back from DMatrixRMaj #193

@ee08b397

Description

@ee08b397

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 DMatrixRMaj( double[][] data ) {

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?

public abstract class DMatrixD1 implements ReshapeMatrix, DMatrix {

    public double[] getData() {
        return this.data;
    }

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions