Example usage for org.apache.commons.math3.linear RealMatrix copySubMatrix

List of usage examples for org.apache.commons.math3.linear RealMatrix copySubMatrix

Introduction

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

Prototype

void copySubMatrix(int[] selectedRows, int[] selectedColumns, double[][] destination)
        throws OutOfRangeException, NullArgumentException, NoDataException, MatrixDimensionMismatchException;

Source Link

Document

Copy a submatrix.

Usage

From source file:lirmm.inria.fr.math.BigSparseRealMatrixTest.java

private void checkCopy(RealMatrix m, double[][] reference, int[] selectedRows, int[] selectedColumns,
        boolean mustFail) {
    try {//from   ww w.j  a  v  a 2 s.  co  m
        double[][] sub = (reference == null) ? new double[1][1] : createIdenticalCopy(reference);
        m.copySubMatrix(selectedRows, selectedColumns, sub);
        Assert.assertEquals(new BigSparseRealMatrix(reference), new BigSparseRealMatrix(sub));
        if (mustFail) {
            Assert.fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException");
        }
    } catch (OutOfRangeException e) {
        if (!mustFail) {
            throw e;
        }
    } catch (NumberIsTooSmallException e) {
        if (!mustFail) {
            throw e;
        }
    } catch (NoDataException e) {
        if (!mustFail) {
            throw e;
        }
    } catch (MatrixDimensionMismatchException e) {
        if (!mustFail) {
            throw e;
        }
    }
}