NonLinearEquationsSolver
NonLinearEquationsSolver copied to clipboard
Remove Math.Net dependency
@EduardBargues Removing the Math.NET dependency would be great. You could either use arrays like CSparse.NET (see Vector helper class) or implement a simple vector type which wraps a double array.
@epsi1on The ILinearSolver allows to choose whichever matrix implementation you like and the goal is to be completely independend of any third party library.
EDIT: introducing an array pool is a good idea, but might not be necessary. To eliminate the cloning of the array in the example code above, the Corrector would need to have a working array of the appropriate size (which could be initialized when the NonLinearSolver is built):
// equilibrium array/vector is a class member info.InitialLoad.CopyTo(equilibrium); equilibrium.Add(newState.Lambda, info.ReferenceLoad, equilibrium); equilibrium.Add(-1.0, reaction, equilibrium);
I think you can remove Math.Net dependency with two approaches as @wo80 mentioned. First is a wrapper around double[]
array which works same as Vector<double>
in Math.NET, second is use double[]
instead of Vector<double>
.
yeah, Ill have a look which one is the best :) !! Pull-request is comming :P !
I'd suggest to use arrays and keep the implementation private. To optimize performance, you could then introduce very specific functions like
static class VectorHelper
{
/// <summary>
/// target = v + scalew * w + scalez * z.
/// </summary>
public static void Add(int n, double[] v, double scalew, double[] w, double scalez, double[] z, double[] target)
{
for (int i = 0; i < n; i++)
{
target[i] = v[i] + scalew * w[i] + scalez * z[i];
}
}
}
The above example equation would then be written as
using static VectorHelper;
// equilibrium = info.InitialLoad + newState.Lambda * info.ReferenceLoad - reaction;
Add(equilibrium.Length, info.InitialLoad, newState.Lambda, info.ReferenceLoad, -1.0, reaction, equilibrium);
Hello, If you did not start yet, i can do and create a pull request?
Thanks
Sure!! Im on vacations and wont start untill next week
Hey @epsi1on ! Did you manage to do something? If not I can work on that. Have a good day!
Hi, Didn't start yet Thanks