/** {@inheritDoc} */ public FieldVector<T> operate(final FieldVector<T> v) throws DimensionMismatchException { try { return new ArrayFieldVector<T>(field, operate(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nCols) { throw new DimensionMismatchException(v.getDimension(), nCols); } final T[] out = MathArrays.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>(field, out, false); } }
/** {@inheritDoc} */ public FieldVector<T> operate(final FieldVector<T> v) throws DimensionMismatchException { try { return new ArrayFieldVector<T>(field, operate(((ArrayFieldVector<T>) v).getDataRef()), false); } catch (ClassCastException cce) { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nCols) { throw new DimensionMismatchException(v.getDimension(), nCols); } final T[] out = MathArrays.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>(field, out, false); } }