@Test public void testDMatrixSparseCSC() throws Exception { DMatrixSparseCSC expected = new DMatrixSparseCSC(18, 21, 10); expected.set(3, 8, rnd.nextDouble()); expected.set(12, 18, rnd.nextDouble()); expected.set(7, 9, rnd.nextDouble()); expected.set(3, 6, rnd.nextDouble()); expected.sortIndices(null); EjmlUnitTests.assertEquals(expected, saveAndLoad(expected, expected.createLike()), TEST_F64); DMatrixSparseTriplet triplet = saveAndLoad(expected, new DMatrixSparseTriplet()); DMatrixSparseCSC actual = ConvertDMatrixStruct.convert(triplet, expected.createLike()); EjmlUnitTests.assertEquals(expected, actual, TEST_F64); EjmlUnitTests.assertEquals(expected, saveAndLoad(expected, new DMatrixRMaj(0)), TEST_F64); }
public static <T extends org.ejml.data.Matrix> T convert(Array input, T output) { checkNotNull(input, "Input array can't be null"); checkNotNull(output, "Output matrix can't be null"); checkArgument(input instanceof Matrix, "Input Array is not a Matrix type"); final Matrix array = (Matrix) input; reshapeOutputSize(array, output); if (array instanceof Sparse && output instanceof MatrixSparse) { if (output instanceof DMatrixSparseCSC) convertToDMatrixSparseCSC((Sparse) array, (DMatrixSparseCSC) output); else if (output instanceof FMatrixSparseCSC) convertToFMatrixSparseCSC((Sparse) array, (FMatrixSparseCSC) output); else if (output instanceof DMatrixSparseTriplet) convertToDMatrixSparseTriplet((Sparse) array, (DMatrixSparseTriplet) output); else if (output instanceof FMatrixSparseTriplet) convertToFMatrixSparseTriplet((Sparse) array, (FMatrixSparseTriplet) output); else throw new IllegalArgumentException("Unsupported sparse output type: " + output.getClass()); } else { if (array instanceof Sparse && output instanceof DMatrixD1) convertToDMatrix((Sparse) array, (DMatrixD1) output); else if (array instanceof Sparse && output instanceof ZMatrixD1) convertToZMatrix((Sparse) array, (ZMatrixD1) output); else if (output instanceof DMatrix) convertToDMatrix(array, (DMatrix) output); else if (output instanceof ZMatrix) convertToZMatrix(array, (ZMatrix) output); else if (output instanceof FMatrix) convertToFMatrix(array, (FMatrix) output); else if (output instanceof CMatrix) convertToCMatrix(array, (CMatrix) output); else if (output instanceof BMatrixRMaj) convertToBMatrixRMaj(array, (BMatrixRMaj) output); else throw new IllegalArgumentException("Unsupported dense output type: " + output.getClass()); } return output; }
Mat5Ejml { public static <T extends org.ejml.data.Matrix> T convert(Array input, T output) { checkNotNull(input, "Input array can't be null"); checkNotNull(output, "Output matrix can't be null"); checkArgument(input instanceof Matrix, "Input Array is not a Matrix type"); final Matrix array = (Matrix) input; reshapeOutputSize(array, output); if (array instanceof Sparse && output instanceof MatrixSparse) { if (output instanceof DMatrixSparseCSC) convertToDMatrixSparseCSC((Sparse) array, (DMatrixSparseCSC) output); else if (output instanceof FMatrixSparseCSC) convertToFMatrixSparseCSC((Sparse) array, (FMatrixSparseCSC) output); else if (output instanceof DMatrixSparseTriplet) convertToDMatrixSparseTriplet((Sparse) array, (DMatrixSparseTriplet) output); else if (output instanceof FMatrixSparseTriplet) convertToFMatrixSparseTriplet((Sparse) array, (FMatrixSparseTriplet) output); else throw new IllegalArgumentException("Unsupported sparse output type: " + output.getClass()); } else { if (array instanceof Sparse && output instanceof DMatrixD1) convertToDMatrix((Sparse) array, (DMatrixD1) output); else if (array instanceof Sparse && output instanceof ZMatrixD1) convertToZMatrix((Sparse) array, (ZMatrixD1) output); else if (output instanceof DMatrix) convertToDMatrix(array, (DMatrix) output); else if (output instanceof ZMatrix) convertToZMatrix(array, (ZMatrix) output); else if (output instanceof FMatrix) convertToFMatrix(array, (FMatrix) output); else if (output instanceof CMatrix) convertToCMatrix(array, (CMatrix) output); else if (output instanceof BMatrixRMaj) convertToBMatrixRMaj(array, (BMatrixRMaj) output); else throw new IllegalArgumentException("Unsupported dense output type: " + output.getClass()); } return output; } }
Mat5Ejml { public static <T extends org.ejml.data.Matrix> T convert(Array input, T output) { checkNotNull(input, "Input array can't be null"); checkNotNull(output, "Output matrix can't be null"); checkArgument(input instanceof Matrix, "Input Array is not a Matrix type"); final Matrix array = (Matrix) input; reshapeOutputSize(array, output); if (array instanceof Sparse && output instanceof MatrixSparse) { if (output instanceof DMatrixSparseCSC) convertToDMatrixSparseCSC((Sparse) array, (DMatrixSparseCSC) output); else if (output instanceof FMatrixSparseCSC) convertToFMatrixSparseCSC((Sparse) array, (FMatrixSparseCSC) output); else if (output instanceof DMatrixSparseTriplet) convertToDMatrixSparseTriplet((Sparse) array, (DMatrixSparseTriplet) output); else if (output instanceof FMatrixSparseTriplet) convertToFMatrixSparseTriplet((Sparse) array, (FMatrixSparseTriplet) output); else throw new IllegalArgumentException("Unsupported sparse output type: " + output.getClass()); } else { if (array instanceof Sparse && output instanceof DMatrixD1) convertToDMatrix((Sparse) array, (DMatrixD1) output); else if (array instanceof Sparse && output instanceof ZMatrixD1) convertToZMatrix((Sparse) array, (ZMatrixD1) output); else if (output instanceof DMatrix) convertToDMatrix(array, (DMatrix) output); else if (output instanceof ZMatrix) convertToZMatrix(array, (ZMatrix) output); else if (output instanceof FMatrix) convertToFMatrix(array, (FMatrix) output); else if (output instanceof CMatrix) convertToCMatrix(array, (CMatrix) output); else if (output instanceof BMatrixRMaj) convertToBMatrixRMaj(array, (BMatrixRMaj) output); else throw new IllegalArgumentException("Unsupported dense output type: " + output.getClass()); } return output; }  }
Mat5Ejml { public static <T extends org.ejml.data.Matrix> T convert(Array input, T output) { checkNotNull(input, "Input array can't be null"); checkNotNull(output, "Output matrix can't be null"); checkArgument(input instanceof Matrix, "Input Array is not a Matrix type"); final Matrix array = (Matrix) input; reshapeOutputSize(array, output); if (array instanceof Sparse && output instanceof MatrixSparse) { if (output instanceof DMatrixSparseCSC) convertToDMatrixSparseCSC((Sparse) array, (DMatrixSparseCSC) output); else if (output instanceof FMatrixSparseCSC) convertToFMatrixSparseCSC((Sparse) array, (FMatrixSparseCSC) output); else if (output instanceof DMatrixSparseTriplet) convertToDMatrixSparseTriplet((Sparse) array, (DMatrixSparseTriplet) output); else if (output instanceof FMatrixSparseTriplet) convertToFMatrixSparseTriplet((Sparse) array, (FMatrixSparseTriplet) output); else throw new IllegalArgumentException("Unsupported sparse output type: " + output.getClass()); } else { if (array instanceof Sparse && output instanceof DMatrixD1) convertToDMatrix((Sparse) array, (DMatrixD1) output); else if (array instanceof Sparse && output instanceof ZMatrixD1) convertToZMatrix((Sparse) array, (ZMatrixD1) output); else if (output instanceof DMatrix) convertToDMatrix(array, (DMatrix) output); else if (output instanceof ZMatrix) convertToZMatrix(array, (ZMatrix) output); else if (output instanceof FMatrix) convertToFMatrix(array, (FMatrix) output); else if (output instanceof CMatrix) convertToCMatrix(array, (CMatrix) output); else if (output instanceof BMatrixRMaj) convertToBMatrixRMaj(array, (BMatrixRMaj) output); else throw new IllegalArgumentException("Unsupported dense output type: " + output.getClass()); } return output; }  static Array asArray(org.ejml.data.Matrix matrix); static T convert(Array input, T output); }
Mat5Ejml { public static <T extends org.ejml.data.Matrix> T convert(Array input, T output) { checkNotNull(input, "Input array can't be null"); checkNotNull(output, "Output matrix can't be null"); checkArgument(input instanceof Matrix, "Input Array is not a Matrix type"); final Matrix array = (Matrix) input; reshapeOutputSize(array, output); if (array instanceof Sparse && output instanceof MatrixSparse) { if (output instanceof DMatrixSparseCSC) convertToDMatrixSparseCSC((Sparse) array, (DMatrixSparseCSC) output); else if (output instanceof FMatrixSparseCSC) convertToFMatrixSparseCSC((Sparse) array, (FMatrixSparseCSC) output); else if (output instanceof DMatrixSparseTriplet) convertToDMatrixSparseTriplet((Sparse) array, (DMatrixSparseTriplet) output); else if (output instanceof FMatrixSparseTriplet) convertToFMatrixSparseTriplet((Sparse) array, (FMatrixSparseTriplet) output); else throw new IllegalArgumentException("Unsupported sparse output type: " + output.getClass()); } else { if (array instanceof Sparse && output instanceof DMatrixD1) convertToDMatrix((Sparse) array, (DMatrixD1) output); else if (array instanceof Sparse && output instanceof ZMatrixD1) convertToZMatrix((Sparse) array, (ZMatrixD1) output); else if (output instanceof DMatrix) convertToDMatrix(array, (DMatrix) output); else if (output instanceof ZMatrix) convertToZMatrix(array, (ZMatrix) output); else if (output instanceof FMatrix) convertToFMatrix(array, (FMatrix) output); else if (output instanceof CMatrix) convertToCMatrix(array, (CMatrix) output); else if (output instanceof BMatrixRMaj) convertToBMatrixRMaj(array, (BMatrixRMaj) output); else throw new IllegalArgumentException("Unsupported dense output type: " + output.getClass()); } return output; }  static Array asArray(org.ejml.data.Matrix matrix); static T convert(Array input, T output);  }