|
From: <pva...@us...> - 2006-08-30 15:04:58
|
Revision: 443
http://svn.sourceforge.net/dnanalytics/?rev=443&view=rev
Author: pvandervelde
Date: 2006-08-30 08:04:37 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
- Fixed bug number: #1549178. SparseVector.Maximum does not work.
- Also fixed bugs in SparseVector.Minimum, AbsoluteMaximum and AbsoluteMinimum.
Modified Paths:
--------------
numerical/trunk/LinearAlgebra/SparseVector.cs
numerical/trunk/NumericalLibrary.csproj
numerical/trunk/UnitTests/LinearAlgebra/SparseVectorTest.cs
numerical/trunk/UnitTests/UnitTests.csproj
Modified: numerical/trunk/LinearAlgebra/SparseVector.cs
===================================================================
--- numerical/trunk/LinearAlgebra/SparseVector.cs 2006-08-21 16:09:46 UTC (rev 442)
+++ numerical/trunk/LinearAlgebra/SparseVector.cs 2006-08-30 15:04:37 UTC (rev 443)
@@ -68,8 +68,7 @@
/// </summary>
/// <param name="source">The <see cref="Vector" /> from which the values for the current instance will be copied.</param>
/// <exception cref="ArgumentNullException">If source is <b>null</b>.</exception>
- public SparseVector(Vector source)
- : base(source.Count)
+ public SparseVector(Vector source) : base(source.Count)
{
for (int i = 0; i < source.Count; i++)
{
@@ -427,7 +426,7 @@
{
int index = -1;
double max = 0.0;
- for (int i = 1; i < mValueCount; i++)
+ for (int i = 0; i < mValueCount; i++)
{
double test = System.Math.Abs(mValues[i]);
if (test > max)
@@ -491,7 +490,7 @@
// non-zero smallest value. Find it.
int index = -1;
double max = double.PositiveInfinity;
- for (int i = 1; i < mValueCount; i++)
+ for (int i = 0; i < mValueCount; i++)
{
double test = System.Math.Abs(mValues[i]);
if (test < max)
@@ -533,7 +532,7 @@
{
int index = -1;
double max = double.NegativeInfinity;
- for (int i = 1; i < mValueCount; i++)
+ for (int i = 0; i < mValueCount; i++)
{
double test = mValues[i];
if (test > max)
@@ -569,7 +568,7 @@
{
int index = -1;
double max = double.PositiveInfinity;
- for (int i = 1; i < mValueCount; i++)
+ for (int i = 0; i < mValueCount; i++)
{
double test = mValues[i];
if (test < max)
Modified: numerical/trunk/NumericalLibrary.csproj
===================================================================
--- numerical/trunk/NumericalLibrary.csproj 2006-08-21 16:09:46 UTC (rev 442)
+++ numerical/trunk/NumericalLibrary.csproj 2006-08-30 15:04:37 UTC (rev 443)
@@ -35,7 +35,7 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.2.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
Modified: numerical/trunk/UnitTests/LinearAlgebra/SparseVectorTest.cs
===================================================================
--- numerical/trunk/UnitTests/LinearAlgebra/SparseVectorTest.cs 2006-08-21 16:09:46 UTC (rev 442)
+++ numerical/trunk/UnitTests/LinearAlgebra/SparseVectorTest.cs 2006-08-30 15:04:37 UTC (rev 443)
@@ -24,6 +24,34 @@
{
return MatrixBuilder.CreateMatrix(rows, columns, MatrixType.Dense);
}
+
+ // NOTE: both tests are bug-fix tests.
+ // Bug-behavior: The sparse vector would not find the maximum value if the first entry in the sparse array was the maximum
+ // Cause: An index error (starting at the second entry in the sparse array).
+
+ [Test]
+ public void MaximumWithMaximumOnFirstEntry()
+ {
+ Vector vector = GetVector(2000);
+ vector[1845] = 38;
+ vector[1857] = 25;
+ vector[1957] = 25;
+
+ Assert.AreEqual(1845, vector.MaximumIndex());
+ Assert.AreEqual(38, vector.Maximum());
+ }
+
+ [Test]
+ public void MinimumWithMinimumOnFirstEntry()
+ {
+ Vector vector = GetVector(2000);
+ vector[1845] = 15;
+ vector[1857] = 25;
+ vector[1957] = 25;
+
+ Assert.AreEqual(1845, vector.MinimumIndex());
+ Assert.AreEqual(15, vector.Minimum());
+ }
}
[TestFixture]
Modified: numerical/trunk/UnitTests/UnitTests.csproj
===================================================================
--- numerical/trunk/UnitTests/UnitTests.csproj 2006-08-21 16:09:46 UTC (rev 442)
+++ numerical/trunk/UnitTests/UnitTests.csproj 2006-08-30 15:04:37 UTC (rev 443)
@@ -30,7 +30,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.2.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|