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 startRow, int endRow, int startColumn, int endColumn, double[][] destination)
        throws OutOfRangeException, NumberIsTooSmallException, 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 startRow, int endRow, int startColumn,
        int endColumn, boolean mustFail) {
    try {//from  w  w w  . j a  v  a2 s  .  c o m
        double[][] sub = (reference == null) ? new double[1][1] : createIdenticalCopy(reference);
        m.copySubMatrix(startRow, endRow, startColumn, endColumn, 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;
        }
    }
}