/// <summary> /// Multiplies this matrix with another matrix and returns the result. /// </summary> /// <param name="other">The matrix to multiply with.</param> /// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception> /// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception> /// <returns>The result of multiplication.</returns> public override Matrix <double> Multiply(Matrix <double> other) { if (other == null) { throw new ArgumentNullException("other"); } if (ColumnCount != other.RowCount) { throw DimensionsDontMatch <ArgumentException>(this, other); } var result = other.CreateMatrix(RowCount, other.ColumnCount); Multiply(other, result); return(result); }
/// <summary> /// Multiplies this matrix with transpose of another matrix and returns the result. /// </summary> /// <param name="other">The matrix to multiply with.</param> /// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception> /// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception> /// <returns>The result of multiplication.</returns> public override Matrix <double> TransposeAndMultiply(Matrix <double> other) { var otherDiagonal = other as DiagonalMatrix; if (otherDiagonal == null) { return(base.TransposeAndMultiply(other)); } if (ColumnCount != otherDiagonal.ColumnCount) { throw DimensionsDontMatch <ArgumentException>(this, otherDiagonal); } var result = other.CreateMatrix(RowCount, other.RowCount); TransposeAndMultiply(other, result); return(result); }