rugheid / Swift-MathEagle

A general math framework to make using math easy. Currently supports function solving and optimisation, matrix and vector algebra, complex numbers, big int, big frac, big rational, graphs and general handy extensions and functions.
MIT License
42 stars 6 forks source link

[Suggestion] Generic approach to Solver #8

Closed BenziAhamed closed 8 years ago

BenziAhamed commented 8 years ago

I was trying to use the Solver.newton methods and found that it wasn't generic to handle Double, Float, CGFloat etc. I ended up implementing it this way. Do you think it would be worthwhile to update the code as illustrated?

rugheid commented 8 years ago

Hi, thank you for contributing! I like the way you implemented it. I do have a few remarks/questions though:

rugheid commented 8 years ago

One small thing: please add your name to the copyright comments at the top of the file.

rugheid commented 8 years ago

Since there were a lot of things that would have had to change, I changed my current implementation to be generic using my own protocols. I still have to write some additional tests for the other types, and I still need to add CGFloat to adopt my own protocols... This is the commit that implements Solver generically: ba1d040 I'll implement CGFloat and close the pull request then. 😄

rugheid commented 8 years ago

CGFloat now complies to all the protocols, so it can be used in all generic parts now. See commit b07d919. I'll close this pull request now. If you want to know how I implemented all the protocols, you can take a look in Math.swift and in the Protocols group in the Xcode project. Thanks for using MathEagle and contributing to it!