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

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

Introduction

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

Prototype

protected AbstractRealMatrix() 

Source Link

Document

Creates a matrix with no data

Usage

From source file:edu.dfci.cccb.mev.hcl.domain.simple.SimpleTwoDimensionalHclBuilder.java

private RealMatrix toRealMatrix(final Dataset dataset) {
    return new AbstractRealMatrix() {

        @Override// www  .j  a  v a 2 s.com
        public void setEntry(int row, int column, double value) throws OutOfRangeException {
            throw new UnsupportedOperationException();
        }

        @Override
        @SneakyThrows(InvalidDimensionTypeException.class)
        public int getRowDimension() {
            return dataset.dimension(ROW).keys().size();
        }

        @Override
        @SneakyThrows({ InvalidDimensionTypeException.class, InvalidCoordinateException.class })
        public double getEntry(int row, int column) throws OutOfRangeException {
            return dataset.values().get(dataset.dimension(ROW).keys().get(row),
                    dataset.dimension(COLUMN).keys().get(column));
        }

        @Override
        @SneakyThrows(InvalidDimensionTypeException.class)
        public int getColumnDimension() {
            return dataset.dimension(COLUMN).keys().size();
        }

        @Override
        public RealMatrix createMatrix(int rowDimension, int columnDimension)
                throws NotStrictlyPositiveException {
            throw new UnsupportedOperationException();
        }

        @Override
        public RealMatrix copy() {
            throw new UnsupportedOperationException();
        }
    };
}

From source file:edu.dfci.cccb.mev.domain.Heatmap.java

private RealMatrix transpose(final RealMatrix original) {
    return new AbstractRealMatrix() {

        @Override/*  w  w w  . j  a  v  a2  s .c o m*/
        public void setEntry(int row, int column, double value) throws OutOfRangeException {
            original.setEntry(column, row, value);
        }

        @Override
        public int getRowDimension() {
            return original.getColumnDimension();
        }

        @Override
        public double getEntry(int row, int column) throws OutOfRangeException {
            return original.getEntry(column, row);
        }

        @Override
        public int getColumnDimension() {
            return original.getRowDimension();
        }

        @Override
        public RealMatrix createMatrix(int rowDimension, int columnDimension)
                throws NotStrictlyPositiveException {
            return original.createMatrix(rowDimension, columnDimension);
        }

        @Override
        public RealMatrix copy() {
            final RealMatrix result = createMatrix(getRowDimension(), getColumnDimension());
            walkInOptimizedOrder(new RealMatrixPreservingVisitor() {

                @Override
                public void visit(int row, int column, double value) {
                    result.setEntry(row, column, value);
                }

                @Override
                public void start(int rows, int columns, int startRow, int endRow, int startColumn,
                        int endColumn) {
                }

                @Override
                public double end() {
                    return NaN;
                }
            });
            return result;
        }
    };
}

From source file:org.briljantframework.array.Matrices.java

/**
 * View the double array as a {@link RealMatrix}.
 *
 * @param array the array (must be 2d)/*from www .  j av a  2 s . c  om*/
 * @return a real matrix view
 */
public static RealMatrix asRealMatrix(DoubleArray array) {
    Check.argument(array.isMatrix(), CAN_ONLY_VIEW_2D_ARRAYS);
    return new AbstractRealMatrix() {
        @Override
        public int getRowDimension() {
            return array.rows();
        }

        @Override
        public int getColumnDimension() {
            return array.columns();
        }

        @Override
        public RealMatrix createMatrix(int rowDimension, int columnDimension)
                throws NotStrictlyPositiveException {
            return asRealMatrix(array.newEmptyArray(rowDimension, columnDimension));
        }

        @Override
        public RealMatrix copy() {
            return asRealMatrix(array.copy());
        }

        @Override
        public double getEntry(int row, int column) throws OutOfRangeException {
            return array.get(row, column);
        }

        @Override
        public void setEntry(int row, int column, double value) throws OutOfRangeException {
            array.set(row, column, value);
        }
    };
}