Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Math.Net dependency #7

Open
EduardBargues opened this issue Aug 9, 2020 · 7 comments
Open

Remove Math.Net dependency #7

EduardBargues opened this issue Aug 9, 2020 · 7 comments

Comments

@EduardBargues
Copy link
Owner

@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);

@epsi1on
Copy link
Collaborator

epsi1on commented Aug 10, 2020

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>.

@EduardBargues
Copy link
Owner Author

yeah, Ill have a look which one is the best :) !! Pull-request is comming :P !

@wo80
Copy link
Collaborator

wo80 commented Aug 10, 2020

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);

@epsi1on
Copy link
Collaborator

epsi1on commented Aug 26, 2020

Hello,
If you did not start yet, i can do and create a pull request?

Thanks

@EduardBargues
Copy link
Owner Author

Sure!! Im on vacations and wont start untill next week

@EduardBargues
Copy link
Owner Author

Hey @epsi1on ! Did you manage to do something? If not I can work on that. Have a good day!

@epsi1on
Copy link
Collaborator

epsi1on commented Sep 12, 2020

Hi,
Didn't start yet
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants