Browse Source

matrix: corrected CopyTo and StyleCop errors

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

27
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,24 +194,18 @@ 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;
if (denseMatrix != null)
{
// TODO this assumes that all entries matter; if "this" is a sparse matrix, // TODO this assumes that all entries matter; if "this" is a sparse matrix,
// we might be able to optimize the copying a bit. // we might be able to optimize the copying a bit.
for (int i = 0; i < RowCount; i++) for (int i = 0; i < RowCount; i++)
{ {
for (int j = 0; j < ColumnCount; j++) for (int j = 0; j < ColumnCount; j++)
{ {
denseMatrix.At(i, j, this.At(i, j)); target.At(i, j, At(i, j));
} }
} }
return;
}
} }
/// <summary> /// <summary>
@ -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,7 +439,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions);
} }
Parallel.For(0, RowCount, i => Parallel.For(
0,
RowCount,
i =>
{ {
for (int j = 0; j < ColumnCount; j++) for (int j = 0; j < ColumnCount; j++)
{ {
@ -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,7 +502,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions);
} }
Parallel.For(0, RowCount, i => Parallel.For(
0,
RowCount,
i =>
{ {
for (int j = 0; j < ColumnCount; j++) for (int j = 0; j < ColumnCount; j++)
{ {
@ -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