/** {@inheritDoc} */ @Override public void setRowVector(final int row, final RealVector vector) throws OutOfRangeException, MatrixDimensionMismatchException { try { setRow(row, ((ArrayRealVector) vector).getDataRef()); } catch (ClassCastException cce) { super.setRowVector(row, vector); } }
public class Literal<T> { private final T literal; private Literal(T literal) { this.literal = literal; } public T get(){ return literal; } public static Literal<Complex> createComplexLiteral(Complex complex){ return new Literal<>(complex); } public static Literal<BlockRealMatrix> createBlockRealMatrixLiteral(BlockRealMatrix complex){ int m = realMatrix.getData().length; int n = realMatrix.getData()[0].length; BlockRealMatrix mat = new BlockRealMatrix(m, n); for (int i = 0; i < m; i++)mat.setRow(i, realMatrix.getRow(i)); return new Literal<>(mat); } // all the other create methods }
/** {@inheritDoc} */ @Override public void setRowVector(final int row, final RealVector vector) throws OutOfRangeException, MatrixDimensionMismatchException { if (vector instanceof ArrayRealVector) { setRow(row, ((ArrayRealVector) vector).getDataRef()); } else { super.setRowVector(row, vector); } }
/** {@inheritDoc} */ @Override public void setRowVector(final int row, final RealVector vector) throws OutOfRangeException, MatrixDimensionMismatchException { try { setRow(row, ((ArrayRealVector) vector).getDataRef()); } catch (ClassCastException cce) { super.setRowVector(row, vector); } }
public BlockRealMatrix computeScoreMatrix() { // First compute the scores of all possible matches between the source and targets int numPairs = getRowCount() * getColumnCount(); int numDimensions = getDimensionCount(); BlockRealMatrix matrix = new BlockRealMatrix(numPairs, numDimensions); int rowIndex = 0; for(int i = 0; i < getRowCount(); ++ i) { for(int j = 0; j < getColumnCount(); ++j) { matrix.setRow(rowIndex++, score(i, j)); } } return matrix; }