This project has moved. For the latest updates, please go here.

Use with Visual Studio 2008?

Mar 10, 2013 at 2:23 PM
Edited Mar 11, 2013 at 10:22 AM
Is this possible to create a .NET 3.5 compliant binary of Math.NET to be used with older versions of .NET projects?

Or at least, is this possible to create a branch of Math.NET and reduce its functionality to be compiled under .NET 3.5 (e.g. by removing support for complex numbers, etc. or by replacing them with class libraries that don't rely on System.Numerics, etc.)?
Coordinator
Mar 13, 2013 at 9:59 AM
We officially do not support .Net below 4.0 right now, but it should be possible. In fact, most of the missing pieces are already there for the portable library build (where we do not have System.Numerics and full TPL either).

I myself have no time (nor personal interest to be honest, as I don't see the point of using .Net 3.5 in 2013) to work on a special build for .Net 3.5, but if someone finds the time to make it work in a simple way I'd be more than happy to integrate it into mainline and start producing official .Net 3.5 builds in the future.
Marked as answer by cdrnet on 10/3/2013 at 5:46 PM
Nov 29, 2013 at 2:06 PM
I had been using Mathnet.Numerics for a personal project, now I have need to use a library I'd made using it in Unity3D, which uses Mono 2.6 (I believe), and does not have .Net 4.0 support.

I have been able to make it work with .Net 3.5 as targeted framework.
  • Using the NOSYSNUMERICS and PORTABLE defines
  • Implementing IEnumerable.Zip, Tuple<T1, T2> and Tuple<T1, T2, T3> as well as Lazy<T> (For all of which I found implementations on StackOverflow) in the MathNet.Numerics namespace
  • Commenting out some TargetedPatchingOptOut attributes, which hopefully I can live without.
  • Using http://www.nuget.org/packages/TaskParallelLibrary to replace the Task class for the Parallel class.
  • Removing some string parsing that relied on Culture
  • And commenting out the Fit class as I wasn't using it anyway, though presumably someone who cared could make that comply also.
There might have been one or two other minor things but those were the main points. Literally just finished doing it and got it working with the library a few minutes ago. I don't know if it'll be perfect, there might be issues with that old threading library, and some of the things implemented might not be as robust or optimised as the system alternatives, but it compiles, runs, and for my use it seems to find Eigenvalues more reliably than other natively .net 3.5 compliant matrix libraries I've tried.
Coordinator
Nov 29, 2013 at 2:48 PM
Thanks for working this out! I wonder whether we can integrate this to mainline just like we integrate the portable builds, e.g. by defining a new compiler symbol "NET35" to conditionally include this changes + conditionally add the missing tuples, lazy and the missing attribute, and enable that symbol in a second csproj "Numerics-Net35.csproj" (similar to "Numerics-Portable47.csproj")?
Nov 29, 2013 at 4:31 PM
Certainly sounds possible, it only took me an hour or so to do.

It's a great library with a wonderful mix of reliability and license. I'm using it to find eigenvalues from a chebyshev approximation to detect close passes of spacecraft and planets as well as solving Newton's Method for a hobby game. Other libraries I tried either offered less or more inconvenient matrix operations, or gave unreliable results or in one case, would sometimes get caught in an infinite loop. I'm glad I was able to get it working with .net 3.5 (though I'd prefer if Unity3D supported 4.0).

You'd need to include that threading reference as well as just defining a symbol in the alternate csproj, but that should be fine. It's basically a library from an old version of Reactive Extensions that someone has bundled into a nuget package.

The classes I added are here http://pastebin.com/ZCJHphPm, all found on Stack Overflow, might be able to be improved for their particular use, haven't really looked at them closely.

The library used for the TPL is http://www.nuget.org/packages/TaskParallelLibrary

Anything else just showed up on the error list.

Hope that's of some help, and I would certainly appreciate an official release for 3.5 so I can get any improvements you make, and I'm sure there are others out there that would find it useful.
Nov 30, 2013 at 5:20 AM
The official release for .NET 3.5 would be great as it was such a widely used framework which many applications/source codes still rely on, specially those that can't be upgraded due to the usage of custom proprietary components which only works under .NET 3.5.
Coordinator
Dec 5, 2013 at 9:37 AM
Edited Dec 5, 2013 at 9:38 AM
There is now a new Numerics-Net35 (and UnitTests-Net35) project, part of the portable solution. It compiles and the tests run, but there are still a few things to improve. Nevertheless, there might indeed be an official .Net 3.5 build of the core library starting from the next alpha.

TODO:
  • Make better use of the TaskParallelLibrary package in CommonParallel.cs (currently it uses the same code path as portable, which does not use the Parallel class)
  • The MathNet.Numerics.Portable solution probably won't open properly in old Visual Studio (say 2008). Provide a proper MathNet.Numerics.Net35 solution instead.
  • Consider to make the unit tests compile against .Net 3.5 as well if possible (not trivial, as it does use dynamic types - and we do NOT want to maintain a separate test set)