public float[] solveFToF(float[] b) { RealVector bVec = new ArrayRealVector(b.length); for (int i = 0; i < b.length; i++) { bVec.setEntry(i, b[i]); } RealVector resultVec = solver.solve(bVec); float[] result = new float[resultVec.getDimension()]; for (int i = 0; i < result.length; i++) { result[i] = (float) resultVec.getEntry(i); } return result; }
/** {@inheritDoc} */ public RealMatrix getColumnMatrix(final int column) throws OutOfRangeException { MatrixUtils.checkColumnIndex(this, column); final int nRows = getRowDimension(); final RealMatrix out = createMatrix(nRows, 1); for (int i = 0; i < nRows; ++i) { out.setEntry(i, 0, getEntry(i, column)); } return out; }
/** {@inheritDoc} */ @Override public double getLInfDistance(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return getLInfDistance((OpenMapRealVector) v); } else { return super.getLInfDistance(v); } }
public double[] solveDToD(double[] b) { RealVector bVec = new ArrayRealVector(b, false); return solver.solve(bVec).toArray(); }
/** {@inheritDoc} */ public void setRowVector(final int row, final RealVector vector) throws OutOfRangeException, MatrixDimensionMismatchException { MatrixUtils.checkRowIndex(this, row); final int nCols = getColumnDimension(); if (vector.getDimension() != nCols) { throw new MatrixDimensionMismatchException(1, vector.getDimension(), 1, nCols); } for (int i = 0; i < nCols; ++i) { setEntry(row, i, vector.getEntry(i)); } }
@Override protected RealVector solve(final RealMatrix jacobian, final RealVector residuals) { return new SingularValueDecomposition(jacobian) .getSolver() .solve(residuals); } };
/** {@inheritDoc} */ @Override public RealVector preMultiply(final RealVector v) throws DimensionMismatchException { final double[] vectorData; if (v instanceof ArrayRealVector) { vectorData = ((ArrayRealVector) v).getDataRef(); } else { vectorData = v.toArray(); } return MatrixUtils.createRealVector(preMultiply(vectorData)); }
/** {@inheritDoc} */ public RealMatrix getRowMatrix(final int row) throws OutOfRangeException { MatrixUtils.checkRowIndex(this, row); final int nCols = getColumnDimension(); final RealMatrix out = createMatrix(1, nCols); for (int i = 0; i < nCols; ++i) { out.setEntry(0, i, getEntry(row, i)); } return out; }
/** {@inheritDoc} */ @Override public RealVector subtract(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return subtract((OpenMapRealVector) v); } else { return super.subtract(v); } }
/** {@inheritDoc} */ @Override public RealVector add(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return add((OpenMapRealVector) v); } else { return super.add(v); } }
/** {@inheritDoc} */ @Override public double getL1Distance(RealVector v) throws DimensionMismatchException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return getL1Distance((OpenMapRealVector) v); } else { return super.getL1Distance(v); } }
/** {@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); } }
/** {@inheritDoc} */ public void setRow(final int row, final double[] array) throws OutOfRangeException, MatrixDimensionMismatchException { MatrixUtils.checkRowIndex(this, row); final int nCols = getColumnDimension(); if (array.length != nCols) { throw new MatrixDimensionMismatchException(1, array.length, 1, nCols); } for (int i = 0; i < nCols; ++i) { setEntry(row, i, array[i]); } }
/** {@inheritDoc} */ public void setColumn(final int column, final double[] array) throws OutOfRangeException, MatrixDimensionMismatchException { MatrixUtils.checkColumnIndex(this, column); final int nRows = getRowDimension(); if (array.length != nRows) { throw new MatrixDimensionMismatchException(array.length, 1, nRows, 1); } for (int i = 0; i < nRows; ++i) { setEntry(i, column, array[i]); } }
/** {@inheritDoc} */ @Override public void setColumnVector(final int column, final RealVector vector) throws OutOfRangeException, MatrixDimensionMismatchException { try { setColumn(column, ((ArrayRealVector) vector).getDataRef()); } catch (ClassCastException cce) { super.setColumnVector(column, vector); } }
/** {@inheritDoc} */ public FieldMatrix<T> getColumnMatrix(final int column) throws OutOfRangeException { checkColumnIndex(column); final int nRows = getRowDimension(); final FieldMatrix<T> out = createMatrix(nRows, 1); for (int i = 0; i < nRows; ++i) { out.setEntry(i, 0, getEntry(i, column)); } return out; }
/** {@inheritDoc} */ public void multiplyEntry(int row, int column, double factor) throws OutOfRangeException { MatrixUtils.checkMatrixIndex(this, row, column); setEntry(row, column, getEntry(row, column) * factor); }
/** {@inheritDoc} */ @Override public void setRowVector(final int row, final FieldVector<T> vector) throws MatrixDimensionMismatchException, OutOfRangeException { try { setRow(row, ((ArrayFieldVector<T>) vector).getDataRef()); } catch (ClassCastException cce) { super.setRowVector(row, vector); } }
/** {@inheritDoc} */ @Override public void setColumnVector(final int column, final FieldVector<T> vector) throws OutOfRangeException, MatrixDimensionMismatchException { try { setColumn(column, ((ArrayFieldVector<T>) vector).getDataRef()); } catch (ClassCastException cce) { super.setColumnVector(column, vector); } }
/** {@inheritDoc} */ @Override public void multiplyEntry(final int row, final int column, final double factor) throws OutOfRangeException { MatrixUtils.checkMatrixIndex(this, row, column); final int iBlock = row / BLOCK_SIZE; final int jBlock = column / BLOCK_SIZE; final int k = (row - iBlock * BLOCK_SIZE) * blockWidth(jBlock) + (column - jBlock * BLOCK_SIZE); blocks[iBlock * blockColumns + jBlock][k] *= factor; }