diff --git a/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs b/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs index a4629b1f..feffe82f 100644 --- a/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs @@ -81,6 +81,39 @@ return this.Clone(); } + /// + /// Adds another matrix to this matrix. + /// + /// The matrix to add to this matrix. + /// The result of the addition. + /// If the other matrix is . + /// If the two matrices don't have the same dimensions. + public override Matrix Add(Matrix other) + { + if (other == null) + { + throw new ArgumentNullException("other"); + } + + if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) + { + throw DimensionsDontMatch(this, other); + } + + Matrix result; + if (other is SymmetricMatrix) + { + result = CreateMatrix(RowCount, ColumnCount); + } + else + { + result = CreateMatrix(RowCount, ColumnCount, true); + } + + DoAdd(other, result); + return result; + } + /// /// Adds another matrix to this matrix. /// @@ -122,6 +155,40 @@ } } + /// + /// Subtracts another matrix from this matrix. + /// + /// The matrix to subtract. + /// The result of the subtraction. + /// If the other matrix is . + /// If the two matrices don't have the same dimensions. + public override Matrix Subtract(Matrix other) + { + if (other == null) + { + throw new ArgumentNullException("other"); + } + + if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) + { + throw DimensionsDontMatch(this, other); + } + + Matrix result; + if (other is SymmetricMatrix) + { + result = CreateMatrix(RowCount, ColumnCount); + } + else + { + result = CreateMatrix(RowCount, ColumnCount, true); + } + + DoSubtract(other, result); + return result; + } + + /// /// Subtracts another matrix from this matrix. /// @@ -246,6 +313,39 @@ } } + /// + /// Pointwise multiplies this matrix with another matrix. + /// + /// The matrix to pointwise multiply with this one. + /// If the other matrix is . + /// If this matrix and are not the same size. + /// A new matrix that is the pointwise multiplication of this matrix and . + public override Matrix PointwiseMultiply(Matrix other) + { + if (other == null) + { + throw new ArgumentNullException("other"); + } + + if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) + { + throw DimensionsDontMatch(this, other, "other"); + } + + Matrix result; + if (other is SymmetricMatrix) + { + result = CreateMatrix(RowCount, ColumnCount); + } + else + { + result = CreateMatrix(RowCount, ColumnCount, true); + } + + PointwiseMultiply(other, result); + return result; + } + /// /// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix. /// @@ -281,6 +381,39 @@ } } + /// + /// Pointwise divide this matrix by another matrix. + /// + /// The matrix to pointwise subtract this one by. + /// If the other matrix is . + /// If this matrix and are not the same size. + /// A new matrix that is the pointwise division of this matrix and . + public override Matrix PointwiseDivide(Matrix other) + { + if (other == null) + { + throw new ArgumentNullException("other"); + } + + if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) + { + throw DimensionsDontMatch(this, other); + } + + Matrix result; + if (other is SymmetricMatrix) + { + result = CreateMatrix(RowCount, ColumnCount); + } + else + { + result = CreateMatrix(RowCount, ColumnCount, true); + } + + PointwiseDivide(other, result); + return result; + } + /// /// Pointwise divide this matrix by another matrix and stores the result into the result matrix. ///