Browse Source

matrix: corrected CopyTo and StyleCop errors

la-knuth
Marcus Cuda 17 years ago
parent
commit
52e58d6abd
  1. 55
      src/Numerics/LinearAlgebra/Double/Matrix.cs
  2. 2
      src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs
  3. 1
      src/UnitTests/UnitTests.csproj

55
src/Numerics/LinearAlgebra/Double/Matrix.cs

@ -30,9 +30,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
using System; using System;
using System.Text; using System.Text;
using Threading;
using Properties; using Properties;
using Threading;
/// <summary> /// <summary>
/// Defines the base class for <c>Matrix</c> classes. /// Defines the base class for <c>Matrix</c> classes.
@ -195,23 +194,17 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount) if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{ {
throw new ArgumentException("target", Resources.ArgumentMatrixSameDimensions); throw new ArgumentException(Resources.ArgumentMatrixSameDimensions, "target");
} }
var denseMatrix = target as DenseMatrix; // TODO this assumes that all entries matter; if "this" is a sparse matrix,
if (denseMatrix != null) // we might be able to optimize the copying a bit.
for (int i = 0; i < RowCount; i++)
{ {
// TODO this assumes that all entries matter; if "this" is a sparse matrix, for (int j = 0; j < ColumnCount; j++)
// we might be able to optimize the copying a bit.
for (int i = 0; i < RowCount; i++)
{ {
for (int j = 0; j < ColumnCount; j++) target.At(i, j, At(i, j));
{
denseMatrix.At(i, j, this.At(i, j));
}
} }
return;
} }
} }
@ -240,7 +233,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// </returns> /// </returns>
public override string ToString() public override string ToString()
{ {
return this.ToString(null, null); return ToString(null, null);
} }
#region Implemented Interfaces #region Implemented Interfaces
@ -446,13 +439,16 @@ namespace MathNet.Numerics.LinearAlgebra.Double
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions);
} }
Parallel.For(0, RowCount, i => Parallel.For(
{ 0,
for (int j = 0; j < ColumnCount; j++) RowCount,
i =>
{ {
At(i, j, At(i, j) + other.At(i, j)); for (int j = 0; j < ColumnCount; j++)
} {
}); At(i, j, At(i, j) + other.At(i, j));
}
});
} }
/// <summary> /// <summary>
@ -472,6 +468,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
throw new ArgumentNullException("rightSide"); throw new ArgumentNullException("rightSide");
} }
if (leftSide == null) if (leftSide == null)
{ {
throw new ArgumentNullException("leftSide"); throw new ArgumentNullException("leftSide");
@ -505,13 +502,16 @@ namespace MathNet.Numerics.LinearAlgebra.Double
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions);
} }
Parallel.For(0, RowCount, i => Parallel.For(
{ 0,
for(int j = 0; j < ColumnCount; j++) RowCount,
i =>
{ {
At(i, j, At(i, j) - other.At(i, j)); for (int j = 0; j < ColumnCount; j++)
} {
}); At(i, j, At(i, j) - other.At(i, j));
}
});
} }
/// <summary> /// <summary>
@ -531,6 +531,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
throw new ArgumentNullException("rightSide"); throw new ArgumentNullException("rightSide");
} }
if (leftSide == null) if (leftSide == null)
{ {
throw new ArgumentNullException("leftSide"); throw new ArgumentNullException("leftSide");

2
src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs

@ -30,7 +30,7 @@
public override Matrix CreateMatrix(int rows, int columns) public override Matrix CreateMatrix(int rows, int columns)
{ {
throw new NotImplementedException(); return new UserDefinedMatrix(rows, columns);
} }
public override Vector CreateVector(int size) public override Vector CreateVector(int size)

1
src/UnitTests/UnitTests.csproj

@ -90,6 +90,7 @@
<Compile Include="InterpolationTests\InterpolationFunctionalContract.cs" /> <Compile Include="InterpolationTests\InterpolationFunctionalContract.cs" />
<Compile Include="InterpolationTests\InterpolationInfrastructureContract.cs" /> <Compile Include="InterpolationTests\InterpolationInfrastructureContract.cs" />
<Compile Include="InterpolationTests\InterpolationFunctionalTest.cs" /> <Compile Include="InterpolationTests\InterpolationFunctionalTest.cs" />
<Compile Include="LinearAlgebraTests\Double\UserDefinedMatrixTests.cs" />
<Compile Include="LinearAlgebraTests\Double\MatrixTests.cs" /> <Compile Include="LinearAlgebraTests\Double\MatrixTests.cs" />
<Compile Include="LinearAlgebraTests\Double\DenseMatrixTests.cs" /> <Compile Include="LinearAlgebraTests\Double\DenseMatrixTests.cs" />
<Compile Include="LinearAlgebraTests\Double\DenseVectorTest.TextHandling.cs" /> <Compile Include="LinearAlgebraTests\Double\DenseVectorTest.TextHandling.cs" />

Loading…
Cancel
Save