List of usage examples for org.apache.commons.math3.linear AbstractFieldMatrix AbstractFieldMatrix
protected AbstractFieldMatrix()
From source file:org.briljantframework.array.Matrices.java
/** * View the array as a {@link FieldMatrix}. * * @param array the array/*www. j a va 2 s . com*/ * @param <T> the field * @return a field matrix view */ public static <T extends FieldElement<T>> FieldMatrix<T> asFieldMatrix(Array<T> array) { Check.argument(array.isMatrix(), CAN_ONLY_VIEW_2D_ARRAYS); return new AbstractFieldMatrix<T>() { @Override public FieldMatrix<T> createMatrix(int rowDimension, int columnDimension) throws NotStrictlyPositiveException { return asFieldMatrix(array.newEmptyArray(rowDimension, columnDimension)); } @Override public FieldMatrix<T> copy() { return asFieldMatrix(array.copy()); } @Override public T getEntry(int row, int column) throws OutOfRangeException { return array.get(row, column); } @Override public void setEntry(int row, int column, T value) throws OutOfRangeException { array.set(row, column, value); } @Override public void addToEntry(int row, int column, T increment) throws OutOfRangeException { array.set(row, column, array.get(row, column).add(increment)); } @Override public void multiplyEntry(int row, int column, T factor) throws OutOfRangeException { array.set(row, column, array.get(row, column).multiply(factor)); } @Override public int getRowDimension() { return array.rows(); } @Override public int getColumnDimension() { return array.columns(); } }; }