/** {@inheritDoc} */ @Override public void setRowVector(final int row, final FieldVector<T> vector) throws MatrixIndexException, InvalidMatrixException { try { setRow(row, ((ArrayFieldVector<T>) vector).getDataRef()); } catch (ClassCastException cce) { super.setRowVector(row, vector); } }
/** Solve the linear equation A × X = B. * <p>The A matrix is implicit here. It is </p> * @param b right-hand side of the equation A × X = B * @return a vector X such that A × X = B * @exception IllegalArgumentException if matrices dimensions don't match * @exception InvalidMatrixException if decomposed matrix is singular */ public ArrayFieldVector<T> solve(ArrayFieldVector<T> b) throws IllegalArgumentException, InvalidMatrixException { return new ArrayFieldVector<T>(solve(b.getDataRef()), false); }
/** Solve the linear equation A × X = B. * <p>The A matrix is implicit here. It is </p> * @param b right-hand side of the equation A × X = B * @return a vector X such that A × X = B * @exception IllegalArgumentException if matrices dimensions don't match * @exception InvalidMatrixException if decomposed matrix is singular */ public ArrayFieldVector<T> solve(ArrayFieldVector<T> b) throws IllegalArgumentException, InvalidMatrixException { return new ArrayFieldVector<T>(solve(b.getDataRef()), false); }
/** {@inheritDoc} */ @Override public void setRowVector(final int row, final FieldVector<T> vector) throws MatrixIndexException, InvalidMatrixException { 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 MatrixIndexException, InvalidMatrixException { try { setColumn(column, ((ArrayFieldVector<T>) vector).getDataRef()); } catch (ClassCastException cce) { super.setColumnVector(column, vector); } }
/** {@inheritDoc} */ @Override public void setColumnVector(final int column, final FieldVector<T> vector) throws MatrixIndexException, InvalidMatrixException { try { setColumn(column, ((ArrayFieldVector<T>) vector).getDataRef()); } catch (ClassCastException cce) { super.setColumnVector(column, vector); } }
/** {@inheritDoc} */ public FieldVector<T> operate(final FieldVector<T> v) throws IllegalArgumentException { try { return new ArrayFieldVector<T>(operate(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nCols) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.getDimension(), nCols); } final T[] out = buildArray(field, nRows); for (int row = 0; row < nRows; ++row) { T sum = field.getZero(); for (int i = 0; i < nCols; ++i) { sum = sum.add(getEntry(row, i).multiply(v.getEntry(i))); } out[row] = sum; } return new ArrayFieldVector<T>(out, false); } }
/** {@inheritDoc} */ public FieldVector<T> preMultiply(final FieldVector<T> v) throws IllegalArgumentException { try { return new ArrayFieldVector<T>(preMultiply(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nRows) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.VECTOR_LENGTH_MISMATCH, v.getDimension(), nRows); } final T[] out = buildArray(field, nCols); for (int col = 0; col < nCols; ++col) { T sum = field.getZero(); for (int i = 0; i < nRows; ++i) { sum = sum.add(getEntry(i, col).multiply(v.getEntry(i))); } out[col] = sum; } return new ArrayFieldVector<T>(out); } }
/** {@inheritDoc} */ public FieldVector<T> preMultiply(final FieldVector<T> v) throws IllegalArgumentException { try { return new ArrayFieldVector<T>(preMultiply(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nRows) { throw MathRuntimeException.createIllegalArgumentException( "vector length mismatch: got {0} but expected {1}", v.getDimension(), nRows); } final T[] out = buildArray(field, nCols); for (int col = 0; col < nCols; ++col) { T sum = field.getZero(); for (int i = 0; i < nRows; ++i) { sum = sum.add(getEntry(i, col).multiply(v.getEntry(i))); } out[col] = sum; } return new ArrayFieldVector<T>(out); } }
/** {@inheritDoc} */ public FieldVector<T> operate(final FieldVector<T> v) throws IllegalArgumentException { try { return new ArrayFieldVector<T>(operate(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nCols) { throw MathRuntimeException.createIllegalArgumentException( "vector length mismatch: got {0} but expected {1}", v.getDimension(), nCols); } final T[] out = buildArray(field, nRows); for (int row = 0; row < nRows; ++row) { T sum = field.getZero(); for (int i = 0; i < nCols; ++i) { sum = sum.add(getEntry(row, i).multiply(v.getEntry(i))); } out[row] = sum; } return new ArrayFieldVector<T>(out, false); } }