Browse Source

fixed silverlight errors

pull/36/head
Marcus Cuda 16 years ago
parent
commit
d796e452a3
  1. 3
      .gitignore
  2. 3
      src/Numerics/Control.cs
  3. 28
      src/Numerics/NumberTheory/IntegerTheory.Euclid.cs
  4. 1
      src/Numerics/SpecialFunctions.cs
  5. 7
      src/Silverlight/Silverlight.csproj
  6. 47
      src/Silverlight/SilverlightUtilities.cs

3
.gitignore

@ -9,4 +9,5 @@ _ReSharper*
*.bak
bin
*.vsdoc
*.XML
*.XML
Version1.cs

3
src/Numerics/Control.cs

@ -32,8 +32,9 @@ namespace MathNet.Numerics
{
using System;
using Algorithms.LinearAlgebra;
using Threading;
/// <summary>
/// <summary>
/// Sets parameters for the library.
/// </summary>
public static class Control

28
src/Numerics/NumberTheory/IntegerTheory.Euclid.cs

@ -3,9 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@ -14,10 +12,8 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -48,7 +44,7 @@ namespace MathNet.Numerics.NumberTheory
{
while (b != 0)
{
long remainder = a % b;
var remainder = a % b;
a = b;
b = remainder;
}
@ -76,7 +72,7 @@ namespace MathNet.Numerics.NumberTheory
var gcd = Math.Abs(integers[0]);
for (int i = 1; (i < integers.Count) && (gcd > 1); i++)
for (var i = 1; (i < integers.Count) && (gcd > 1); i++)
{
gcd = GreatestCommonDivisor(gcd, integers[i]);
}
@ -111,21 +107,25 @@ namespace MathNet.Numerics.NumberTheory
/// The <c>gcd</c> of 45 and 18 is 9: 18 = 2*9, 45 = 5*9. 9 = 1*45 -2*18, therefore x=1 and y=-2.
/// </example>
public static long ExtendedGreatestCommonDivisor(
long a,
long b,
out long x,
long a,
long b,
out long x,
out long y)
{
long mp = 1, np = 0, m = 0, n = 1;
while (b != 0)
{
long rem;
long quot = Math.DivRem(a, b, out rem);
long rem;
#if SILVERLIGHT
var quot = SilverlightUtilities.DivRem(a, b, out rem);
#else
long quot = Math.DivRem(a, b, out rem);
#endif
a = b;
b = rem;
long tmp = m;
var tmp = m;
m = mp - (quot * m);
mp = tmp;
@ -181,7 +181,7 @@ namespace MathNet.Numerics.NumberTheory
var lcm = Math.Abs(integers[0]);
for (int i = 1; i < integers.Count; i++)
for (var i = 1; i < integers.Count; i++)
{
lcm = LeastCommonMultiple(lcm, integers[i]);
}
@ -199,4 +199,4 @@ namespace MathNet.Numerics.NumberTheory
return LeastCommonMultiple((IList<long>)integers);
}
}
}
}

1
src/Numerics/SpecialFunctions.cs

@ -26,6 +26,7 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
// <contribution>
// Cephes Math Library, Stephen L. Moshier

7
src/Silverlight/Silverlight.csproj

@ -314,7 +314,14 @@
<Compile Include="..\Numerics\Trigonometry.cs">
<Link>Trigonometry.cs</Link>
</Compile>
<Compile Include="..\Numerics\Version1.cs">
<Link>Version1.cs</Link>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Version.tt</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SilverlightUtilities.cs" />
<Compile Include="Threading\AggregateException.cs" />
<Compile Include="Threading\Parallel.cs" />
<Compile Include="Threading\Task.cs" />

47
src/Silverlight/SilverlightUtilities.cs

@ -0,0 +1,47 @@
// <copyright file="SilverlightUtilities.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics
{
/// <summary>
/// Contains methods missing from Silverlight.
/// </summary>
public static class SilverlightUtilities
{
/// <summary>
/// Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output parameter.
/// </summary>
/// <param name="a">The dividend.</param>
/// <param name="b">The divisor.</param>
/// <param name="result">The remainder.</param>
/// <returns>The quotient of the specified numbers.</returns>
public static long DivRem(long a, long b, out long result)
{
result = a % b;
return a / b;
}
}
}
Loading…
Cancel
Save