/** * {@inheritDoc} * * @throws NumberIsTooLargeException if {@code m} is an * {@code OpenMapRealMatrix}, and the total number of entries of the product * is larger than {@code Integer.MAX_VALUE}. */ @Override public RealMatrix multiply(final RealMatrix m) throws DimensionMismatchException, NumberIsTooLargeException { try { return multiply((OpenMapRealMatrix) m); } catch (ClassCastException cce) { MatrixUtils.checkMultiplicationCompatible(this, m); final int outCols = m.getColumnDimension(); final BlockRealMatrix out = new BlockRealMatrix(rows, outCols); for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) { iterator.advance(); final double value = iterator.value(); final int key = iterator.key(); final int i = key / columns; final int k = key % columns; for (int j = 0; j < outCols; ++j) { out.addToEntry(i, j, value * m.getEntry(k, j)); } } return out; } }
/** * {@inheritDoc} * * @throws NumberIsTooLargeException if {@code m} is an * {@code OpenMapRealMatrix}, and the total number of entries of the product * is larger than {@code Integer.MAX_VALUE}. */ @Override public RealMatrix multiply(final RealMatrix m) throws DimensionMismatchException, NumberIsTooLargeException { if (m instanceof OpenMapRealMatrix) { return multiply((OpenMapRealMatrix) m); } else { MatrixUtils.checkMultiplicationCompatible(this, m); final int outCols = m.getColumnDimension(); final BlockRealMatrix out = new BlockRealMatrix(rows, outCols); for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) { iterator.advance(); final double value = iterator.value(); final int key = iterator.key(); final int i = key / columns; final int k = key % columns; for (int j = 0; j < outCols; ++j) { out.addToEntry(i, j, value * m.getEntry(k, j)); } } return out; } }
/** * {@inheritDoc} * * @throws NumberIsTooLargeException if {@code m} is an * {@code OpenMapRealMatrix}, and the total number of entries of the product * is larger than {@code Integer.MAX_VALUE}. */ @Override public RealMatrix multiply(final RealMatrix m) throws DimensionMismatchException, NumberIsTooLargeException { try { return multiply((OpenMapRealMatrix) m); } catch (ClassCastException cce) { MatrixUtils.checkMultiplicationCompatible(this, m); final int outCols = m.getColumnDimension(); final BlockRealMatrix out = new BlockRealMatrix(rows, outCols); for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) { iterator.advance(); final double value = iterator.value(); final int key = iterator.key(); final int i = key / columns; final int k = key % columns; for (int j = 0; j < outCols; ++j) { out.addToEntry(i, j, value * m.getEntry(k, j)); } } return out; } }