/** {@inheritDoc} */ @Override public RealVector operate(final RealVector v) throws DimensionMismatchException { try { return new ArrayRealVector(operate(((ArrayRealVector) 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 double[] out = new double[nRows]; for (int row = 0; row < nRows; ++row) { double sum = 0; for (int i = 0; i < nCols; ++i) { sum += getEntry(row, i) * v.getEntry(i); } out[row] = sum; } return new ArrayRealVector(out, false); } }
/** {@inheritDoc} */ @Override public RealVector operate(final RealVector v) throws DimensionMismatchException { if (v instanceof ArrayRealVector) { return new ArrayRealVector(operate(((ArrayRealVector) v).getDataRef()), false); } else { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (v.getDimension() != nCols) { throw new DimensionMismatchException(v.getDimension(), nCols); } final double[] out = new double[nRows]; for (int row = 0; row < nRows; ++row) { double sum = 0; for (int i = 0; i < nCols; ++i) { sum += getEntry(row, i) * v.getEntry(i); } out[row] = sum; } return new ArrayRealVector(out, false); } }
/** {@inheritDoc} */ @Override public RealVector operate(final RealVector v) throws DimensionMismatchException { try { return new ArrayRealVector(operate(((ArrayRealVector) 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 double[] out = new double[nRows]; for (int row = 0; row < nRows; ++row) { double sum = 0; for (int i = 0; i < nCols; ++i) { sum += getEntry(row, i) * v.getEntry(i); } out[row] = sum; } return new ArrayRealVector(out, false); } }