Example usage for org.apache.commons.math3.linear Array2DRowRealMatrix Array2DRowRealMatrix

List of usage examples for org.apache.commons.math3.linear Array2DRowRealMatrix Array2DRowRealMatrix

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear Array2DRowRealMatrix Array2DRowRealMatrix.

Prototype

public Array2DRowRealMatrix(final double[][] d, final boolean copyArray)
        throws DimensionMismatchException, NoDataException, NullArgumentException 

Source Link

Document

Create a new RealMatrix using the input array as the underlying data array.

Usage

From source file:com.clust4j.utils.MatTests.java

@Test(expected = DimensionMismatchException.class)
public void testDimCheckDME1() {
    Array2DRowRealMatrix matrix1 = new Array2DRowRealMatrix(new double[5][2], false);
    Array2DRowRealMatrix matrix2 = new Array2DRowRealMatrix(new double[4][2], false);
    MatUtils.checkDims(matrix1, matrix2);
}

From source file:com.clust4j.utils.MatTests.java

@Test(expected = DimensionMismatchException.class)
public void testDimCheckDME2() {
    Array2DRowRealMatrix matrix1 = new Array2DRowRealMatrix(new double[5][2], false);
    Array2DRowRealMatrix matrix2 = new Array2DRowRealMatrix(new double[5][3], false);
    MatUtils.checkDims(matrix1, matrix2);
}

From source file:com.clust4j.algo.HDBSCANTests.java

@Test
public void testPredict() {
    HDBSCAN d = new HDBSCANParameters().fitNewModel(iris);

    /*//from w w  w.j a va 2 s .  c  o m
     * Test for dim mismatch
     */
    Array2DRowRealMatrix newData = new Array2DRowRealMatrix(
            new double[][] { new double[] { 150, 150, 150, 150, 150 } }, false);
    boolean a = false;
    try {
        d.predict(newData);
    } catch (DimensionMismatchException dim) {
        a = true;
    } finally {
        assertTrue(a);
    }

    /*
     * Ensure unsupportedOperation
     */
    newData = new Array2DRowRealMatrix(new double[][] { new double[] { 150, 150, 150, 150 } }, false);
    a = false;
    try {
        d.predict(newData);
    } catch (UnsupportedOperationException u) {
        a = true;
    } finally {
        assertTrue(a);
    }
}