Coder Social home page Coder Social logo

Comments (5)

BenMorel avatar BenMorel commented on July 21, 2024

Hi!

Thanks for reaching out. First of all congrats for your library, I've never stumbled upon it before, it really handles advanced (for me, at least!) mathematical concepts.

Indeed if you add arbitrary size integer/decimal support, our libraries will overlap somehow on this point, which is not really a problem but may lead to duplicate efforts. brick/math's objective is to only provide the arbitrary size objects (integer/decimal/rational), and nothing more (but do it well).

This is particularly useful for anything related to money.

One of the strengths of brick/math is its ability to use GMP or BCMath functions when available, and to fall back to plain PHP when not (with a performance penalty). It may lack more advanced features, but so far there haven't been requests for these features despite > 1M downloads.

I'm afraid I won't have time to invest into translating what I've done here for another project, however if you want to avoid reinventing the wheel, and think that you can build your arbitrary-sized objects on top of brick/math, then by all means I'll be happy to help, including if this requires changes here (I'm still in 0.x so quite flexible).

from math.

Beakerboy avatar Beakerboy commented on July 21, 2024

I'm not the lead developer, I just submit a lot of code. One of the main points is to be free of dependencies, so no references to GMP, or BCMath in this project. These large numbers can then be used for things like cryptographic functions or matrix algebra. Just thought I'd let you know about the project in case you need some more mathematical objects, or want a place to put some code you've developed.

from math.

BenMorel avatar BenMorel commented on July 21, 2024

One of the main points is to be free of dependencies, so no references to GMP, or BCMath in this project.

I'm not sure whether this is a good move, TBH. I call them optional dependencies in brick/math's case, as nothing will tell you that you must install them, and the library will work just fine without them. Only the docs will mention them, so that you know how to make the lib faster if you need the speed.

However, the performance gain by taking advantage of these libraries is HUGE (tenfold at least), so it's not to be taken lightly. You can simply not achieve, or even approach, the same level of performance by using plain PHP. PHP is an interpreted language on top of a state machine, so inherently slower, and does not even give you the low-level bricks you'd need to manipulate data in the way GMP does it, or at least, not in an efficient manner.

Anyway, if you feel like it, just benchmark it to get an idea.

Just thought I'd let you know about the project in case you need some more mathematical objects, or want a place to put some code you've developed.

For now I'm good, but thanks for the suggestion! It's always interesting to see what's around anyway.

from math.

Beakerboy avatar Beakerboy commented on July 21, 2024

I fully agree with you, but I’m not the lead dev. I’ve been using GMP to guide the design of my object so that down the road an interface can be used internally instead of the object.

from math.

BenMorel avatar BenMorel commented on July 21, 2024

That sounds like a wise approach.

In brick/math, this is achieved through the Calculator abstract class. It's not an interface, as it contains helper methods, some of which can be overridden by child classes if they natively implement the function (e.g., gcd()).

Implementations:

from math.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.