-
Notifications
You must be signed in to change notification settings - Fork 925
Upgrading to Version 3
Math.NET Numerics has grown and matured remarkably since the first release of its second major version (v2). But we also made a few unfortunate design choices over the years, and replaced early functionality with something that works better. We fixed most of these in the third major version, v3. Unfortunately this required a few breaking changes.
If you prefer not to upgrade to v3 just yet, that's fine. If needed we can back-port some bug fixes to the v2 branch. However, we will not add any new features to the old v2 branch and recommend to upgrade if feasible.
Almost all of the breaking changes are very simple to fix in user code, but they do need to be fixed. We intend to collect common migration steps and tips here on this wiki page; feedback is welcome.
For a list of all the changes, see release notes.
- All the
.Algorithms
namespaces have been dropped. Fix: remove the Algorithm part. - The Linear Algebra
.Generic
namespace was removed. Fix: use the parent namespaceMathNet.Numerics.LinearAlgebra
instead.
- We recommend to always declare matrix and vector variables with the generic root type, e.g.
Matrix<double>
. You'll never have to cast between different types within the type hierarchy again. - There is now a generic way to create matrices and vectors using the builder class. For example,
Vector<double>.Build.Random(10)
creates a random dense vector of the length 10. Tip: since you often only work with one data type, e.g. doubles, consider declaringvar M = Matrix<double>.Build;
. Creating a diagonal identity matrix of order 4 then simply becomesM.DiagonalIdentity(4);
. - There is usually no need to open the type specific namespaces, unless you want to use their static functions to create instances.