/// <inheritdoc/>
        /// <exception cref="NumberIsTooLargeException"> if <c>m</c> is an
        /// <c>OpenMapRealMatrix</c>, and the total number of entries of the product
        /// is larger than <c>Int32.MaxValue</c>.</exception>
        public new RealMatrix multiply(RealMatrix m)
        {
            try
            {
                return(multiply((OpenMapRealMatrix)m));
            }
            catch (InvalidCastException)
            {
                MatrixUtils.checkMultiplicationCompatible(this, m);

                int             outCols = m.getColumnDimension();
                BlockRealMatrix outp    = new BlockRealMatrix(rows, outCols);
                for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.MoveNext();)
                {
                    double value = iterator.Current.Value;
                    int    key   = iterator.Current.Key;
                    int    i     = key / columns;
                    int    k     = key % columns;
                    for (int j = 0; j < outCols; ++j)
                    {
                        outp.addToEntry(i, j, value * m.getEntry(k, j));
                    }
                }
                return(outp);
            }
        }
Ejemplo n.º 2
0
        /**
         * {@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}.
         */
        public override RealMatrix multiply(RealMatrix m)
        {
            try {
                return(multiply((OpenMapRealMatrix)m));
            } catch (InvalidCastException cce) {
                //MatrixUtils.checkMultiplicationCompatible(this, m);

                int             outCols = m.getColumnDimension();
                BlockRealMatrix @out    = new BlockRealMatrix(rows, outCols);
                for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();)
                {
                    iterator.advance();
                    double value = iterator.value();
                    int    key   = iterator.key();
                    int    i     = key / columns;
                    int    k     = key % columns;
                    for (int j = 0; j < outCols; ++j)
                    {
                        @out.addToEntry(i, j, value * m.getEntry(k, j));
                    }
                }

                return(@out);
            }
        }