Browse Source

[SymmetricDenseMatrix] Trace(): remove redundant check for square matrix since symm matrices are always square

Signed-off-by: Alexander Karatarakis <alex@karatarakis.com>
pull/59/head
Alexander Karatarakis 14 years ago
parent
commit
07f563d7e4
  1. 7
      src/Numerics/LinearAlgebra/Double/SymmetricDenseMatrix.cs
  2. 7
      src/Numerics/LinearAlgebra/Single/SymmetricDenseMatrix.cs

7
src/Numerics/LinearAlgebra/Double/SymmetricDenseMatrix.cs

@ -529,14 +529,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// Computes the trace of this matrix. /// Computes the trace of this matrix.
/// </summary> /// </summary>
/// <returns>The trace of this matrix</returns> /// <returns>The trace of this matrix</returns>
/// <exception cref="ArgumentException">If the matrix is not square</exception>
public override double Trace() public override double Trace()
{ {
if (RowCount != ColumnCount) // Matrix is always square.
{
throw new ArgumentException(Resources.ArgumentMatrixSquare);
}
var sum = 0.0; var sum = 0.0;
for (var i = 0; i < RowCount; i++) for (var i = 0; i < RowCount; i++)
{ {

7
src/Numerics/LinearAlgebra/Single/SymmetricDenseMatrix.cs

@ -529,14 +529,9 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// Computes the trace of this matrix. /// Computes the trace of this matrix.
/// </summary> /// </summary>
/// <returns>The trace of this matrix</returns> /// <returns>The trace of this matrix</returns>
/// <exception cref="ArgumentException">If the matrix is not square</exception>
public override float Trace() public override float Trace()
{ {
if (RowCount != ColumnCount) // Matrix is always square.
{
throw new ArgumentException(Resources.ArgumentMatrixSquare);
}
var sum = 0.0f; var sum = 0.0f;
for (var i = 0; i < RowCount; i++) for (var i = 0; i < RowCount; i++)
{ {

Loading…
Cancel
Save