Logo Search packages:      
Sourcecode: jblas version File versions  Download package

FloatMatrix org::jblas::la::FloatMatrix::mmuli ( FloatMatrix  other,
FloatMatrix  result 
) [inline]

Matrix-matrix multiplication (in-place).

Definition at line 1420 of file FloatMatrix.java.

References assertMultipliesWith(), columns, FloatMatrix(), isScalar(), muli(), resize(), rows, and scalar().

Referenced by mmul(), and mmuli().

                                                                    {
        if (other.isScalar()) {
            return muli(other.scalar(), result);
        }
        if (isScalar()) {
            return other.muli(scalar(), result);
        }

        /* check sizes and resize if necessary */
        assertMultipliesWith(other);
        if (result.rows != rows || result.columns != other.columns) {
            if (result != this && result != other) {
                result.resize(rows, other.columns);
            } else {
                throw new SizeException("Cannot resize result matrix because it is used in-place.");
            }
        }

        if (result == this || result == other) {
            /* actually, blas cannot do multiplications in-place. Therefore, we will fake by
             * allocating a temporary object on the side and copy the result later.
             */
            FloatMatrix temp = new FloatMatrix(result.rows, result.columns);
            if (other.columns == 1) {
                SimpleBlas.gemv(1.0f, this, other, 0.0f, temp);
            } else {
                SimpleBlas.gemm(1.0f, this, other, 0.0f, temp);
            }
            SimpleBlas.copy(temp, result);
        } else {
            if (other.columns == 1) {
                SimpleBlas.gemv(1.0f, this, other, 0.0f, result);
            } else {
                SimpleBlas.gemm(1.0f, this, other, 0.0f, result);
            }
        }
        return result;
    }


Generated by  Doxygen 1.6.0   Back to index