Browse Source

Solution: Replace Silverlight with Portable library

Instead of a specific Silverlight version, we now provide a separate
Portable Library assebly that supports .Net 4.0.1 and higher,
Silverlight 5 ad well as .Net for Metro style apps (WinRT).

New NuGet Package MathNet.Numerics.Portable with the portable library.
Since MathNet.Numerics.Portable now supports silverlight, the normal
package MathNet.Numerics no longer supports it (.Net 4 only).

Reworked the common parallel execution infrastructure for more reasonable
abstractions and better compatibility with portable libraries. Portable
libraries do support parts of the TPL, but neither the Parallel class nor
straight threading.
la-knuth
Christoph Ruegg 15 years ago
parent
commit
386fb36bfc
  1. 12
      MathNet.Numerics.Portable.sln
  2. 17
      build/NuGet/Numerics.Portable/MathNet.Numerics.Portable.nuspec
  3. 21
      build/NuGet/nuget.proj
  4. 22
      src/Numerics/Complex32.cs
  5. 1700
      src/Numerics/Complex64.cs
  6. 2
      src/Numerics/ComplexExtensions.cs
  7. 32
      src/Numerics/Control.cs
  8. 2
      src/Numerics/GlobalizationHelper.cs
  9. 6
      src/Numerics/LinearAlgebra/Complex/DenseVector.cs
  10. 2
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  11. 4
      src/Numerics/LinearAlgebra/Complex/Solvers/IIterator.cs
  12. 8
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
  13. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs
  14. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/DivergenceStopCriterium.cs
  15. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/FailureStopCriterium.cs
  16. 4
      src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/IIterationStopCriterium.cs
  17. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/IterationCountStopCriterium.cs
  18. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/ResidualStopCriterium.cs
  19. 2
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  20. 4
      src/Numerics/LinearAlgebra/Complex/SparseVector.cs
  21. 6
      src/Numerics/LinearAlgebra/Complex/Vector.cs
  22. 6
      src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
  23. 2
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  24. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/IIterator.cs
  25. 8
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
  26. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs
  27. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/DivergenceStopCriterium.cs
  28. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/FailureStopCriterium.cs
  29. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/IIterationStopCriterium.cs
  30. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/IterationCountStopCriterium.cs
  31. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/ResidualStopCriterium.cs
  32. 2
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  33. 4
      src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
  34. 6
      src/Numerics/LinearAlgebra/Complex32/Vector.cs
  35. 6
      src/Numerics/LinearAlgebra/Double/DenseVector.cs
  36. 2
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  37. 4
      src/Numerics/LinearAlgebra/Double/Solvers/IIterator.cs
  38. 9
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
  39. 4
      src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs
  40. 2
      src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/DivergenceStopCriterium.cs
  41. 2
      src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/FailureStopCriterium.cs
  42. 4
      src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/IIterationStopCriterium.cs
  43. 2
      src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/IterationCountStopCriterium.cs
  44. 2
      src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/ResidualStopCriterium.cs
  45. 2
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  46. 4
      src/Numerics/LinearAlgebra/Double/SparseVector.cs
  47. 6
      src/Numerics/LinearAlgebra/Double/Vector.cs
  48. 6
      src/Numerics/LinearAlgebra/Generic/Matrix.cs
  49. 6
      src/Numerics/LinearAlgebra/Generic/Vector.cs
  50. 6
      src/Numerics/LinearAlgebra/Single/DenseVector.cs
  51. 2
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  52. 4
      src/Numerics/LinearAlgebra/Single/Solvers/IIterator.cs
  53. 8
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
  54. 4
      src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs
  55. 2
      src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/DivergenceStopCriterium.cs
  56. 2
      src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/FailureStopCriterium.cs
  57. 4
      src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/IIterationStopCriterium.cs
  58. 2
      src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/IterationCountStopCriterium.cs
  59. 2
      src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/ResidualStopCriterium.cs
  60. 2
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
  61. 4
      src/Numerics/LinearAlgebra/Single/SparseVector.cs
  62. 6
      src/Numerics/LinearAlgebra/Single/Vector.cs
  63. 222
      src/Numerics/NumberTheory/IntegerTheory.Euclid.Big.cs
  64. 5
      src/Numerics/NumberTheory/IntegerTheory.Euclid.cs
  65. 6
      src/Numerics/Numerics.csproj
  66. 2
      src/Numerics/Permutation.cs
  67. 36
      src/Numerics/Precision.cs
  68. 2
      src/Numerics/Properties/Resources1.Designer.cs
  69. 6
      src/Numerics/Random/SystemCrypto.cs
  70. 11
      src/Numerics/SerializableAttribute.cs
  71. 2
      src/Numerics/Sorting.cs
  72. 2
      src/Numerics/Statistics/Histogram.cs
  73. 626
      src/Numerics/Threading/CommonParallel.cs
  74. 1028
      src/Portable/Portable.csproj
  75. 51
      src/Portable/Properties/AssemblyInfo.cs
  76. 2
      src/Silverlight/Properties/AssemblyInfo.cs
  77. 9
      src/Silverlight/SerializableAttribute.cs
  78. 15
      src/Silverlight/Silverlight.csproj
  79. 65
      src/Silverlight/Threading/AggregateException.cs
  80. 485
      src/Silverlight/Threading/Parallel.cs
  81. 128
      src/Silverlight/Threading/Task.cs
  82. 79
      src/Silverlight/Threading/TaskOfT.cs
  83. 258
      src/Silverlight/Threading/ThreadQueue.cs
  84. 4
      src/UnitTests/ArrayHelpers.cs
  85. 4
      src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs
  86. 2
      src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs
  87. 2
      src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs
  88. 2
      src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs
  89. 2
      src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs
  90. 2
      src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs
  91. 2
      src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs
  92. 2
      src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs
  93. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
  94. 2
      src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs
  95. 2
      src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs
  96. 2
      src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs
  97. 2
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
  98. 2
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
  99. 2
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs
  100. 2
      src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs

12
MathNet.Numerics.Portable.sln

@ -1,8 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silverlight", "src\Silverlight\Silverlight.csproj", "{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Readme", "Readme", "{C2F37492-38AE-4186-8A7F-17B0B080942C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Readme", "Readme", "{C2F37492-38AE-4186-8A7F-17B0B080942C}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
AUTHORS.markdown = AUTHORS.markdown AUTHORS.markdown = AUTHORS.markdown
@ -10,16 +8,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Readme", "Readme", "{C2F374
README.markdown = README.markdown README.markdown = README.markdown
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portable", "src\Portable\Portable.csproj", "{D877F358-A2D2-4CC3-A921-8AA5CF6187E8}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D877F358-A2D2-4CC3-A921-8AA5CF6187E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Debug|Any CPU.Build.0 = Debug|Any CPU {D877F358-A2D2-4CC3-A921-8AA5CF6187E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Release|Any CPU.ActiveCfg = Release|Any CPU {D877F358-A2D2-4CC3-A921-8AA5CF6187E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Release|Any CPU.Build.0 = Release|Any CPU {D877F358-A2D2-4CC3-A921-8AA5CF6187E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

17
build/NuGet/Numerics.Portable/MathNet.Numerics.Portable.nuspec

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>MathNet.Numerics.Portable</id>
<version>1.0.0</version>
<title>Math.NET Numerics Portable Edition</title>
<summary>Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use. Supports .Net 4.0.3, SL5, WinRT.</summary>
<description>Math.NET Numerics is the numerical foundation of the Math.NET project, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use. Numerics is the result of merging dnAnalytics with Math.NET Iridium and is intended to replace both. Portable edition, supports .Net 4.0.3, SL5, WinRT.</description>
<authors>Marcus Cuda, Christoph Ruegg, Jurgen Van Gael</authors>
<owners>Christoph Ruegg</owners>
<projectUrl>http://numerics.mathdotnet.com/</projectUrl>
<iconUrl>http://www.mathdotnet.com/images/MathNet128.png</iconUrl>
<licenseUrl>http://mathnetnumerics.codeplex.com/license</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>math numeric portable SL WinRT statistics probability integration interpolation linear algebra matrix fft</tags>
</metadata>
</package>

21
build/NuGet/nuget.proj

@ -9,6 +9,7 @@
<OutLib>$(MSBuildProjectDirectory)/../../out/lib</OutLib> <OutLib>$(MSBuildProjectDirectory)/../../out/lib</OutLib>
<OutNuGetPackages>$(MSBuildProjectDirectory)/../../out/packages/NuGet</OutNuGetPackages> <OutNuGetPackages>$(MSBuildProjectDirectory)/../../out/packages/NuGet</OutNuGetPackages>
<NumericsPack>$(MSBuildProjectDirectory)/Numerics</NumericsPack> <NumericsPack>$(MSBuildProjectDirectory)/Numerics</NumericsPack>
<PortablePack>$(MSBuildProjectDirectory)/Numerics.Portable</PortablePack>
<FSharpPack>$(MSBuildProjectDirectory)/FSharp</FSharpPack> <FSharpPack>$(MSBuildProjectDirectory)/FSharp</FSharpPack>
<NumericsSamplePack>$(MSBuildProjectDirectory)/Numerics.Sample</NumericsSamplePack> <NumericsSamplePack>$(MSBuildProjectDirectory)/Numerics.Sample</NumericsSamplePack>
<FSharpSamplePack>$(MSBuildProjectDirectory)/FSharp.Sample</FSharpSamplePack> <FSharpSamplePack>$(MSBuildProjectDirectory)/FSharp.Sample</FSharpSamplePack>
@ -17,7 +18,7 @@
<ItemGroup> <ItemGroup>
<NumericsNet40 Include="$(OutLib)/Net40/MathNet.Numerics.dll;$(OutLib)/Net40/MathNet.Numerics.IO.dll;$(OutLib)/Net40/MathNet.Numerics.pdb;$(OutLib)/Net40/MathNet.Numerics.IO.pdb;$(OutLib)/Net40/MathNet.Numerics.xml;$(OutLib)/Net40/MathNet.Numerics.IO.xml" /> <NumericsNet40 Include="$(OutLib)/Net40/MathNet.Numerics.dll;$(OutLib)/Net40/MathNet.Numerics.IO.dll;$(OutLib)/Net40/MathNet.Numerics.pdb;$(OutLib)/Net40/MathNet.Numerics.IO.pdb;$(OutLib)/Net40/MathNet.Numerics.xml;$(OutLib)/Net40/MathNet.Numerics.IO.xml" />
<NumericsSL4 Include="$(OutLib)/SL4/MathNet.Numerics.dll;$(OutLib)/SL4/MathNet.Numerics.pdb;$(OutLib)/SL4/MathNet.Numerics.xml;" /> <NumericsPortable Include="$(OutLib)/Portable/MathNet.Numerics.dll;$(OutLib)/Portable/MathNet.Numerics.pdb;$(OutLib)/Portable/MathNet.Numerics.xml;" />
<FSharpNet40 Include="$(OutLib)/Net40/MathNet.Numerics.FSharp.dll;$(OutLib)/Net40/MathNet.Numerics.FSharp.pdb;$(OutLib)/Net40/MathNet.Numerics.FSharp.xml" /> <FSharpNet40 Include="$(OutLib)/Net40/MathNet.Numerics.FSharp.dll;$(OutLib)/Net40/MathNet.Numerics.FSharp.pdb;$(OutLib)/Net40/MathNet.Numerics.FSharp.xml" />
<NumericsSample Include="$(Examples)/**/*.cs" Exclude="$(Examples)/**/bin/**;$(Examples)/**/obj/**" /> <NumericsSample Include="$(Examples)/**/*.cs" Exclude="$(Examples)/**/bin/**;$(Examples)/**/obj/**" />
<FSharpSample Include="$(FSharpExamples)/**/*.fs" Exclude="$(FSharpExamples)/**/bin/**;$(FSharpExamples)/**/obj/**" /> <FSharpSample Include="$(FSharpExamples)/**/*.fs" Exclude="$(FSharpExamples)/**/bin/**;$(FSharpExamples)/**/obj/**" />
@ -31,7 +32,11 @@
<RemoveDir Directories="$(NumericsPack)/lib" /> <RemoveDir Directories="$(NumericsPack)/lib" />
<Copy SourceFiles="@(NumericsNet40)" DestinationFolder="$(NumericsPack)/lib/Net40" /> <Copy SourceFiles="@(NumericsNet40)" DestinationFolder="$(NumericsPack)/lib/Net40" />
<Copy SourceFiles="@(NumericsSL4)" DestinationFolder="$(NumericsPack)/lib/SL4" />
<RemoveDir Directories="$(PortablePack)/lib" />
<Copy SourceFiles="@(NumericsPortable)" DestinationFolder="$(PortablePack)/lib/net40" />
<Copy SourceFiles="@(NumericsPortable)" DestinationFolder="$(PortablePack)/lib/sl5" />
<Copy SourceFiles="@(NumericsPortable)" DestinationFolder="$(PortablePack)/lib/winrt45" />
<RemoveDir Directories="$(FSharpPack)/lib" /> <RemoveDir Directories="$(FSharpPack)/lib" />
<Copy SourceFiles="@(FSharpNet40)" DestinationFolder="$(FSharpPack)/lib/Net40" /> <Copy SourceFiles="@(FSharpNet40)" DestinationFolder="$(FSharpPack)/lib/Net40" />
@ -49,6 +54,9 @@
<GetAssemblyIdentity AssemblyFiles="$(NumericsPack)/lib/Net40/MathNet.Numerics.dll"> <GetAssemblyIdentity AssemblyFiles="$(NumericsPack)/lib/Net40/MathNet.Numerics.dll">
<Output TaskParameter="Assemblies" ItemName="NumericsAssemblyInfo"/> <Output TaskParameter="Assemblies" ItemName="NumericsAssemblyInfo"/>
</GetAssemblyIdentity> </GetAssemblyIdentity>
<GetAssemblyIdentity AssemblyFiles="$(PortablePack)/lib/net40/MathNet.Numerics.dll">
<Output TaskParameter="Assemblies" ItemName="PortableAssemblyInfo"/>
</GetAssemblyIdentity>
<GetAssemblyIdentity AssemblyFiles="$(FSharpPack)/lib/Net40/MathNet.Numerics.FSharp.dll"> <GetAssemblyIdentity AssemblyFiles="$(FSharpPack)/lib/Net40/MathNet.Numerics.FSharp.dll">
<Output TaskParameter="Assemblies" ItemName="FSharpAssemblyInfo"/> <Output TaskParameter="Assemblies" ItemName="FSharpAssemblyInfo"/>
</GetAssemblyIdentity> </GetAssemblyIdentity>
@ -56,12 +64,14 @@
<!-- Extract Assembly Versions --> <!-- Extract Assembly Versions -->
<PropertyGroup> <PropertyGroup>
<NumericsAssemblyVersion>%(NumericsAssemblyInfo.Version)</NumericsAssemblyVersion> <NumericsAssemblyVersion>%(NumericsAssemblyInfo.Version)</NumericsAssemblyVersion>
<PortableAssemblyVersion>%(PortableAssemblyInfo.Version)</PortableAssemblyVersion>
<FSharpAssemblyVersion>%(FSharpAssemblyInfo.Version)</FSharpAssemblyVersion> <FSharpAssemblyVersion>%(FSharpAssemblyInfo.Version)</FSharpAssemblyVersion>
</PropertyGroup> </PropertyGroup>
<!-- Package Versions (skip 4th part/build number, for semvar compliance) --> <!-- Package Versions (skip 4th part/build number, for semvar compliance) -->
<PropertyGroup> <PropertyGroup>
<NumericsPackVersion>$(NumericsAssemblyVersion.Substring(0, $(NumericsAssemblyVersion.LastIndexOf('.'))))</NumericsPackVersion> <NumericsPackVersion>$(NumericsAssemblyVersion.Substring(0, $(NumericsAssemblyVersion.LastIndexOf('.'))))</NumericsPackVersion>
<PortablePackVersion>$(PortableAssemblyVersion.Substring(0, $(PortableAssemblyVersion.LastIndexOf('.'))))</PortablePackVersion>
<FSharpPackVersion>$(FSharpAssemblyVersion.Substring(0, $(FSharpAssemblyVersion.LastIndexOf('.'))))</FSharpPackVersion> <FSharpPackVersion>$(FSharpAssemblyVersion.Substring(0, $(FSharpAssemblyVersion.LastIndexOf('.'))))</FSharpPackVersion>
</PropertyGroup> </PropertyGroup>
@ -70,6 +80,12 @@
XmlFileName="$(NumericsPack)/MathNet.Numerics.nuspec" XmlFileName="$(NumericsPack)/MathNet.Numerics.nuspec"
XPath="//package/n:metadata/n:version" XPath="//package/n:metadata/n:version"
Value="$(NumericsPackVersion)"/> Value="$(NumericsPackVersion)"/>
<XmlUpdate
Prefix="n" Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
XmlFileName="$(PortablePack)/MathNet.Numerics.Portable.nuspec"
XPath="//package/n:metadata/n:version"
Value="$(PortablePackVersion)"/>
<XmlUpdate <XmlUpdate
Prefix="n" Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" Prefix="n" Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
@ -123,6 +139,7 @@
<Target Name="BuildPackages" DependsOnTargets="UpdateNuspec;PatchContentFiles"> <Target Name="BuildPackages" DependsOnTargets="UpdateNuspec;PatchContentFiles">
<MakeDir Directories="$(OutNuGetPackages)" /> <MakeDir Directories="$(OutNuGetPackages)" />
<Exec Command="$(NuGetExe) pack $(NumericsPack)/MathNet.Numerics.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" /> <Exec Command="$(NuGetExe) pack $(NumericsPack)/MathNet.Numerics.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" />
<Exec Command="$(NuGetExe) pack $(PortablePack)/MathNet.Numerics.Portable.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" />
<Exec Command="$(NuGetExe) pack $(FSharpPack)/MathNet.Numerics.FSharp.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" /> <Exec Command="$(NuGetExe) pack $(FSharpPack)/MathNet.Numerics.FSharp.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" />
<Exec Command="$(NuGetExe) pack $(NumericsSamplePack)/MathNet.Numerics.Sample.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" /> <Exec Command="$(NuGetExe) pack $(NumericsSamplePack)/MathNet.Numerics.Sample.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" />
<Exec Command="$(NuGetExe) pack $(FSharpSamplePack)/MathNet.Numerics.FSharp.Sample.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" /> <Exec Command="$(NuGetExe) pack $(FSharpSamplePack)/MathNet.Numerics.FSharp.Sample.nuspec /Verbose /OutputDirectory $(OutNuGetPackages)" />

22
src/Numerics/Complex32.cs

@ -125,7 +125,7 @@ namespace MathNet.Numerics
/// <param name="imaginary"> /// <param name="imaginary">
/// The value for the imaginary component. /// The value for the imaginary component.
/// </param> /// </param>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32(float real, float imaginary) public Complex32(float real, float imaginary)
@ -214,7 +214,7 @@ namespace MathNet.Numerics
/// <value>The real component of the complex number.</value> /// <value>The real component of the complex number.</value>
public float Real public float Real
{ {
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
get get
@ -229,7 +229,7 @@ namespace MathNet.Numerics
/// <value>The real imaginary component of the complex number.</value> /// <value>The real imaginary component of the complex number.</value>
public float Imaginary public float Imaginary
{ {
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
get get
@ -943,7 +943,7 @@ namespace MathNet.Numerics
/// <returns> /// <returns>
/// Returns the same complex number. /// Returns the same complex number.
/// </returns> /// </returns>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Plus() public Complex32 Plus()
@ -957,7 +957,7 @@ namespace MathNet.Numerics
/// <returns> /// <returns>
/// The negated value of this complex number. /// The negated value of this complex number.
/// </returns> /// </returns>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Negate() public Complex32 Negate()
@ -974,7 +974,7 @@ namespace MathNet.Numerics
/// <param name="other"> /// <param name="other">
/// The other complex number to add. /// The other complex number to add.
/// </param> /// </param>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Add(Complex32 other) public Complex32 Add(Complex32 other)
@ -991,7 +991,7 @@ namespace MathNet.Numerics
/// <param name="other"> /// <param name="other">
/// The other complex number to subtract from this one. /// The other complex number to subtract from this one.
/// </param> /// </param>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Subtract(Complex32 other) public Complex32 Subtract(Complex32 other)
@ -1008,7 +1008,7 @@ namespace MathNet.Numerics
/// <param name="multiplier"> /// <param name="multiplier">
/// The complex number to multiply. /// The complex number to multiply.
/// </param> /// </param>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Multiply(Complex32 multiplier) public Complex32 Multiply(Complex32 multiplier)
@ -1025,7 +1025,7 @@ namespace MathNet.Numerics
/// <param name="divisor"> /// <param name="divisor">
/// The divisor. /// The divisor.
/// </param> /// </param>
#if !SILVERLIGHT #if !PORTABLE
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
#endif #endif
public Complex32 Divide(Complex32 divisor) public Complex32 Divide(Complex32 divisor)
@ -1235,7 +1235,7 @@ namespace MathNet.Numerics
} }
} }
#if SILVERLIGHT #if PORTABLE
var value = GlobalizationHelper.ParseSingle(ref token); var value = GlobalizationHelper.ParseSingle(ref token);
#else #else
var value = GlobalizationHelper.ParseSingle(ref token, format.GetCultureInfo()); var value = GlobalizationHelper.ParseSingle(ref token, format.GetCultureInfo());
@ -1392,6 +1392,7 @@ namespace MathNet.Numerics
return new Complex32(value, 0.0f); return new Complex32(value, 0.0f);
} }
#if SYSNUMERICS
/// <summary> /// <summary>
/// Implicit conversion of a BigInteger int to a <c>Complex32</c>. /// Implicit conversion of a BigInteger int to a <c>Complex32</c>.
/// </summary> /// </summary>
@ -1401,6 +1402,7 @@ namespace MathNet.Numerics
{ {
return new Complex32((long)value, 0.0f); return new Complex32((long)value, 0.0f);
} }
#endif
/// <summary> /// <summary>
/// Implicit conversion of a real long to a <c>Complex32</c>. /// Implicit conversion of a real long to a <c>Complex32</c>.

1700
src/Numerics/Complex64.cs

File diff suppressed because it is too large

2
src/Numerics/ComplexExtensions.cs

@ -497,7 +497,7 @@ namespace MathNet.Numerics
} }
} }
#if SILVERLIGHT #if PORTABLE
var value = GlobalizationHelper.ParseDouble(ref token); var value = GlobalizationHelper.ParseDouble(ref token);
#else #else
var value = GlobalizationHelper.ParseDouble(ref token, format.GetCultureInfo()); var value = GlobalizationHelper.ParseDouble(ref token, format.GetCultureInfo());

32
src/Numerics/Control.cs

@ -32,19 +32,16 @@ namespace MathNet.Numerics
{ {
using System; using System;
using Algorithms.LinearAlgebra; using Algorithms.LinearAlgebra;
using Threading;
/// <summary> /// <summary>
/// Sets parameters for the library. /// Sets parameters for the library.
/// </summary> /// </summary>
public static class Control public static class Control
{ {
#if !SILVERLIGHT
/// <summary> /// <summary>
/// Initial number of threads to use; /// Initial number of threads to use;
/// </summary> /// </summary>
private static int _numberOfThreads = Environment.ProcessorCount; private static int _numberOfThreads = Environment.ProcessorCount;
#endif
/// <summary> /// <summary>
/// Initial block size for the native linear algebra provider. /// Initial block size for the native linear algebra provider.
@ -110,20 +107,11 @@ namespace MathNet.Numerics
/// <remarks>The Silverlight version of the library defaults to one thread.</remarks> /// <remarks>The Silverlight version of the library defaults to one thread.</remarks>
public static int NumberOfParallelWorkerThreads public static int NumberOfParallelWorkerThreads
{ {
#if SILVERLIGHT get { return _numberOfThreads; }
get { return ThreadQueue.ThreadCount; }
set { ThreadQueue.Start(value); }
#else
get
{
return _numberOfThreads;
}
set set
{ // instead of throwing an out of range exception, simply normalize { // instead of throwing an out of range exception, simply normalize
_numberOfThreads = Math.Max(1, Math.Min(1024, value)); _numberOfThreads = Math.Max(1, Math.Min(1024, value));
} }
#endif
} }
/// <summary> /// <summary>
@ -133,11 +121,7 @@ namespace MathNet.Numerics
/// <value>The block size. Must be at least 32.</value> /// <value>The block size. Must be at least 32.</value>
public static int BlockSize public static int BlockSize
{ {
get get { return _blockSize; }
{
return _blockSize;
}
set set
{ {
if (_blockSize > 31) if (_blockSize > 31)
@ -153,11 +137,7 @@ namespace MathNet.Numerics
/// <value>The order. Default is 64.</value> /// <value>The order. Default is 64.</value>
public static int ParallelizeOrder public static int ParallelizeOrder
{ {
get get { return _parallelizeOrder; }
{
return _parallelizeOrder;
}
set set
{ {
if (_parallelizeOrder > 2) if (_parallelizeOrder > 2)
@ -173,11 +153,7 @@ namespace MathNet.Numerics
/// <value>Number of elements. Default is 300.</value> /// <value>Number of elements. Default is 300.</value>
public static int ParallelizeElements public static int ParallelizeElements
{ {
get get { return _parallelizeElements; }
{
return _parallelizeElements;
}
set set
{ {
if (_parallelizeElements > 2) if (_parallelizeElements > 2)

2
src/Numerics/GlobalizationHelper.cs

@ -127,7 +127,7 @@ namespace MathNet.Numerics
} }
} }
#if SILVERLIGHT #if PORTABLE
/// <summary> /// <summary>
/// Globalized Parsing: Parse a double number /// Globalized Parsing: Parse a double number
/// </summary> /// </summary>

6
src/Numerics/LinearAlgebra/Complex/DenseVector.cs

@ -807,11 +807,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(Data, (i, v) => v.Magnitude, Math.Max, 0d);
0,
Count,
(index, localData) => Math.Max(localData, Data[index].Magnitude),
Math.Max);
} }
var sum = 0.0; var sum = 0.0;

2
src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs

@ -268,7 +268,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(Data[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(Data[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(Data[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(Data[i].GetHashCode());

4
src/Numerics/LinearAlgebra/Complex/Solvers/IIterator.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
/// Defines the base interface for iterators that help control an iterative calculation. /// Defines the base interface for iterators that help control an iterative calculation.
/// </summary> /// </summary>
public interface IIterator public interface IIterator
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -101,7 +101,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
/// </remarks> /// </remarks>
void ResetToPrecalculationState(); void ResetToPrecalculationState();
#if SILVERLIGHT #if PORTABLE
IIterator Clone(); IIterator Clone();
#endif #endif
} }

8
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs

@ -96,7 +96,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// </summary> /// </summary>
private static readonly ICalculationStatus RunningStatus = new CalculationRunning(); private static readonly ICalculationStatus RunningStatus = new CalculationRunning();
#if SILVERLIGHT #if PORTABLE
private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>(); private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>();
#else #else
/// <summary> /// <summary>
@ -125,6 +125,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude); LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude);
} }
#if !PORTABLE
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location.
/// </summary> /// </summary>
@ -171,6 +172,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// Now we can load the solver information. // Now we can load the solver information.
LoadSolverInformationFromAssembly(assembly, typesToExclude); LoadSolverInformationFromAssembly(assembly, typesToExclude);
} }
#endif
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name.
@ -291,6 +293,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
{ {
continue; continue;
} }
#if !PORTABLE
catch (MethodAccessException) catch (MethodAccessException)
{ {
continue; continue;
@ -299,6 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
{ {
continue; continue;
} }
#endif
catch (MemberAccessException) catch (MemberAccessException)
{ {
continue; continue;
@ -556,7 +560,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
throw new Exception("IIterativeSolverSetup objects not found"); throw new Exception("IIterativeSolverSetup objects not found");
} }
#if SILVERLIGHT #if PORTABLE
foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups))
#else #else
foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups))

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs

@ -311,7 +311,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
return new Iterator(stopCriteria); return new Iterator(stopCriteria);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Creates a deep clone of the current iterator. /// Creates a deep clone of the current iterator.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/DivergenceStopCriterium.cs

@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations); return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clone this object /// Clone this object
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/FailureStopCriterium.cs

@ -186,7 +186,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
return new FailureStopCriterium(); return new FailureStopCriterium();
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="FailureStopCriterium"/> and its settings. /// Clones the current <see cref="FailureStopCriterium"/> and its settings.
/// </summary> /// </summary>

4
src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/IIterationStopCriterium.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
/// The base interface for classes that provide stop criteria for iterative calculations. /// The base interface for classes that provide stop criteria for iterative calculations.
/// </summary> /// </summary>
public interface IIterationStopCriterium public interface IIterationStopCriterium
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
/// </summary> /// </summary>
StopLevel StopLevel { get; } StopLevel StopLevel { get; }
#if SILVERLIGHT #if PORTABLE
IIterationStopCriterium Clone(); IIterationStopCriterium Clone();
#endif #endif
} }

2
src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/IterationCountStopCriterium.cs

@ -212,7 +212,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
return new IterationCountStopCriterium(_maximumNumberOfIterations); return new IterationCountStopCriterium(_maximumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="IterationCountStopCriterium"/> and its settings. /// Clones the current <see cref="IterationCountStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex/Solvers/StopCriterium/ResidualStopCriterium.cs

@ -394,7 +394,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium
return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum); return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="ResidualStopCriterium"/> and its settings. /// Clones the current <see cref="ResidualStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs

@ -843,7 +843,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i].Magnitude); hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i].Magnitude);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].Magnitude); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].Magnitude);

4
src/Numerics/LinearAlgebra/Complex/SparseVector.cs

@ -1090,7 +1090,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select(0, NonZerosCount, (index, localData) => Math.Max(localData, _nonZeroValues[index].Magnitude), Math.Max); return CommonParallel.Aggregate(0, NonZerosCount, i => _nonZeroValues[i].Magnitude, Math.Max, 0d);
} }
var sum = 0.0; var sum = 0.0;
@ -1406,7 +1406,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode());

6
src/Numerics/LinearAlgebra/Complex/Vector.cs

@ -316,11 +316,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (double.IsPositiveInfinity(p)) if (double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(0, Count, i => At(i).Magnitude, Math.Max, 0d);
0,
Count,
(index, localData) => Math.Max(localData, At(index).Magnitude),
Math.Max);
} }
var sum = 0.0; var sum = 0.0;

6
src/Numerics/LinearAlgebra/Complex32/DenseVector.cs

@ -860,11 +860,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(Data, (i, v) => v.Magnitude, Math.Max, 0f);
0,
Count,
(index, localData) => Math.Max(localData, Data[index].Magnitude),
Common.Max);
} }
var sum = 0.0; var sum = 0.0;

2
src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs

@ -273,7 +273,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(Data[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(Data[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(Data[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(Data[i].GetHashCode());

4
src/Numerics/LinearAlgebra/Complex32/Solvers/IIterator.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
/// Defines the base interface for iterators that help control an iterative calculation. /// Defines the base interface for iterators that help control an iterative calculation.
/// </summary> /// </summary>
public interface IIterator public interface IIterator
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -101,7 +101,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
/// </remarks> /// </remarks>
void ResetToPrecalculationState(); void ResetToPrecalculationState();
#if SILVERLIGHT #if PORTABLE
IIterator Clone(); IIterator Clone();
#endif #endif
} }

8
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs

@ -93,7 +93,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// </summary> /// </summary>
private static readonly ICalculationStatus RunningStatus = new CalculationRunning(); private static readonly ICalculationStatus RunningStatus = new CalculationRunning();
#if SILVERLIGHT #if PORTABLE
private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>(); private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>();
#else #else
/// <summary> /// <summary>
@ -122,6 +122,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude); LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude);
} }
#if !PORTABLE
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location.
/// </summary> /// </summary>
@ -168,6 +169,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// Now we can load the solver information. // Now we can load the solver information.
LoadSolverInformationFromAssembly(assembly, typesToExclude); LoadSolverInformationFromAssembly(assembly, typesToExclude);
} }
#endif
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name.
@ -288,6 +290,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
{ {
continue; continue;
} }
#if !PORTABLE
catch (MethodAccessException) catch (MethodAccessException)
{ {
continue; continue;
@ -296,6 +299,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
{ {
continue; continue;
} }
#endif
catch (MemberAccessException) catch (MemberAccessException)
{ {
continue; continue;
@ -553,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
throw new Exception("IIterativeSolverSetup objects not found"); throw new Exception("IIterativeSolverSetup objects not found");
} }
#if SILVERLIGHT #if PORTABLE
foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups))
#else #else
foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups))

4
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs

@ -311,7 +311,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
return new Iterator(stopCriteria); return new Iterator(stopCriteria);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Creates a deep clone of the current iterator. /// Creates a deep clone of the current iterator.
/// </summary> /// </summary>
@ -320,6 +320,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
{ {
return Clone(); return Clone();
} }
#endif #endif
} }
} }

2
src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/DivergenceStopCriterium.cs

@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations); return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clone this object /// Clone this object
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/FailureStopCriterium.cs

@ -186,7 +186,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
return new FailureStopCriterium(); return new FailureStopCriterium();
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="FailureStopCriterium"/> and its settings. /// Clones the current <see cref="FailureStopCriterium"/> and its settings.
/// </summary> /// </summary>

4
src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/IIterationStopCriterium.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
/// The base interface for classes that provide stop criteria for iterative calculations. /// The base interface for classes that provide stop criteria for iterative calculations.
/// </summary> /// </summary>
public interface IIterationStopCriterium public interface IIterationStopCriterium
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
/// </summary> /// </summary>
StopLevel StopLevel { get; } StopLevel StopLevel { get; }
#if SILVERLIGHT #if PORTABLE
IIterationStopCriterium Clone(); IIterationStopCriterium Clone();
#endif #endif
} }

2
src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/IterationCountStopCriterium.cs

@ -212,7 +212,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
return new IterationCountStopCriterium(_maximumNumberOfIterations); return new IterationCountStopCriterium(_maximumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="IterationCountStopCriterium"/> and its settings. /// Clones the current <see cref="IterationCountStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex32/Solvers/StopCriterium/ResidualStopCriterium.cs

@ -394,7 +394,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium
return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum); return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="ResidualStopCriterium"/> and its settings. /// Clones the current <see cref="ResidualStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs

@ -844,7 +844,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i].Magnitude); hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i].Magnitude);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].Magnitude); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].Magnitude);

4
src/Numerics/LinearAlgebra/Complex32/SparseVector.cs

@ -1120,7 +1120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select(0, NonZerosCount, (index, localData) => Math.Max(localData, _nonZeroValues[index].Magnitude), Common.Max); return CommonParallel.Aggregate(0, NonZerosCount, i => _nonZeroValues[i].Magnitude, Math.Max, 0f);
} }
var sum = 0.0; var sum = 0.0;
@ -1436,7 +1436,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode());

6
src/Numerics/LinearAlgebra/Complex32/Vector.cs

@ -316,11 +316,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (double.IsPositiveInfinity(p)) if (double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(0, Count, i => At(i).Magnitude, Math.Max, 0f);
0,
Count,
(index, localData) => Math.Max(localData, At(index).Magnitude),
Common.Max);
} }
var sum = 0.0; var sum = 0.0;

6
src/Numerics/LinearAlgebra/Double/DenseVector.cs

@ -942,11 +942,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(Data, (i, v) => Math.Abs(v), Math.Max, 0d);
0,
Count,
(index, localData) => Math.Max(localData, Math.Abs(Data[index])),
Math.Max);
} }
var sum = 0.0; var sum = 0.0;

2
src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs

@ -267,7 +267,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(Data[i]); hash ^= Precision.DoubleToInt64Bits(Data[i]);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(Data[i]); hash ^= BitConverter.DoubleToInt64Bits(Data[i]);

4
src/Numerics/LinearAlgebra/Double/Solvers/IIterator.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// Defines the base interface for iterators that help control an iterative calculation. /// Defines the base interface for iterators that help control an iterative calculation.
/// </summary> /// </summary>
public interface IIterator public interface IIterator
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -101,7 +101,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// </remarks> /// </remarks>
void ResetToPrecalculationState(); void ResetToPrecalculationState();
#if SILVERLIGHT #if PORTABLE
IIterator Clone(); IIterator Clone();
#endif #endif
} }

9
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs

@ -31,7 +31,6 @@
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
{ {
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -91,7 +90,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// </summary> /// </summary>
private static readonly ICalculationStatus RunningStatus = new CalculationRunning(); private static readonly ICalculationStatus RunningStatus = new CalculationRunning();
#if SILVERLIGHT #if PORTABLE
private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>(); private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>();
#else #else
/// <summary> /// <summary>
@ -120,6 +119,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude); LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude);
} }
#if !PORTABLE
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location.
/// </summary> /// </summary>
@ -166,6 +166,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
// Now we can load the solver information. // Now we can load the solver information.
LoadSolverInformationFromAssembly(assembly, typesToExclude); LoadSolverInformationFromAssembly(assembly, typesToExclude);
} }
#endif
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name.
@ -286,6 +287,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
{ {
continue; continue;
} }
#if !PORTABLE
catch (MethodAccessException) catch (MethodAccessException)
{ {
continue; continue;
@ -294,6 +296,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
{ {
continue; continue;
} }
#endif
catch (MemberAccessException) catch (MemberAccessException)
{ {
continue; continue;
@ -551,7 +554,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
throw new Exception("IIterativeSolverSetup objects not found"); throw new Exception("IIterativeSolverSetup objects not found");
} }
#if SILVERLIGHT #if PORTABLE
foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups))
#else #else
foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups))

4
src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs

@ -311,7 +311,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
return new Iterator(stopCriteria); return new Iterator(stopCriteria);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Creates a deep clone of the current iterator. /// Creates a deep clone of the current iterator.
/// </summary> /// </summary>
@ -320,6 +320,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
{ {
return Clone(); return Clone();
} }
#endif #endif
} }
} }

2
src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/DivergenceStopCriterium.cs

@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations); return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clone this object /// Clone this object
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/FailureStopCriterium.cs

@ -186,7 +186,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
return new FailureStopCriterium(); return new FailureStopCriterium();
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="FailureStopCriterium"/> and its settings. /// Clones the current <see cref="FailureStopCriterium"/> and its settings.
/// </summary> /// </summary>

4
src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/IIterationStopCriterium.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
/// The base interface for classes that provide stop criteria for iterative calculations. /// The base interface for classes that provide stop criteria for iterative calculations.
/// </summary> /// </summary>
public interface IIterationStopCriterium public interface IIterationStopCriterium
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
/// </summary> /// </summary>
StopLevel StopLevel { get; } StopLevel StopLevel { get; }
#if SILVERLIGHT #if PORTABLE
IIterationStopCriterium Clone(); IIterationStopCriterium Clone();
#endif #endif
} }

2
src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/IterationCountStopCriterium.cs

@ -212,7 +212,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
return new IterationCountStopCriterium(_maximumNumberOfIterations); return new IterationCountStopCriterium(_maximumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="IterationCountStopCriterium"/> and its settings. /// Clones the current <see cref="IterationCountStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Double/Solvers/StopCriterium/ResidualStopCriterium.cs

@ -394,7 +394,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium
return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum); return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="ResidualStopCriterium"/> and its settings. /// Clones the current <see cref="ResidualStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs

@ -855,7 +855,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i]); hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i]);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i]); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i]);

4
src/Numerics/LinearAlgebra/Double/SparseVector.cs

@ -1149,7 +1149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select(0, NonZerosCount, (index, localData) => Math.Max(localData, Math.Abs(_nonZeroValues[index])), Math.Max); return CommonParallel.Aggregate(0, NonZerosCount, i => Math.Abs(_nonZeroValues[i]), Math.Max, 0d);
} }
var sum = 0.0; var sum = 0.0;
@ -1466,7 +1466,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode());

6
src/Numerics/LinearAlgebra/Double/Vector.cs

@ -318,11 +318,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(0, Count, i => Math.Abs(At(i)), Math.Max, 0d);
0,
Count,
(index, localData) => Math.Max(localData, Math.Abs(At(index))),
Math.Max);
} }
var sum = 0.0; var sum = 0.0;

6
src/Numerics/LinearAlgebra/Generic/Matrix.cs

@ -41,7 +41,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam> /// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
[Serializable] [Serializable]
public abstract partial class Matrix<T> : public abstract partial class Matrix<T> :
#if SILVERLIGHT #if PORTABLE
IFormattable, IEquatable<Matrix<T>> IFormattable, IEquatable<Matrix<T>>
#else #else
IFormattable, IEquatable<Matrix<T>>, ICloneable IFormattable, IEquatable<Matrix<T>>, ICloneable
@ -1335,7 +1335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#region Implemented Interfaces #region Implemented Interfaces
#if !SILVERLIGHT #if !PORTABLE
#region ICloneable #region ICloneable
@ -1493,7 +1493,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
var col = i % ColumnCount; var col = i % ColumnCount;
var row = (i - col) / RowCount; var row = (i - col) / RowCount;
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this[row, col].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this[row, col].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(this[row, col].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(this[row, col].GetHashCode());

6
src/Numerics/LinearAlgebra/Generic/Vector.cs

@ -42,7 +42,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <typeparam name="T">Supported data types are double, single, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam> /// <typeparam name="T">Supported data types are double, single, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
[Serializable] [Serializable]
public abstract class Vector<T> : public abstract class Vector<T> :
#if SILVERLIGHT #if PORTABLE
IFormattable, IEnumerable<T>, IEquatable<Vector<T>> IFormattable, IEnumerable<T>, IEquatable<Vector<T>>
#else #else
IFormattable, IEnumerable<T>, IEquatable<Vector<T>>, ICloneable IFormattable, IEnumerable<T>, IEquatable<Vector<T>>, ICloneable
@ -1391,7 +1391,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#region Implemented Interfaces #region Implemented Interfaces
#if !SILVERLIGHT #if !PORTABLE
#region ICloneable #region ICloneable
@ -1583,7 +1583,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(this[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(this[i].GetHashCode());

6
src/Numerics/LinearAlgebra/Single/DenseVector.cs

@ -942,11 +942,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(Data, (i, v) => Math.Abs(v), Math.Max, 0f);
0,
Count,
(index, localData) => Math.Max(localData, Math.Abs(Data[index])),
Common.Max);
} }
var sum = 0.0; var sum = 0.0;

2
src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs

@ -267,7 +267,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(Data[i]); hash ^= Precision.DoubleToInt64Bits(Data[i]);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(Data[i]); hash ^= BitConverter.DoubleToInt64Bits(Data[i]);

4
src/Numerics/LinearAlgebra/Single/Solvers/IIterator.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// Defines the base interface for iterators that help control an iterative calculation. /// Defines the base interface for iterators that help control an iterative calculation.
/// </summary> /// </summary>
public interface IIterator public interface IIterator
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -101,7 +101,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// </remarks> /// </remarks>
void ResetToPrecalculationState(); void ResetToPrecalculationState();
#if SILVERLIGHT #if PORTABLE
IIterator Clone(); IIterator Clone();
#endif #endif
} }

8
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs

@ -93,7 +93,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// </summary> /// </summary>
private static readonly ICalculationStatus RunningStatus = new CalculationRunning(); private static readonly ICalculationStatus RunningStatus = new CalculationRunning();
#if SILVERLIGHT #if PORTABLE
private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>(); private static readonly Dictionary<double, List<IIterativeSolverSetup>> SolverSetups = new Dictionary<double, List<IIterativeSolverSetup>>();
#else #else
/// <summary> /// <summary>
@ -122,6 +122,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude); LoadSolverInformationFromAssembly(Assembly.GetExecutingAssembly(), typesToExclude);
} }
#if !PORTABLE
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the file location.
/// </summary> /// </summary>
@ -168,6 +169,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// Now we can load the solver information. // Now we can load the solver information.
LoadSolverInformationFromAssembly(assembly, typesToExclude); LoadSolverInformationFromAssembly(assembly, typesToExclude);
} }
#endif
/// <summary> /// <summary>
/// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name. /// Loads the available <see cref="IIterativeSolverSetup"/> objects from the assembly specified by the assembly name.
@ -288,6 +290,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
{ {
continue; continue;
} }
#if !PORTABLE
catch (MethodAccessException) catch (MethodAccessException)
{ {
continue; continue;
@ -296,6 +299,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
{ {
continue; continue;
} }
#endif
catch (MemberAccessException) catch (MemberAccessException)
{ {
continue; continue;
@ -553,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
throw new Exception("IIterativeSolverSetup objects not found"); throw new Exception("IIterativeSolverSetup objects not found");
} }
#if SILVERLIGHT #if PORTABLE
foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.OrderBy(solver => solver.Key, new DoubleComparer()).Select(pair => pair.Value).SelectMany(setups => setups))
#else #else
foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups)) foreach (var setup in SolverSetups.Select(pair => pair.Value).SelectMany(setups => setups))

4
src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs

@ -311,7 +311,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
return new Iterator(stopCriteria); return new Iterator(stopCriteria);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Creates a deep clone of the current iterator. /// Creates a deep clone of the current iterator.
/// </summary> /// </summary>
@ -320,6 +320,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
{ {
return Clone(); return Clone();
} }
#endif #endif
} }
} }

2
src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/DivergenceStopCriterium.cs

@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations); return new DivergenceStopCriterium(_maximumRelativeIncrease, _minimumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clone this object /// Clone this object
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/FailureStopCriterium.cs

@ -186,7 +186,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
return new FailureStopCriterium(); return new FailureStopCriterium();
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="FailureStopCriterium"/> and its settings. /// Clones the current <see cref="FailureStopCriterium"/> and its settings.
/// </summary> /// </summary>

4
src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/IIterationStopCriterium.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
/// The base interface for classes that provide stop criteria for iterative calculations. /// The base interface for classes that provide stop criteria for iterative calculations.
/// </summary> /// </summary>
public interface IIterationStopCriterium public interface IIterationStopCriterium
#if !SILVERLIGHT #if !PORTABLE
: ICloneable : ICloneable
#endif #endif
{ {
@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
/// </summary> /// </summary>
StopLevel StopLevel { get; } StopLevel StopLevel { get; }
#if SILVERLIGHT #if PORTABLE
IIterationStopCriterium Clone(); IIterationStopCriterium Clone();
#endif #endif
} }

2
src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/IterationCountStopCriterium.cs

@ -212,7 +212,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
return new IterationCountStopCriterium(_maximumNumberOfIterations); return new IterationCountStopCriterium(_maximumNumberOfIterations);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="IterationCountStopCriterium"/> and its settings. /// Clones the current <see cref="IterationCountStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Single/Solvers/StopCriterium/ResidualStopCriterium.cs

@ -394,7 +394,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium
return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum); return new ResidualStopCriterium(_maximum, _minimumIterationsBelowMaximum);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Clones the current <see cref="ResidualStopCriterium"/> and its settings. /// Clones the current <see cref="ResidualStopCriterium"/> and its settings.
/// </summary> /// </summary>

2
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

@ -838,7 +838,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i]); hash ^= Precision.DoubleToInt64Bits(_nonZeroValues[i]);
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i]); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i]);

4
src/Numerics/LinearAlgebra/Single/SparseVector.cs

@ -1159,7 +1159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (Double.IsPositiveInfinity(p)) if (Double.IsPositiveInfinity(p))
{ {
return CommonParallel.Select(0, NonZerosCount, (index, localData) => Math.Max(localData, Math.Abs(_nonZeroValues[index])), Common.Max); return CommonParallel.Aggregate(0, NonZerosCount, i => Math.Abs(_nonZeroValues[i]), Math.Max, 0f);
} }
var sum = 0.0; var sum = 0.0;
@ -1476,7 +1476,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
long hash = 0; long hash = 0;
for (var i = 0; i < hashNum; i++) for (var i = 0; i < hashNum; i++)
{ {
#if SILVERLIGHT #if PORTABLE
hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode()); hash ^= Precision.DoubleToInt64Bits(this._nonZeroValues[i].GetHashCode());
#else #else
hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode()); hash ^= BitConverter.DoubleToInt64Bits(_nonZeroValues[i].GetHashCode());

6
src/Numerics/LinearAlgebra/Single/Vector.cs

@ -319,11 +319,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (float.IsPositiveInfinity((float)p)) if (float.IsPositiveInfinity((float)p))
{ {
return CommonParallel.Select( return CommonParallel.Aggregate(0, Count, i => Math.Abs(At(i)), Math.Max, 0f);
0,
Count,
(index, localData) => Math.Max(localData, Math.Abs(At(index))),
Common.Max);
} }
var sum = 0.0; var sum = 0.0;

222
src/Numerics/NumberTheory/IntegerTheory.Euclid.Big.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
#if SYSNUMERICS
namespace MathNet.Numerics.NumberTheory namespace MathNet.Numerics.NumberTheory
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
/// <summary> /// <summary>
/// Number theory utility functions for integers. /// Number theory utility functions for integers.
/// </summary> /// </summary>
public static partial class IntegerTheory public static partial class IntegerTheory
@ -47,7 +48,7 @@ namespace MathNet.Numerics.NumberTheory
/// <returns>Greatest common divisor <c>gcd</c>(a,b)</returns> /// <returns>Greatest common divisor <c>gcd</c>(a,b)</returns>
public static BigInteger GreatestCommonDivisor(BigInteger a, BigInteger b) public static BigInteger GreatestCommonDivisor(BigInteger a, BigInteger b)
{ {
return BigInteger.GreatestCommonDivisor(a, b); return BigInteger.GreatestCommonDivisor(a, b);
} }
/// <summary> /// <summary>
@ -55,7 +56,7 @@ namespace MathNet.Numerics.NumberTheory
/// </summary> /// </summary>
/// <param name="integers">List of Integers.</param> /// <param name="integers">List of Integers.</param>
/// <returns>Greatest common divisor <c>gcd</c>(list of integers)</returns> /// <returns>Greatest common divisor <c>gcd</c>(list of integers)</returns>
public static BigInteger GreatestCommonDivisor(IList<BigInteger> integers) public static BigInteger GreatestCommonDivisor(IList<BigInteger> integers)
{ {
if (null == integers) if (null == integers)
{ {
@ -82,114 +83,115 @@ namespace MathNet.Numerics.NumberTheory
/// </summary> /// </summary>
/// <param name="integers">List of Integers.</param> /// <param name="integers">List of Integers.</param>
/// <returns>Greatest common divisor <c>gcd</c>(list of integers)</returns> /// <returns>Greatest common divisor <c>gcd</c>(list of integers)</returns>
public static BigInteger GreatestCommonDivisor(params BigInteger[] integers) public static BigInteger GreatestCommonDivisor(params BigInteger[] integers)
{ {
return GreatestCommonDivisor((IList<BigInteger>)integers); return GreatestCommonDivisor((IList<BigInteger>)integers);
} }
/// <summary> /// <summary>
/// Computes the extended greatest common divisor, such that a*x + b*y = <c>gcd</c>(a,b). /// Computes the extended greatest common divisor, such that a*x + b*y = <c>gcd</c>(a,b).
/// </summary> /// </summary>
/// <param name="a">First Integer: a.</param> /// <param name="a">First Integer: a.</param>
/// <param name="b">Second Integer: b.</param> /// <param name="b">Second Integer: b.</param>
/// <param name="x">Resulting x, such that a*x + b*y = <c>gcd</c>(a,b).</param> /// <param name="x">Resulting x, such that a*x + b*y = <c>gcd</c>(a,b).</param>
/// <param name="y">Resulting y, such that a*x + b*y = <c>gcd</c>(a,b)</param> /// <param name="y">Resulting y, such that a*x + b*y = <c>gcd</c>(a,b)</param>
/// <returns>Greatest common divisor <c>gcd</c>(a,b)</returns> /// <returns>Greatest common divisor <c>gcd</c>(a,b)</returns>
/// <example> /// <example>
/// <code> /// <code>
/// long x,y,d; /// long x,y,d;
/// d = Fn.GreatestCommonDivisor(45,18,out x, out y); /// d = Fn.GreatestCommonDivisor(45,18,out x, out y);
/// -> d == 9 &amp;&amp; x == 1 &amp;&amp; y == -2 /// -> d == 9 &amp;&amp; x == 1 &amp;&amp; y == -2
/// </code> /// </code>
/// 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. /// 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> /// </example>
public static BigInteger ExtendedGreatestCommonDivisor( public static BigInteger ExtendedGreatestCommonDivisor(
BigInteger a, BigInteger a,
BigInteger b, BigInteger b,
out BigInteger x, out BigInteger x,
out BigInteger y) out BigInteger y)
{ {
BigInteger mp = BigInteger.One, np = BigInteger.Zero, m = BigInteger.Zero, n = BigInteger.One; BigInteger mp = BigInteger.One, np = BigInteger.Zero, m = BigInteger.Zero, n = BigInteger.One;
while (!b.IsZero) while (!b.IsZero)
{ {
BigInteger rem; BigInteger rem;
BigInteger quot = BigInteger.DivRem(a, b, out rem); BigInteger quot = BigInteger.DivRem(a, b, out rem);
a = b; a = b;
b = rem; b = rem;
BigInteger tmp = m; BigInteger tmp = m;
m = mp - (quot * m); m = mp - (quot * m);
mp = tmp; mp = tmp;
tmp = n; tmp = n;
n = np - (quot * n); n = np - (quot * n);
np = tmp; np = tmp;
} }
if (a >= BigInteger.Zero) if (a >= BigInteger.Zero)
{ {
x = mp; x = mp;
y = np; y = np;
return a; return a;
} }
x = -mp; x = -mp;
y = -np; y = -np;
return -a; return -a;
} }
/// <summary> /// <summary>
/// Returns the least common multiple (<c>lcm</c>) of two big integers. /// Returns the least common multiple (<c>lcm</c>) of two big integers.
/// </summary> /// </summary>
/// <param name="a">First Integer: a.</param> /// <param name="a">First Integer: a.</param>
/// <param name="b">Second Integer: b.</param> /// <param name="b">Second Integer: b.</param>
/// <returns>Least common multiple <c>lcm</c>(a,b)</returns> /// <returns>Least common multiple <c>lcm</c>(a,b)</returns>
public static BigInteger LeastCommonMultiple(BigInteger a, BigInteger b) public static BigInteger LeastCommonMultiple(BigInteger a, BigInteger b)
{ {
if (a.IsZero || b.IsZero) if (a.IsZero || b.IsZero)
{ {
return BigInteger.Zero; return BigInteger.Zero;
} }
return BigInteger.Abs((a / BigInteger.GreatestCommonDivisor(a, b)) * b); return BigInteger.Abs((a / BigInteger.GreatestCommonDivisor(a, b)) * b);
} }
/// <summary> /// <summary>
/// Returns the least common multiple (<c>lcm</c>) of a set of big integers. /// Returns the least common multiple (<c>lcm</c>) of a set of big integers.
/// </summary> /// </summary>
/// <param name="integers">List of Integers.</param> /// <param name="integers">List of Integers.</param>
/// <returns>Least common multiple <c>lcm</c>(list of integers)</returns> /// <returns>Least common multiple <c>lcm</c>(list of integers)</returns>
public static BigInteger LeastCommonMultiple(IList<BigInteger> integers) public static BigInteger LeastCommonMultiple(IList<BigInteger> integers)
{ {
if (null == integers) if (null == integers)
{ {
throw new ArgumentNullException("integers"); throw new ArgumentNullException("integers");
} }
if (integers.Count == 0) if (integers.Count == 0)
{ {
return 1; return 1;
} }
var lcm = BigInteger.Abs(integers[0]); var lcm = BigInteger.Abs(integers[0]);
for (int i = 1; i < integers.Count; i++) for (int i = 1; i < integers.Count; i++)
{ {
lcm = LeastCommonMultiple(lcm, integers[i]); lcm = LeastCommonMultiple(lcm, integers[i]);
} }
return lcm; return lcm;
} }
/// <summary> /// <summary>
/// Returns the least common multiple (<c>lcm</c>) of a set of big integers. /// Returns the least common multiple (<c>lcm</c>) of a set of big integers.
/// </summary> /// </summary>
/// <param name="integers">List of Integers.</param> /// <param name="integers">List of Integers.</param>
/// <returns>Least common multiple <c>lcm</c>(list of integers)</returns> /// <returns>Least common multiple <c>lcm</c>(list of integers)</returns>
public static BigInteger LeastCommonMultiple(params BigInteger[] integers) public static BigInteger LeastCommonMultiple(params BigInteger[] integers)
{ {
return LeastCommonMultiple((IList<BigInteger>)integers); return LeastCommonMultiple((IList<BigInteger>)integers);
} }
} }
} }
#endif

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

@ -117,8 +117,9 @@ namespace MathNet.Numerics.NumberTheory
while (b != 0) while (b != 0)
{ {
long rem; long rem;
#if SILVERLIGHT #if PORTABLE
var quot = SilverlightUtilities.DivRem(a, b, out rem); rem = a / b;
var quot = a % b;
#else #else
long quot = Math.DivRem(a, b, out rem); long quot = Math.DivRem(a, b, out rem);
#endif #endif

6
src/Numerics/Numerics.csproj

@ -40,7 +40,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\..\out\debug\Net40\</OutputPath> <OutputPath>..\..\out\debug\Net40\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG;SYSNUMERICS</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile> <DocumentationFile>
@ -51,7 +51,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\..\out\lib\Net40\</OutputPath> <OutputPath>..\..\out\lib\Net40\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE;SYSNUMERICS</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\out\lib\Net40\MathNet.Numerics.xml</DocumentationFile> <DocumentationFile>..\..\out\lib\Net40\MathNet.Numerics.xml</DocumentationFile>
@ -96,6 +96,7 @@
<Compile Include="Algorithms\LinearAlgebra\Mkl\MklLinearAlgebraProvider.float.cs" /> <Compile Include="Algorithms\LinearAlgebra\Mkl\MklLinearAlgebraProvider.float.cs" />
<Compile Include="Algorithms\LinearAlgebra\Mkl\SafeNativeMethods.cs" /> <Compile Include="Algorithms\LinearAlgebra\Mkl\SafeNativeMethods.cs" />
<Compile Include="ArrayExtensions.cs" /> <Compile Include="ArrayExtensions.cs" />
<Compile Include="Complex64.cs" />
<Compile Include="Combinatorics.cs" /> <Compile Include="Combinatorics.cs" />
<Compile Include="ComplexExtensions.cs" /> <Compile Include="ComplexExtensions.cs" />
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
@ -394,6 +395,7 @@
<Compile Include="Random\WH1982.cs" /> <Compile Include="Random\WH1982.cs" />
<Compile Include="Random\WH2006.cs" /> <Compile Include="Random\WH2006.cs" />
<Compile Include="Random\Xorshift.cs" /> <Compile Include="Random\Xorshift.cs" />
<Compile Include="SerializableAttribute.cs" />
<Compile Include="Signals\SignalGenerator.Random.cs" /> <Compile Include="Signals\SignalGenerator.Random.cs" />
<Compile Include="Signals\SignalGenerator.Chebyshev.cs" /> <Compile Include="Signals\SignalGenerator.Chebyshev.cs" />
<Compile Include="Signals\SignalGenerator.Equidistant.cs" /> <Compile Include="Signals\SignalGenerator.Equidistant.cs" />

2
src/Numerics/Permutation.cs

@ -149,7 +149,7 @@ namespace MathNet.Numerics
{ {
if (idx[i] != i) if (idx[i] != i)
{ {
#if !SILVERLIGHT #if !PORTABLE
int q = Array.FindIndex(idx, i + 1, x => x == i); int q = Array.FindIndex(idx, i + 1, x => x == i);
#else #else
int q = -1; int q = -1;

36
src/Numerics/Precision.cs

@ -186,14 +186,14 @@ namespace MathNet.Numerics
// truncating a negative number will give us a magnitude that is off by 1 // truncating a negative number will give us a magnitude that is off by 1
if (magnitude < 0) if (magnitude < 0)
{ {
#if SILVERLIGHT #if PORTABLE
return (int)Truncate(magnitude - 1); return (int)Truncate(magnitude - 1);
#else #else
return (int)Math.Truncate(magnitude - 1); return (int)Math.Truncate(magnitude - 1);
#endif #endif
} }
#if SILVERLIGHT #if PORTABLE
return (int)Truncate(magnitude); return (int)Truncate(magnitude);
#else #else
return (int)Math.Truncate(magnitude); return (int)Math.Truncate(magnitude);
@ -223,14 +223,14 @@ namespace MathNet.Numerics
// truncating a negative number will give us a magnitude that is off by 1 // truncating a negative number will give us a magnitude that is off by 1
if (magnitude < 0) if (magnitude < 0)
{ {
#if SILVERLIGHT #if PORTABLE
return (int)Truncate(magnitude - 1); return (int)Truncate(magnitude - 1);
#else #else
return (int)Math.Truncate(magnitude - 1); return (int)Math.Truncate(magnitude - 1);
#endif #endif
} }
#if SILVERLIGHT #if PORTABLE
return (int)Truncate(magnitude); return (int)Truncate(magnitude);
#else #else
return (int)Math.Truncate(magnitude); return (int)Math.Truncate(magnitude);
@ -261,7 +261,7 @@ namespace MathNet.Numerics
/// </returns> /// </returns>
private static long GetLongFromDouble(double value) private static long GetLongFromDouble(double value)
{ {
#if SILVERLIGHT #if PORTABLE
return DoubleToInt64Bits(value); return DoubleToInt64Bits(value);
#else #else
return BitConverter.DoubleToInt64Bits(value); return BitConverter.DoubleToInt64Bits(value);
@ -364,7 +364,7 @@ namespace MathNet.Numerics
// Note that not all long values can be translated into double values. There's a whole bunch of them // Note that not all long values can be translated into double values. There's a whole bunch of them
// which return weird values like infinity and NaN // which return weird values like infinity and NaN
#if SILVERLIGHT #if PORTABLE
return Int64BitsToDouble(intValue); return Int64BitsToDouble(intValue);
#else #else
return BitConverter.Int64BitsToDouble(intValue); return BitConverter.Int64BitsToDouble(intValue);
@ -434,7 +434,7 @@ namespace MathNet.Numerics
// Note that not all long values can be translated into double values. There's a whole bunch of them // Note that not all long values can be translated into double values. There's a whole bunch of them
// which return weird values like infinity and NaN // which return weird values like infinity and NaN
#if SILVERLIGHT #if PORTABLE
return Int64BitsToDouble(intValue); return Int64BitsToDouble(intValue);
#else #else
return BitConverter.Int64BitsToDouble(intValue); return BitConverter.Int64BitsToDouble(intValue);
@ -581,7 +581,7 @@ namespace MathNet.Numerics
// Got underflow, which can be fixed by splitting the calculation into two bits // Got underflow, which can be fixed by splitting the calculation into two bits
// first get the remainder of the intValue after subtracting it from the long.MinValue // first get the remainder of the intValue after subtracting it from the long.MinValue
// and add that to the ulpsDifference. That way we'll turn positive without underflow // and add that to the ulpsDifference. That way we'll turn positive without underflow
#if SILVERLIGHT #if PORTABLE
topRangeEnd =Int64BitsToDouble(maxNumbersBetween + (long.MinValue - intValue)); topRangeEnd =Int64BitsToDouble(maxNumbersBetween + (long.MinValue - intValue));
#else #else
topRangeEnd = BitConverter.Int64BitsToDouble(maxNumbersBetween + (long.MinValue - intValue)); topRangeEnd = BitConverter.Int64BitsToDouble(maxNumbersBetween + (long.MinValue - intValue));
@ -590,7 +590,7 @@ namespace MathNet.Numerics
else else
{ {
// No problems here, move along. // No problems here, move along.
#if SILVERLIGHT #if PORTABLE
topRangeEnd = Int64BitsToDouble(intValue - maxNumbersBetween); topRangeEnd = Int64BitsToDouble(intValue - maxNumbersBetween);
#else #else
topRangeEnd = BitConverter.Int64BitsToDouble(intValue - maxNumbersBetween); topRangeEnd = BitConverter.Int64BitsToDouble(intValue - maxNumbersBetween);
@ -607,7 +607,7 @@ namespace MathNet.Numerics
{ {
// intValue is negative. Adding the positive ulpsDifference means that it gets less negative. // intValue is negative. Adding the positive ulpsDifference means that it gets less negative.
// However due to the conversion way this means that the actual double value gets more negative :-S // However due to the conversion way this means that the actual double value gets more negative :-S
#if SILVERLIGHT #if PORTABLE
bottomRangeEnd =Int64BitsToDouble(intValue + maxNumbersBetween); bottomRangeEnd =Int64BitsToDouble(intValue + maxNumbersBetween);
#else #else
bottomRangeEnd = BitConverter.Int64BitsToDouble(intValue + maxNumbersBetween); bottomRangeEnd = BitConverter.Int64BitsToDouble(intValue + maxNumbersBetween);
@ -626,7 +626,7 @@ namespace MathNet.Numerics
else else
{ {
// No troubles here // No troubles here
#if SILVERLIGHT #if PORTABLE
topRangeEnd = Int64BitsToDouble(intValue + maxNumbersBetween); topRangeEnd = Int64BitsToDouble(intValue + maxNumbersBetween);
#else #else
topRangeEnd = BitConverter.Int64BitsToDouble(intValue + maxNumbersBetween); topRangeEnd = BitConverter.Int64BitsToDouble(intValue + maxNumbersBetween);
@ -638,7 +638,7 @@ namespace MathNet.Numerics
{ {
// No problems here. IntValue is larger than ulpsDifference so we'll end up with a // No problems here. IntValue is larger than ulpsDifference so we'll end up with a
// positive number. // positive number.
#if SILVERLIGHT #if PORTABLE
bottomRangeEnd =Int64BitsToDouble(intValue - maxNumbersBetween); bottomRangeEnd =Int64BitsToDouble(intValue - maxNumbersBetween);
#else #else
bottomRangeEnd = BitConverter.Int64BitsToDouble(intValue - maxNumbersBetween); bottomRangeEnd = BitConverter.Int64BitsToDouble(intValue - maxNumbersBetween);
@ -648,7 +648,7 @@ namespace MathNet.Numerics
{ {
// Int value is bigger than zero but smaller than the ulpsDifference. So we'll need to deal with // Int value is bigger than zero but smaller than the ulpsDifference. So we'll need to deal with
// the reversal at the negative end // the reversal at the negative end
#if SILVERLIGHT #if PORTABLE
bottomRangeEnd = Int64BitsToDouble(long.MinValue + (maxNumbersBetween - intValue)); bottomRangeEnd = Int64BitsToDouble(long.MinValue + (maxNumbersBetween - intValue));
#else #else
bottomRangeEnd = BitConverter.Int64BitsToDouble(long.MinValue + (maxNumbersBetween - intValue)); bottomRangeEnd = BitConverter.Int64BitsToDouble(long.MinValue + (maxNumbersBetween - intValue));
@ -1772,7 +1772,7 @@ namespace MathNet.Numerics
return double.NaN; return double.NaN;
} }
#if SILVERLIGHT #if PORTABLE
long signed64 = DoubleToInt64Bits(value); long signed64 = DoubleToInt64Bits(value);
#else #else
long signed64 = BitConverter.DoubleToInt64Bits(value); long signed64 = BitConverter.DoubleToInt64Bits(value);
@ -1781,7 +1781,7 @@ namespace MathNet.Numerics
if (signed64 == 0) if (signed64 == 0)
{ {
signed64++; signed64++;
#if SILVERLIGHT #if PORTABLE
return Int64BitsToDouble(signed64) - value; return Int64BitsToDouble(signed64) - value;
#else #else
return BitConverter.Int64BitsToDouble(signed64) - value; return BitConverter.Int64BitsToDouble(signed64) - value;
@ -1790,14 +1790,14 @@ namespace MathNet.Numerics
if (signed64-- < 0) if (signed64-- < 0)
{ {
#if SILVERLIGHT #if PORTABLE
return Int64BitsToDouble(signed64) - value; return Int64BitsToDouble(signed64) - value;
#else #else
return BitConverter.Int64BitsToDouble(signed64) - value; return BitConverter.Int64BitsToDouble(signed64) - value;
#endif #endif
} }
#if SILVERLIGHT #if PORTABLE
return value - Int64BitsToDouble(signed64); return value - Int64BitsToDouble(signed64);
#else #else
return value - BitConverter.Int64BitsToDouble(signed64); return value - BitConverter.Int64BitsToDouble(signed64);
@ -1826,7 +1826,7 @@ namespace MathNet.Numerics
return BitConverter.ToInt32(BitConverter.GetBytes(value), 0); return BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
} }
#if SILVERLIGHT #if PORTABLE
internal static long DoubleToInt64Bits(double value) internal static long DoubleToInt64Bits(double value)
{ {
return BitConverter.ToInt64(BitConverter.GetBytes(value), 0); return BitConverter.ToInt64(BitConverter.GetBytes(value), 0);

2
src/Numerics/Properties/Resources1.Designer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.488 // Runtime Version:4.0.30319.269
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

6
src/Numerics/Random/SystemCrypto.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2010 Math.NET // Copyright (c) 2009-2012 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -28,6 +28,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
#if !PORTABLE
namespace MathNet.Numerics.Random namespace MathNet.Numerics.Random
{ {
using System; using System;
@ -97,4 +98,5 @@ namespace MathNet.Numerics.Random
return BitConverter.ToUInt32(bytes, 0) * mReciprocal; return BitConverter.ToUInt32(bytes, 0) * mReciprocal;
} }
} }
} }
#endif

11
src/Numerics/SerializableAttribute.cs

@ -0,0 +1,11 @@
using System;
namespace MathNet.Numerics
{
#if PORTABLE
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class SerializableAttribute : Attribute
{
}
#endif
}

2
src/Numerics/Sorting.cs

@ -165,6 +165,7 @@ namespace MathNet.Numerics
throw new ArgumentNullException("comparer"); throw new ArgumentNullException("comparer");
} }
#if !PORTABLE
// array case // array case
var keysArray = keys as TKey[]; var keysArray = keys as TKey[];
var itemsArray = items as TItem[]; var itemsArray = items as TItem[];
@ -173,6 +174,7 @@ namespace MathNet.Numerics
Array.Sort(keysArray, itemsArray, comparer); Array.Sort(keysArray, itemsArray, comparer);
return; return;
} }
#endif
// local sort implementation // local sort implementation
QuickSort(keys, items, comparer, 0, keys.Count - 1); QuickSort(keys, items, comparer, 0, keys.Count - 1);

2
src/Numerics/Statistics/Histogram.cs

@ -41,7 +41,7 @@ namespace MathNet.Numerics.Statistics
/// </summary> /// </summary>
[Serializable] [Serializable]
public class Bucket : public class Bucket :
#if SILVERLIGHT #if PORTABLE
IComparable<Bucket> IComparable<Bucket>
#else #else
IComparable<Bucket>, ICloneable IComparable<Bucket>, ICloneable

626
src/Numerics/Threading/CommonParallel.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2011 Math.NET // Copyright (c) 2009-2012 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -31,10 +31,14 @@
namespace MathNet.Numerics.Threading namespace MathNet.Numerics.Threading
{ {
using System; using System;
using System.Threading.Tasks;
#if !SILVERLIGHT #if !PORTABLE
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Threading.Tasks; using System.Collections.Generic;
#else
using System.Linq;
using MathNet.Numerics.Properties;
#endif #endif
/// <summary> /// <summary>
@ -43,7 +47,7 @@ namespace MathNet.Numerics.Threading
public static class CommonParallel public static class CommonParallel
{ {
/// <summary> /// <summary>
/// Executes a for loop in which iterations may run in parallel. /// Executes a for loop in which iterations may run in parallel.
/// </summary> /// </summary>
/// <param name="fromInclusive">The start index, inclusive.</param> /// <param name="fromInclusive">The start index, inclusive.</param>
/// <param name="toExclusive">The end index, exclusive.</param> /// <param name="toExclusive">The end index, exclusive.</param>
@ -52,26 +56,11 @@ namespace MathNet.Numerics.Threading
/// <exception cref="AggregateException">At least one invocation of the body threw an exception.</exception> /// <exception cref="AggregateException">At least one invocation of the body threw an exception.</exception>
public static void For(int fromInclusive, int toExclusive, Action<int> body) public static void For(int fromInclusive, int toExclusive, Action<int> body)
{ {
var parallel = true; if (body == null)
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{ {
parallel = false; throw new ArgumentNullException("body");
} }
For(fromInclusive, toExclusive, body, parallel);
}
/// <summary>
/// Executes a for loop in which iterations may run in parallel.
/// </summary>
/// <param name="fromInclusive">The start index, inclusive.</param>
/// <param name="toExclusive">The end index, exclusive.</param>
/// <param name="body">The body to be invoked for each iteration.</param>
/// <param name="parallel">Use multiple threads.</param>
/// <exception cref="ArgumentNullException">The <paramref name="body"/> argument is <c>null</c>.</exception>
/// <exception cref="AggregateException">At least one invocation of the body threw an exception.</exception>
public static void For(int fromInclusive, int toExclusive, Action<int> body, bool parallel)
{
// Special case: no action // Special case: no action
if (fromInclusive >= toExclusive) if (fromInclusive >= toExclusive)
{ {
@ -85,286 +74,154 @@ namespace MathNet.Numerics.Threading
return; return;
} }
// Common case // Special case: straight execution without parallelism
if (parallel) if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{
#if SILVERLIGHT
Parallel.For(fromInclusive, toExclusive, body);
#else
Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions
{
MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads
},
(range, loopState) =>
{
for (var i = range.Item1; i < range.Item2; i++)
{
body(i);
}
});
#endif
}
else
{ {
for (var index = fromInclusive; index < toExclusive; index++) for (var index = fromInclusive; index < toExclusive; index++)
{ {
body(index); body(index);
} }
return;
} }
}
/* /// <summary> // Common case
/// Aggregates a function over a loop. #if PORTABLE
/// </summary> var tasks = new Task[Control.NumberOfParallelWorkerThreads];
/// <param name="fromInclusive">Starting index of the loop.</param> var size = (toExclusive - fromInclusive) / tasks.Length;
/// <param name="toExclusive">Ending index of the loop</param>
/// <param name="body">The function to aggregate.</param>
/// <returns>The sum of the function over the loop.</returns>
public static double Aggregate(int fromInclusive, int toExclusive, Func<int, double> body)
{
var sync = new object();
var sum = 0.0;
#if SILVERLIGHT
Parallel.For(
fromInclusive,
toExclusive,
() => 0.0,
(i, localData) => localData += body(i),
localResult =>
{
lock (sync)
{
sum += localResult;
}
});
#else
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) // partition the jobs into separate sets for each but the last worked thread
{ for (var i = 0; i < tasks.Length - 1; i++)
for (var index = fromInclusive; index < toExclusive; index++)
{
sum += body(index);
}
}
else
{ {
Parallel.ForEach( var start = fromInclusive + (i * size);
Partitioner.Create(fromInclusive, toExclusive), var stop = fromInclusive + ((i + 1) * size);
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
() => 0.0,
(range, loopState, localData) =>
{
for (var i = range.Item1; i < range.Item2; i++)
{
localData += body(i);
}
return localData; tasks[i] = Task.Factory.StartNew(() =>
},
localResult =>
{ {
lock (sync) for (int j = start; j < stop; j++)
{ {
sum += localResult; body(j);
} }
}); });
} }
#endif
return sum;
}
/// <summary> // add another set for last worker thread
/// Aggregates a function over a loop. tasks[tasks.Length - 1] = Task.Factory.StartNew(() =>
/// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param>
/// <param name="toExclusive">Ending index of the loop</param>
/// <param name="body">The function to aggregate.</param>
/// <returns>The sum of the function over the loop.</returns>
public static float Aggregate(int fromInclusive, int toExclusive, Func<int, float> body)
{
var sync = new object();
var sum = 0.0f;
#if SILVERLIGHT
Parallel.For(
fromInclusive,
toExclusive,
() => 0.0f,
(i, localData) => localData += body(i),
localResult =>
{ {
lock (sync) for (int j = fromInclusive + ((tasks.Length - 1) * size); j < toExclusive; j++)
{ {
sum += localResult; body(j);
} }
}); });
#else
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) Task.WaitAll(tasks);
{ #else
for (var index = fromInclusive; index < toExclusive; index++) Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions
{ {
sum += body(index); MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads
} },
} (range, loopState) =>
else {
{ for (var i = range.Item1; i < range.Item2; i++)
Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
() => 0.0f,
(range, loopState, localData) =>
{
for (var i = range.Item1; i < range.Item2; i++)
{
localData += body(i);
}
return localData;
},
localResult =>
{ {
lock (sync) body(i);
{ }
sum += localResult; });
}
});
}
#endif #endif
return sum;
} }
/// <summary> /// <summary>
/// Aggregates a function over a loop for Complex data type. /// Executes a for loop in which iterations may run in parallel.
/// </summary> /// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param> /// <param name="array">The array to iterate over.</param>
/// <param name="toExclusive">Ending index of the loop</param> /// <param name="body">The body to be invoked for each iteration.</param>
/// <param name="body">The function to aggregate.</param> /// <exception cref="ArgumentNullException">The <paramref name="body"/> argument is <c>null</c>.</exception>
/// <returns>The sum of the function over the loop.</returns> /// <exception cref="AggregateException">At least one invocation of the body threw an exception.</exception>
public static Complex Aggregate(int fromInclusive, int toExclusive, Func<int, Complex> body) public static void For<T>(T[] array, Action<int, T> body)
{ {
var sync = new object(); if (body == null)
var sum = Complex.Zero; {
throw new ArgumentNullException("body");
#if SILVERLIGHT }
Parallel.For(
fromInclusive, // Special case: no action
toExclusive, if (array == null || array.Length == 0)
() => Complex.Zero, {
(i, localData) => localData += body(i), return;
localResult => }
{
lock (sync)
{
sum += localResult;
}
});
#else
// Special case: single action, inline
if (array.Length == 0)
{
body(0, array[0]);
return;
}
// Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{ {
for (var index = fromInclusive; index < toExclusive; index++) // efficient since the compiler can drop the range checks
for (int i = 0; i < array.Length; i++)
{ {
sum += body(index); body(i, array[i]);
} }
return;
} }
else
// Common case
#if PORTABLE
var tasks = new Task[Control.NumberOfParallelWorkerThreads];
var size = array.Length / tasks.Length;
// partition the jobs into separate sets for each but the last worked thread
for (var i1 = 0; i1 < tasks.Length - 1; i1++)
{ {
Parallel.ForEach( var start = (i1 * size);
Partitioner.Create(fromInclusive, toExclusive), var stop = ((i1 + 1) * size);
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
() => Complex.Zero,
(range, loopState, localData) =>
{
for (var i = range.Item1; i < range.Item2; i++)
{
localData += body(i);
}
return localData; tasks[i1] = Task.Factory.StartNew(() =>
},
localResult =>
{ {
lock (sync) for (int j = start; j < stop; j++)
{ {
sum += localResult; body(j, array[j]);
} }
}); });
} }
#endif
return sum;
}
/// <summary> // add another set for last worker thread
/// Aggregates a function over a loop for Complex32 data type. tasks[tasks.Length - 1] = Task.Factory.StartNew(() =>
/// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param>
/// <param name="toExclusive">Ending index of the loop</param>
/// <param name="body">The function to aggregate.</param>
/// <returns>The sum of the function over the loop.</returns>
public static Complex32 Aggregate(int fromInclusive, int toExclusive, Func<int, Complex32> body)
{
var sync = new object();
var sum = Complex32.Zero;
#if SILVERLIGHT
Parallel.For(
fromInclusive,
toExclusive,
() => Complex32.Zero,
(i, localData) => localData += body(i),
localResult =>
{ {
lock (sync) for (int j = ((tasks.Length - 1) * size); j < array.Length; j++)
{ {
sum += localResult; body(j, array[j]);
} }
}); });
#else
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) Task.WaitAll(tasks);
{ #else
for (var index = fromInclusive; index < toExclusive; index++) Parallel.ForEach(
Partitioner.Create(0, array.Length),
new ParallelOptions
{ {
sum += body(index); MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads
} },
} (range, loopState) =>
else {
{ for (var i = range.Item1; i < range.Item2; i++)
Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
() => Complex32.Zero,
(range, loopState, localData) =>
{
for (var i = range.Item1; i < range.Item2; i++)
{
localData += body(i);
}
return localData;
},
localResult =>
{ {
lock (sync) body(i, array[i]);
{ }
sum += localResult; });
}
});
}
#endif #endif
return sum; }
}*/
/// <summary> /// <summary>
/// Executes each of the provided actions inside a discrete, asynchronous task. /// Executes each of the provided actions inside a discrete, asynchronous task.
/// </summary> /// </summary>
/// <param name="actions">An array of actions to execute.</param> /// <param name="actions">An array of actions to execute.</param>
/// <exception cref="ArgumentException">The actions array contains a <c>null</c> element.</exception> /// <exception cref="ArgumentException">The actions array contains a <c>null</c> element.</exception>
/// <exception cref="AggregateException">An action threw an exception.</exception> /// <exception cref="AggregateException">At least one invocation of the actions threw an exception.</exception>
public static void Invoke(params Action[] actions) public static void Invoke(params Action[] actions)
{ {
// Special case: no action // Special case: no action
@ -381,10 +238,21 @@ namespace MathNet.Numerics.Threading
} }
// Common case // Common case
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads; #if PORTABLE
#if SILVERLIGHT var tasks = new Task[actions.Length];
Parallel.Invoke(actions); for (var i = 0; i < tasks.Length; i++)
{
Action action = actions[i];
if (action == null)
{
throw new ArgumentException(String.Format(Resources.ArgumentItemNull, "actions"), "actions");
}
tasks[i] = Task.Factory.StartNew(action);
}
Task.WaitAll(tasks);
#else #else
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.Invoke( Parallel.Invoke(
new ParallelOptions new ParallelOptions
{ {
@ -399,105 +267,275 @@ namespace MathNet.Numerics.Threading
/// </summary> /// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param> /// <param name="fromInclusive">Starting index of the loop.</param>
/// <param name="toExclusive">Ending index of the loop</param> /// <param name="toExclusive">Ending index of the loop</param>
/// <param name="body">The function to select items over a subset.</param> /// <param name="select">The function to select items over a subset.</param>
/// <param name="localFinally">The function to select the item of selection from the subsets.</param> /// <param name="reduce">The function to select the item of selection from the subsets.</param>
/// <returns>The selected value.</returns> /// <returns>The selected value.</returns>
public static double Select(int fromInclusive, int toExclusive, Func<int, double, double> body, Func<double, double, double> localFinally) public static T Aggregate<T>(int fromInclusive, int toExclusive, Func<int, T> select, Func<T[], T> reduce)
{ {
double ret = 0; if (select == null)
var syncLock = new object(); {
throw new ArgumentNullException("select");
}
if (reduce == null)
{
throw new ArgumentNullException("reduce");
}
#if SILVERLIGHT // Special case: no action
Parallel.For( if (fromInclusive >= toExclusive)
fromInclusive, {
toExclusive, return reduce(new T[0]);
() => 0.0, }
(i, localData) => localData = body(i, localData),
localResult => // Special case: single action, inline
if (fromInclusive == (toExclusive - 1))
{
return reduce(new [] { select(fromInclusive) });
}
// Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{
var mapped = new T[toExclusive - fromInclusive];
for (int k = 0; k < mapped.Length; k++)
{ {
lock (syncLock) mapped[k] = select(k + fromInclusive);
}
return reduce(mapped);
}
#if PORTABLE
var tasks = new Task<T>[Control.NumberOfParallelWorkerThreads];
var size = (toExclusive - fromInclusive) / tasks.Length;
// partition the jobs into separate sets for each but the last worked thread
for (var i = 0; i < tasks.Length - 1; i++)
{
var start = fromInclusive + (i * size);
var stop = fromInclusive + ((i + 1) * size);
tasks[i] = Task.Factory.StartNew(() =>
{
var mapped = new T[stop - start];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k + start);
}
return reduce(mapped);
});
}
// add another set for last worker thread
tasks[tasks.Length - 1] = Task.Factory.StartNew(() =>
{
var start = fromInclusive + ((tasks.Length - 1) * size);
var mapped = new T[toExclusive - start];
for (int k = 0; k < mapped.Length; k++)
{ {
ret = localFinally(ret, localResult); mapped[k] = select(k + start);
} }
return reduce(mapped);
}); });
return Task.Factory
.ContinueWhenAll(tasks, tsk => reduce(tsk.Select(t => t.Result).ToArray()))
.Result;
#else #else
var intermediateResults = new List<T>();
var syncLock = new object();
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads; var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.ForEach( Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive), Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions { MaxDegreeOfParallelism = maxThreads }, new ParallelOptions { MaxDegreeOfParallelism = maxThreads },
() => 0.0, () => new List<T>(),
(range, loop, localData) => (range, loop, localData) =>
{ {
for (var i = range.Item1; i < range.Item2; i++) var mapped = new T[range.Item2 - range.Item1];
for (int k = 0; k < mapped.Length; k++)
{ {
localData = body(i, localData); mapped[k] = select(k + range.Item1);
} }
localData.Add(reduce(mapped));
return localData; return localData;
}, },
localResult => localResult =>
{ {
lock (syncLock) lock (syncLock)
{ {
ret = localFinally(ret, localResult); intermediateResults.Add(reduce(localResult.ToArray()));
} }
}); });
return reduce(intermediateResults.ToArray());
#endif #endif
}
return ret;
}
/// <summary> /// <summary>
/// Selects an item (such as Max or Min). /// Selects an item (such as Max or Min).
/// </summary> /// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param> /// <param name="array">The array to iterate over.</param>
/// <param name="toExclusive">Ending index of the loop</param> /// <param name="select">The function to select items over a subset.</param>
/// <param name="body">The function to select items over a subset.</param> /// <param name="reduce">The function to select the item of selection from the subsets.</param>
/// <param name="localFinally">The function to select the item of selection from the subsets.</param>
/// <returns>The selected value.</returns> /// <returns>The selected value.</returns>
public static float Select(int fromInclusive, int toExclusive, Func<int, float, float> body, Func<float, float, float> localFinally) public static U Aggregate<T, U>(T[] array, Func<int, T, U> select, Func<U[], U> reduce)
{ {
float ret = 0; if (select == null)
var syncLock = new object(); {
throw new ArgumentNullException("select");
}
if (reduce == null)
{
throw new ArgumentNullException("reduce");
}
#if SILVERLIGHT // Special case: no action
Parallel.For( if (array == null || array.Length == 0)
fromInclusive, {
toExclusive, return reduce(new U[0]);
() => 0.0f, }
(i, localData) => localData = body(i, localData),
localResult => // Special case: single action, inline
if (array.Length == 1)
{
return reduce(new[] { select(0, array[0]) });
}
// Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{
var mapped = new U[array.Length];
for (int k = 0; k < mapped.Length; k++)
{ {
lock (syncLock) mapped[k] = select(k, array[k]);
}
return reduce(mapped);
}
#if PORTABLE
var tasks = new Task<U>[Control.NumberOfParallelWorkerThreads];
var size = array.Length / tasks.Length;
// partition the jobs into separate sets for each but the last worked thread
for (var i = 0; i < tasks.Length - 1; i++)
{
var start = (i * size);
var stop = ((i + 1) * size);
tasks[i] = Task.Factory.StartNew(() =>
{
var mapped = new U[stop - start];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k + start, array[k + start]);
}
return reduce(mapped);
});
}
// add another set for last worker thread
tasks[tasks.Length - 1] = Task.Factory.StartNew(() =>
{
var start = ((tasks.Length - 1) * size);
var mapped = new U[array.Length - start];
for (int k = 0; k < mapped.Length; k++)
{ {
ret = localFinally(ret, localResult); mapped[k] = select(k + start, array[k + start]);
} }
return reduce(mapped);
}); });
return Task.Factory
.ContinueWhenAll(tasks, tsk => reduce(tsk.Select(t => t.Result).ToArray()))
.Result;
#else #else
var intermediateResults = new List<U>();
var syncLock = new object();
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads; var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.ForEach( Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive), Partitioner.Create(0, array.Length),
new ParallelOptions { MaxDegreeOfParallelism = maxThreads }, new ParallelOptions { MaxDegreeOfParallelism = maxThreads },
() => 0.0f, () => new List<U>(),
(range, loop, localData) => (range, loop, localData) =>
{ {
for (var i = range.Item1; i < range.Item2; i++) var mapped = new U[range.Item2 - range.Item1];
for (int k = 0; k < mapped.Length; k++)
{ {
localData = body(i, localData); mapped[k] = select(k + range.Item1, array[k + range.Item1]);
} }
localData.Add(reduce(mapped));
return localData; return localData;
}, },
localResult => localResult =>
{ {
lock (syncLock) lock (syncLock)
{ {
ret = localFinally(ret, localResult); intermediateResults.Add(reduce(localResult.ToArray()));
} }
}); });
return reduce(intermediateResults.ToArray());
#endif #endif
}
return ret; /// <summary>
/// Selects an item (such as Max or Min).
/// </summary>
/// <param name="fromInclusive">Starting index of the loop.</param>
/// <param name="toExclusive">Ending index of the loop</param>
/// <param name="select">The function to select items over a subset.</param>
/// <param name="reducePair">The function to select the item of selection from the subsets.</param>
/// <param name="reduceDefault">Default result of the reduce function on an empty set.</param>
/// <returns>The selected value.</returns>
public static T Aggregate<T>(int fromInclusive, int toExclusive, Func<int, T> select, Func<T, T, T> reducePair, T reduceDefault)
{
return Aggregate(fromInclusive, toExclusive, select, results =>
{
if (results == null || results.Length == 0)
{
return reduceDefault;
}
if (results.Length == 1)
{
return results[0];
}
T result = results[0];
for (int i = 1; i < results.Length; i++)
{
result = reducePair(result, results[i]);
}
return result;
});
}
/// <summary>
/// Selects an item (such as Max or Min).
/// </summary>
/// <param name="array">The array to iterate over.</param>
/// <param name="select">The function to select items over a subset.</param>
/// <param name="reducePair">The function to select the item of selection from the subsets.</param>
/// <param name="reduceDefault">Default result of the reduce function on an empty set.</param>
/// <returns>The selected value.</returns>
public static U Aggregate<T, U>(T[] array, Func<int, T, U> select, Func<U, U, U> reducePair, U reduceDefault)
{
return Aggregate(array, select, results =>
{
if (results == null || results.Length == 0)
{
return reduceDefault;
}
if (results.Length == 1)
{
return results[0];
}
U result = results[0];
for (int i = 1; i < results.Length; i++)
{
result = reducePair(result, results[i]);
}
return result;
});
} }
} }
} }

1028
src/Portable/Portable.csproj

File diff suppressed because it is too large

51
src/Silverlight/SilverlightUtilities.cs → src/Portable/Properties/AssemblyInfo.cs

@ -1,9 +1,9 @@
// <copyright file="SilverlightUtilities.cs" company="Math.NET"> // <copyright file="AssemblyInfo.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project // Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com // http://mathnet.opensourcedotnet.info
// http://github.com/mathnet/mathnet-numerics //
// http://mathnetnumerics.codeplex.com // Copyright (c) 2002-2012 Math.NET
// Copyright (c) 2009-2010 Math.NET //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -12,8 +12,10 @@
// copies of the Software, and to permit persons to whom the // copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following // Software is furnished to do so, subject to the following
// conditions: // conditions:
//
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -24,24 +26,21 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
namespace MathNet.Numerics using System;
{ using System.Reflection;
/// <summary> using System.Resources;
/// Contains methods missing from Silverlight. using System.Runtime.CompilerServices;
/// </summary>
public static class SilverlightUtilities [assembly: AssemblyTitle("Math.NET Numerics - Portable Edition")]
{ [assembly: AssemblyDescription("Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use.")]
/// <summary> [assembly: AssemblyConfiguration("")]
/// Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output parameter. [assembly: AssemblyCompany("Math.NET Project")]
/// </summary> [assembly: AssemblyProduct("Math.NET Numerics")]
/// <param name="a">The dividend.</param> [assembly: AssemblyCopyright("Copyright © Math.NET Project")]
/// <param name="b">The divisor.</param> [assembly: AssemblyTrademark("")]
/// <param name="result">The remainder.</param> [assembly: AssemblyCulture("")]
/// <returns>The quotient of the specified numbers.</returns> [assembly: CLSCompliant(true)]
public static long DivRem(long a, long b, out long result) [assembly: InternalsVisibleTo("SilverlightUnitTests")]
{ [assembly: NeutralResourcesLanguage("en")]
result = a % b; [assembly: AssemblyVersion("1.0.0.0")]
return a / b; [assembly: AssemblyFileVersion("1.0.0.0")]
}
}
}

2
src/Silverlight/Properties/AssemblyInfo.cs

@ -2,7 +2,7 @@
// Math.NET Numerics, part of the Math.NET Project // Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info // http://mathnet.opensourcedotnet.info
// //
// Copyright (c) 2009 Math.NET // Copyright (c) 2002-2012 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation

9
src/Silverlight/SerializableAttribute.cs

@ -1,9 +0,0 @@
using System;
namespace MathNet.Numerics
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class SerializableAttribute : Attribute
{
}
}

15
src/Silverlight/Silverlight.csproj

@ -44,7 +44,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\..\out\debug\SL4\</OutputPath> <OutputPath>..\..\out\debug\SL4\</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants> <DefineConstants>TRACE;DEBUG;SILVERLIGHT;PORTABLE</DefineConstants>
<NoStdLib>true</NoStdLib> <NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig> <NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
@ -106,6 +106,9 @@
<Compile Include="..\Numerics\Complex32.cs"> <Compile Include="..\Numerics\Complex32.cs">
<Link>Complex32.cs</Link> <Link>Complex32.cs</Link>
</Compile> </Compile>
<Compile Include="..\Numerics\Complex64.cs">
<Link>Complex64.cs</Link>
</Compile>
<Compile Include="..\Numerics\ComplexExtensions.cs"> <Compile Include="..\Numerics\ComplexExtensions.cs">
<Link>ComplexExtensions.cs</Link> <Link>ComplexExtensions.cs</Link>
</Compile> </Compile>
@ -976,6 +979,9 @@
<Compile Include="..\Numerics\Random\Xorshift.cs"> <Compile Include="..\Numerics\Random\Xorshift.cs">
<Link>Random\Xorshift.cs</Link> <Link>Random\Xorshift.cs</Link>
</Compile> </Compile>
<Compile Include="..\Numerics\SerializableAttribute.cs">
<Link>SerializableAttribute.cs</Link>
</Compile>
<Compile Include="..\Numerics\Signals\SignalGenerator.Chebyshev.cs"> <Compile Include="..\Numerics\Signals\SignalGenerator.Chebyshev.cs">
<Link>Signals\SignalGenerator.Chebyshev.cs</Link> <Link>Signals\SignalGenerator.Chebyshev.cs</Link>
</Compile> </Compile>
@ -1043,13 +1049,6 @@
<Link>Trigonometry.cs</Link> <Link>Trigonometry.cs</Link>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerializableAttribute.cs" />
<Compile Include="SilverlightUtilities.cs" />
<Compile Include="Threading\AggregateException.cs" />
<Compile Include="Threading\Parallel.cs" />
<Compile Include="Threading\Task.cs" />
<Compile Include="Threading\TaskOfT.cs" />
<Compile Include="Threading\ThreadQueue.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Numerics\Properties\Resources.resx"> <EmbeddedResource Include="..\Numerics\Properties\Resources.resx">

65
src/Silverlight/Threading/AggregateException.cs

@ -1,65 +0,0 @@
// <copyright file="AggregateException.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
// Copyright (c) 2009 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.Threading
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
/// <summary>
/// Represents multiple errors that occur during application execution.
/// </summary>
public class AggregateException : Exception
{
/// <summary>
/// List of the aggregated exceptions.
/// </summary>
private readonly IList<Exception> _exceptions = new List<Exception>();
/// <summary>
/// Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.
/// </summary>
/// <param name="exceptions">The exceptions that are the cause of the current exception.</param>
public AggregateException(IEnumerable<Exception> exceptions)
{
foreach (var exception in exceptions)
{
this._exceptions.Add(exception);
}
}
/// <summary>
/// Gets a read-only collection of the Exception instances that caused the current exception.
/// </summary>
/// <value>A read-only collection of the Exception instances that caused the current exception</value>
public ReadOnlyCollection<Exception> InnerExceptions
{
get
{
return new ReadOnlyCollection<Exception>(this._exceptions);
}
}
}
}

485
src/Silverlight/Threading/Parallel.cs

@ -1,485 +0,0 @@
// <copyright file="Parallel.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 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.Threading
{
using System;
using System.Collections.Generic;
using Properties;
/// <summary>
/// Provides support for parallel loops.
/// </summary>
internal static class Parallel
{
/// <summary>
/// The amount to scale the foreach buffer after each iteration.
/// </summary>
private const int ScalingFactor = 2;
/// <summary>
/// The maximum size of the foreach buffer.
/// </summary>
private const int MaxBlockSize = 65536;
/// <summary>
/// The initial size of the for each buffer.
/// </summary>
private const int IntialBlockSize = 1024;
/// <summary>
/// Executes a for loop in which iterations may run in parallel.
/// </summary>
/// <param name="fromInclusive">The start index, inclusive.</param>
/// <param name="toExclusive">The end index, exclusive.</param>
/// <param name="body">The body to be invoked for each iteration.</param>
/// <exception cref="ArgumentNullException">The <paramref name="body"/> argument is null.</exception>
/// <exception cref="AggregateException">At least one invocation of the body threw an exception.</exception>
public static void For(int fromInclusive, int toExclusive, Action<int> body)
{
if (body == null)
{
throw new ArgumentNullException("body");
}
// fast forward execution if it's only one or none items
var count = toExclusive - fromInclusive;
if (count <= 1)
{
if (count == 1)
{
body(fromInclusive);
}
return;
}
// fast forward execution in case parallelization is disabled
if (Control.DisableParallelization
|| ThreadQueue.ThreadCount <= 1
|| ThreadQueue.IsInWorkerThread)
{
for (int i = fromInclusive; i < toExclusive; i++)
{
body(i);
}
return;
}
var actions = new Action[ThreadQueue.ThreadCount];
var size = count / actions.Length;
// partition the jobs into separate sets for each but the last worked thread
for (var i = 0; i < actions.Length - 1; i++)
{
var start = fromInclusive + (i * size);
var stop = fromInclusive + ((i + 1) * size);
actions[i] =
() =>
{
for (int j = start; j < stop; j++)
{
body(j);
}
};
}
// add another set for last worker thread
actions[actions.Length - 1] =
() =>
{
for (int i = fromInclusive + ((actions.Length - 1) * size); i < toExclusive; i++)
{
body(i);
}
};
Invoke(actions);
}
/// <summary>
/// Executes a for loop in which iterations may run in parallel.
/// </summary>
/// <typeparam name="T">The type of the thread-local data.</typeparam>
/// <param name="fromInclusive">The start index, inclusive.</param>
/// <param name="toExclusive">The end index, exclusive.</param>
/// <param name="localInit">The function delegate that returns the initial state of the local data for each thread.</param>
/// <param name="body">The delegate that is invoked once per iteration.</param>
/// <param name="localFinally">The delegate that performs a final action on the local state of each thread.</param>
public static void For<T>(int fromInclusive, int toExclusive, Func<T> localInit, Func<int, T, T> body, Action<T> localFinally)
{
var count = toExclusive - fromInclusive;
var tasks = new Task<T>[ThreadQueue.ThreadCount];
var size = count / tasks.Length;
// fast forward execution if it's only one or none items
if (count <= 1)
{
if (count == 1)
{
localFinally(body(fromInclusive, localInit()));
}
return;
}
// fast forward execution in case parallelization is disabled
if (Control.DisableParallelization
|| ThreadQueue.ThreadCount <= 1
|| ThreadQueue.IsInWorkerThread)
{
var localresult = localInit();
for (var i = fromInclusive; i < toExclusive; i++)
{
localresult = body(i, localresult);
}
localFinally(localresult);
return;
}
// partition the jobs into separate sets for each but the last worked thread
for (var i = 0; i < tasks.Length - 1; i++)
{
var start = fromInclusive + (i * size);
var stop = fromInclusive + ((i + 1) * size);
tasks[i] = new Task<T>(
localData =>
{
var localresult = (T)localData;
for (var j = start; j < stop; j++)
{
localresult = body(j, localresult);
}
return localresult;
},
localInit());
ThreadQueue.Enqueue(tasks[i]);
}
// add another set for last worker thread
tasks[tasks.Length - 1] = new Task<T>(
localData =>
{
var localresult = (T)localData;
for (var i = fromInclusive + ((tasks.Length - 1) * size); i < toExclusive; i++)
{
localresult = body(i, localresult);
}
return localresult;
},
localInit());
ThreadQueue.Enqueue(tasks[tasks.Length - 1]);
if (tasks.Length <= 0)
{
return;
}
WaitForTasksToComplete(tasks);
foreach (var t in tasks)
{
localFinally(t.Result);
}
CollectExceptions(tasks);
}
/// <summary>
/// Executes a for each operation on an IEnumerable{T} in which iterations may run in parallel.
/// </summary>
/// <typeparam name="T">The type of the data in the source.</typeparam>
/// <param name="source">An enumerable data source.</param>
/// <param name="body">The delegate that is invoked once per iteration.</param>
public static void ForEach<T>(IEnumerable<T> source, Action<T> body)
{
if (body == null)
{
throw new ArgumentNullException("body");
}
// fast forward execution in case parallelization is disabled
if (Control.DisableParallelization
|| ThreadQueue.ThreadCount <= 1
|| ThreadQueue.IsInWorkerThread)
{
foreach (var item in source)
{
body(item);
}
return;
}
// source is a IList, call For instead.
if (source is IList<T>)
{
var list = (IList<T>)source;
For(0, list.Count, i => body(list[i]));
return;
}
var maxBlockSize = IntialBlockSize;
var tasks = new List<Task>();
var enumerator = source.GetEnumerator();
while (enumerator.MoveNext())
{
var pos = 0;
var list = new T[maxBlockSize];
list[pos++] = enumerator.Current;
var count = 1;
while (count < maxBlockSize && enumerator.MoveNext())
{
list[pos++] = enumerator.Current;
count++;
}
var task = new Task(
() =>
{
for (var i = 0; i < pos; i++)
{
body(list[i]);
}
});
ThreadQueue.Enqueue(task);
tasks.Add(task);
maxBlockSize = Math.Min(MaxBlockSize, maxBlockSize * ScalingFactor);
}
if (tasks.Count > 0)
{
WaitForTasksToComplete(tasks.ToArray());
CollectExceptions(tasks);
}
}
/// <summary>
/// Executes a for each operation on an IEnumerable{TSource in which iterations may run in parallel.
/// </summary>
/// <typeparam name="TSource">The type of the data in the source.</typeparam>
/// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
/// <param name="source">An enumerable data source.</param>
/// <param name="localInit">The function delegate that returns the initial state of the local data for each thread.</param>
/// <param name="body">The delegate that is invoked once per iteration.</param>
/// <param name="localFinally">The delegate that performs a final action on the local state of each thread.</param>
public static void ForEach<TSource, TLocal>(IEnumerable<TSource> source, Func<TLocal> localInit, Func<TSource, TLocal, TLocal> body, Action<TLocal> localFinally)
{
if (body == null)
{
throw new ArgumentNullException("body");
}
// fast forward execution in case parallelization is disabled
if (Control.DisableParallelization
|| ThreadQueue.ThreadCount <= 1
|| ThreadQueue.IsInWorkerThread)
{
var localResult = localInit();
foreach (var item in source)
{
localResult = body(item, localResult);
}
localFinally(localResult);
return;
}
// source is a IList, call For instead.
if (source is IList<TSource>)
{
var list = (IList<TSource>)source;
For(0, list.Count, localInit, (i, local) => body(list[i], local), localFinally);
return;
}
var maxBlockSize = IntialBlockSize;
var tasks = new List<Task<TLocal>>();
var enumerator = source.GetEnumerator();
while (enumerator.MoveNext())
{
var pos = 0;
var list = new TSource[maxBlockSize];
list[pos++] = enumerator.Current;
var count = 1;
while (count < maxBlockSize && enumerator.MoveNext())
{
list[pos++] = enumerator.Current;
count++;
}
var task = new Task<TLocal>(
localData =>
{
var localresult = localData;
for (var i = 0; i < pos; i++)
{
localresult = body(list[i], (TLocal)localresult);
}
return (TLocal)localresult;
},
localInit());
ThreadQueue.Enqueue(task);
tasks.Add(task);
maxBlockSize = Math.Min(MaxBlockSize, maxBlockSize * ScalingFactor);
}
if (tasks.Count <= 0)
{
return;
}
var taskArray = tasks.ToArray();
WaitForTasksToComplete(taskArray);
for (var i = 0; i < taskArray.Length; i++)
{
localFinally(tasks[i].Result);
}
CollectExceptions(taskArray);
}
/// <summary>
/// Executes each of the provided actions inside a discrete, asynchronous task.
/// </summary>
/// <param name="actions">An array of actions to execute.</param>
/// <exception cref="ArgumentNullException">The <paramref name="actions"/> argument is null.</exception>
/// <exception cref="ArgumentException">The actions array contains a null element.</exception>
/// <exception cref="AggregateException">An action threw an exception.</exception>
public static void Run(params Action[] actions)
{
if (actions == null)
{
throw new ArgumentNullException("actions");
}
// fast forward execution if it's only one or none items
if (actions.Length <= 1)
{
if (actions.Length == 1)
{
actions[0]();
}
return;
}
// fast forward execution in case parallelization is disabled
if (Control.DisableParallelization
|| ThreadQueue.ThreadCount <= 1
|| ThreadQueue.IsInWorkerThread)
{
for (var i = 0; i < actions.Length; i++)
{
actions[i]();
}
return;
}
Invoke(actions);
}
/// <summary>
/// Executes each of the provided actions inside a discrete, asynchronous task.
/// </summary>
/// <param name="actions">An array of actions to execute.</param>
/// <exception cref="ArgumentException">The actions array contains a null element.</exception>
/// <exception cref="AggregateException">An action threw an exception.</exception>
internal static void Invoke(params Action[] actions)
{
// create a job for each action
var tasks = new Task[actions.Length];
for (var i = 0; i < tasks.Length; i++)
{
Action action = actions[i];
if (action == null)
{
throw new ArgumentException(String.Format(Resources.ArgumentItemNull, "actions"), "actions");
}
tasks[i] = new Task(action);
}
// run the jobs
ThreadQueue.Enqueue(tasks);
WaitForTasksToComplete(tasks);
CollectExceptions(tasks);
}
/// <summary>
/// Waits for tasks to complete.
/// </summary>
/// <param name="tasks">The tasks.</param>
private static void WaitForTasksToComplete(Task[] tasks)
{
foreach (var task in tasks)
{
task.Wait();
}
}
/// <summary>
/// Collects the exceptions and dispose tasks.
/// </summary>
/// <param name="tasks">The tasks.</param>
private static void CollectExceptions(IEnumerable<Task> tasks)
{
// collect all thrown exceptions and dispose the jobs
var exceptions = new List<Exception>();
foreach (var task in tasks)
{
if (task.IsFaulted)
{
exceptions.Add(task.Exception);
}
}
// throw the aggregated exceptions, if any
if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
}
}
}

128
src/Silverlight/Threading/Task.cs

@ -1,128 +0,0 @@
// <copyright file="Task.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 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.Threading
{
using System;
using System.Threading;
/// <summary>
/// Internal Parallel Task Handle.
/// </summary>
internal class Task
{
/// <summary>
/// Delegate to the task's action.
/// </summary>
private readonly System.Action _body;
/// <summary>
/// Initializes a new instance of the Task class.
/// </summary>
/// <param name="body">Delegate to the task's action.</param>
public Task(Action body)
{
if (body == null)
{
throw new ArgumentNullException("body");
}
_body = body;
}
/// <summary>
/// Initializes a new instance of the <see cref="Task"/> class.
/// </summary>
protected Task()
{
}
/// <summary>
/// Gets a value indicating whether the task completed due to an unhandled exception.
/// </summary>
/// <value>
/// <c>true</c> if this task completed due to an unhandled exception; otherwise, <c>false</c>.
/// </value>
public bool IsFaulted
{
get { return Exception != null; }
}
/// <summary>
/// Gets a value indicating whether this task has completed.
/// </summary>
/// <value>
/// <c>true</c> if this task has completed; otherwise, <c>false</c>.
/// </value>
public bool IsCompleted
{
get;
private set;
}
/// <summary>
/// Gets or sets the exception thrown by the task, if any.
/// </summary>
public Exception Exception { get; set; }
/// <summary>
/// Run the task.
/// </summary>
public void Compute()
{
try
{
DoCompute();
IsCompleted = true;
}
catch (Exception e)
{
Exception = e;
}
}
/// <summary>
/// Runs the actual task.
/// </summary>
protected virtual void DoCompute()
{
_body();
}
/// <summary>
/// Waits for the task to complete execution.
/// </summary>
public void Wait()
{
while (!IsCompleted && !IsFaulted)
{
Thread.Sleep(0);
}
}
}
}

79
src/Silverlight/Threading/TaskOfT.cs

@ -1,79 +0,0 @@
// <copyright file="TaskOfT.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 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.Threading
{
using System;
/// <summary>
/// Internal Generic Parallel Task Handle.
/// </summary>
/// <typeparam name="TResult">The type of the result.</typeparam>
internal class Task<TResult> : Task
{
/// <summary>
/// Delegate to the task's action.
/// </summary>
private readonly Func<object, TResult> _body;
/// <summary>
/// Variable used to hold state information between iterations.
/// </summary>
private readonly object _state;
/// <summary>
/// Gets the result of the task.
/// </summary>
/// <value>The result of the task.</value>
public TResult Result { get; private set; }
/// <summary>
/// Initializes a new instance of the Task class.
/// </summary>
/// <param name="body">Delegate to the task's action.</param>
/// <param name="state">An object representing data to be used by the action.</param>
public Task(Func<object, TResult> body, object state)
{
if (body == null)
{
throw new ArgumentNullException("body");
}
_state = state;
_body = body;
}
/// <summary>
/// Runs the actual task.
/// </summary>
protected override void DoCompute()
{
Result = _body(_state);
}
}
}

258
src/Silverlight/Threading/ThreadQueue.cs

@ -1,258 +0,0 @@
// <copyright file="ThreadQueue.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 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.Threading
{
using System;
using System.Collections.Generic;
using System.Threading;
/// <summary>
/// Internal Parallel Thread Queue.
/// </summary>
internal static class ThreadQueue
{
/// <summary>
/// Sync Object for the thread queue state.
/// </summary>
private static readonly object _stateSync = new object();
/// <summary>
/// Sync Object for queue access (to be sure it's used by us only).
/// </summary>
private static readonly object _queueSync = new object();
/// <summary>
/// Queue holding the pending jobs.
/// </summary>
private static readonly Queue<Task> _queue = new Queue<Task>();
/// <summary>
/// Running flag, used to signal worker threads to stop cleanly.
/// </summary>
private static bool _running = true;
/// <summary>
/// Worker threads
/// </summary>
private static Thread[] _threads;
/// <summary>
/// Gets the number of worker threads.
/// </summary>
internal static int ThreadCount { get; private set; }
/// <summary>
/// Indicating whether the current thread is a parallelized worker thread.
/// </summary>
[ThreadStatic]
private static bool _isInWorkerThread;
/// <summary>
/// Initializes static members of the ThreadQueue class.
/// </summary>
static ThreadQueue()
{
Start(1);
}
/// <summary>
/// Gets a value indicating whether the current thread is a parallelized worker thread.
/// </summary>
public static bool IsInWorkerThread
{
get { return _isInWorkerThread; }
}
/// <summary>
/// Add a job to the queue.
/// </summary>
/// <param name="task">The job to run.</param>
public static void Enqueue(Task task)
{
if (!_running)
{
Start();
}
lock (_queueSync)
{
_queue.Enqueue(task);
Monitor.Pulse(_queueSync);
}
}
/// <summary>
/// Add a set of jobs to the queue.
/// </summary>
/// <param name="tasks">The jobs to run.</param>
public static void Enqueue(IList<Task> tasks)
{
if (!_running)
{
Start();
}
lock (_queueSync)
{
foreach (var task in tasks)
{
_queue.Enqueue(task);
}
Monitor.PulseAll(_queueSync);
}
}
/// <summary>
/// Worker Thread Program
/// </summary>
private static void WorkerThreadStart()
{
_isInWorkerThread = true;
while (_running)
{
// Get the job...
Task task = null;
lock (_queueSync)
{
// Check whether we should shut down
if (!_running)
{
break;
}
if (_queue.Count > 0)
{
task = _queue.Dequeue();
}
else
{
Monitor.Wait(_queueSync);
}
}
if (task == null)
{
continue;
}
// ...and run it
task.Compute();
}
_isInWorkerThread = false;
}
/// <summary>
/// Start or restart the queue with the specified number of worker threads.
/// </summary>
/// <param name="numberOfThreads">Number of worker threads.</param>
public static void Start(int numberOfThreads)
{
lock (_stateSync)
{
// instead of throwing an out of range exception, simply normalize
numberOfThreads = Math.Max(1, Math.Min(1024, numberOfThreads));
if (_threads != null)
{
if (_threads.Length == numberOfThreads)
{
return;
}
Shutdown();
}
ThreadCount = numberOfThreads;
Start();
}
}
/// <summary>
/// Start the thread queue, if it is not already running.
/// </summary>
public static void Start()
{
lock (_stateSync)
{
if (_threads != null)
{
return;
}
_running = true;
_threads = new Thread[ThreadCount];
for (var i = 0; i < _threads.Length; i++)
{
_threads[i] = new Thread(WorkerThreadStart)
{
IsBackground = true
};
_threads[i].Start();
}
}
}
/// <summary>
/// Stop the thread queue, if it is running.
/// </summary>
public static void Shutdown()
{
// try to stop the worker threads cleanly
lock (_stateSync)
{
if (_threads == null)
{
return;
}
_running = false;
lock (_queueSync)
{
Monitor.PulseAll(_queueSync);
}
// wait until all threads have stopped
foreach (var thread in _threads)
{
thread.Join();
}
_threads = null;
}
}
}
}

4
src/UnitTests/ArrayHelpers.cs

@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests
/// <returns>An array of the target type containing the converted elements from the source array.</returns> /// <returns>An array of the target type containing the converted elements from the source array.</returns>
public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput, TOutput> converter) public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput, TOutput> converter)
{ {
#if SILVERLIGHT #if PORTABLE
if (array == null) if (array == null)
throw new ArgumentException(); throw new ArgumentException();
@ -55,7 +55,7 @@ namespace MathNet.Numerics.UnitTests
#endif #endif
} }
#if SILVERLIGHT #if PORTABLE
/// <summary> /// <summary>
/// Determines whether the specified array contains elements that match the conditions defined by the specified predicate. /// Determines whether the specified array contains elements that match the conditions defined by the specified predicate.
/// </summary> /// </summary>

4
src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
a.ToString()); a.ToString());
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Can format complex to string with culture. /// Can format complex to string with culture.
/// </summary> /// </summary>
@ -245,7 +245,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
Assert.AreEqual(float.MinValue, z.Imaginary, "E3"); Assert.AreEqual(float.MinValue, z.Imaginary, "E3");
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Try parse can handle symbols with a culture. /// Try parse can handle symbols with a culture.
/// </summary> /// </summary>

2
src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs

@ -147,7 +147,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
Assert.AreEqual(double.MinValue, z.Imaginary, "E3"); Assert.AreEqual(double.MinValue, z.Imaginary, "E3");
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Try parse can handle symbols with a culture. /// Try parse can handle symbols with a culture.
/// </summary> /// </summary>

2
src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs

@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="culture">Culture name.</param> /// <param name="culture">Culture name.</param>
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")]
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")]
#if !SILVERLIGHT #if !PORTABLE
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")]
#endif #endif
public void CanParseComplexDenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) public void CanParseComplexDenseVectorsWithCulture(string stringToParse, string expectedToString, string culture)

2
src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs

@ -33,7 +33,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
using LinearAlgebra.Complex; using LinearAlgebra.Complex;
using NUnit.Framework; using NUnit.Framework;
#if SILVERLIGHT #if PORTABLE
using Threading; using Threading;
#endif #endif

2
src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="culture">Culture name.</param> /// <param name="culture">Culture name.</param>
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")]
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")]
#if !SILVERLIGHT #if !PORTABLE
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")]
#endif #endif
public void CanParseComplexSparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) public void CanParseComplexSparseVectorsWithCulture(string stringToParse, string expectedToString, string culture)

2
src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
CollectionAssert.AreEqual(vector, clone); CollectionAssert.AreEqual(vector, clone);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Can clone a vector using <c>IClonable</c> interface method. /// Can clone a vector using <c>IClonable</c> interface method.
/// </summary> /// </summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs

@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="culture">Culture name.</param> /// <param name="culture">Culture name.</param>
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")]
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")]
#if !SILVERLIGHT #if !PORTABLE
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")]
#endif #endif
public void CanParseComplex32DenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) public void CanParseComplex32DenseVectorsWithCulture(string stringToParse, string expectedToString, string culture)

2
src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs

@ -33,7 +33,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
using NUnit.Framework; using NUnit.Framework;
using Complex32 = Numerics.Complex32; using Complex32 = Numerics.Complex32;
#if SILVERLIGHT #if PORTABLE
using Threading; using Threading;
#endif #endif

2
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs

@ -237,7 +237,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors // Now compare the vectors
for (var i = 0; i < y.Count; i++) for (var i = 0; i < y.Count; i++)
{ {
#if !SILVERLIGHT #if !PORTABLE
Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i); Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
#else #else
Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary * 10.0f, 1), "#05-" + i); Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary * 10.0f, 1), "#05-" + i);

2
src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="culture">Culture name.</param> /// <param name="culture">Culture name.</param>
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")]
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")]
#if !SILVERLIGHT #if !PORTABLE
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")]
#endif #endif
public void CanParseComplex32SparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) public void CanParseComplex32SparseVectorsWithCulture(string stringToParse, string expectedToString, string culture)

2
src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
CollectionAssert.AreEqual(vector, clone); CollectionAssert.AreEqual(vector, clone);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Can clone a vector using <c>IClonable</c> interface method. /// Can clone a vector using <c>IClonable</c> interface method.
/// </summary> /// </summary>

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

@ -33,7 +33,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
using LinearAlgebra.Generic; using LinearAlgebra.Generic;
using NUnit.Framework; using NUnit.Framework;
#if SILVERLIGHT #if PORTABLE
using Threading; using Threading;
#endif #endif

2
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs

@ -237,7 +237,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors // Now compare the vectors
for (var i = 0; i < y.Count; i++) for (var i = 0; i < y.Count; i++)
{ {
#if !SILVERLIGHT #if !PORTABLE
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
#else #else
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);

2
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs

@ -239,7 +239,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors // Now compare the vectors
for (var i = 0; i < y.Count; i++) for (var i = 0; i < y.Count; i++)
{ {
#if !SILVERLIGHT #if !PORTABLE
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
#else #else
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);

2
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs

@ -238,7 +238,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors // Now compare the vectors
for (var i = 0; i < y.Count; i++) for (var i = 0; i < y.Count; i++)
{ {
#if !SILVERLIGHT #if !PORTABLE
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
#else #else
Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);

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

@ -58,7 +58,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
CollectionAssert.AreEqual(vector, clone); CollectionAssert.AreEqual(vector, clone);
} }
#if !SILVERLIGHT #if !PORTABLE
/// <summary> /// <summary>
/// Can clone a vector using <c>IClonable</c> interface method. /// Can clone a vector using <c>IClonable</c> interface method.
/// </summary> /// </summary>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save