protected override void DoMultiply(Matrix<float> other, Matrix<float> result)
{
var denseOther = other as DenseMatrix;
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
denseOther._values,
denseOther._rowCount,
denseOther._columnCount,
denseResult._values);
return;
}
var diagonalOther = other.Storage as DiagonalMatrixStorage<float>;
if (diagonalOther != null)
{
var diagonal = diagonalOther.Data;
var d = Math.Min(ColumnCount, other.ColumnCount);
if (d < other.ColumnCount)
{
result.ClearSubMatrix(0, RowCount, ColumnCount, other.ColumnCount - ColumnCount);
}
int index = 0;
for (int j = 0; j < d; j++)
{
for (int i = 0; i < RowCount; i++)
{
result.At(i, j, _values[index]*diagonal[j]);
index++;
}
}
return;
}
base.DoMultiply(other, result);
}