charto / bigfloat

Fast arbitrary precision math library for computational geometry.
MIT License
72 stars 3 forks source link

Performance enhancement #1

Closed munrocket closed 5 years ago

munrocket commented 5 years ago

As you know private methods in javascript have worst performance (check here question3). And since your library designed to be incredibly fast do you think about static function for arithmetic? I checked same libraries with multicomponent float expansion in other languages and their performance are much better compeared to ordinary arbitrary precision.

munrocket commented 5 years ago

Also what about .js distribution? This project maintainable?

jjrv commented 5 years ago

Here's the .js file published on npm.

TypeScript attaches private methods to the prototype, the private keyword here only affects the .d.ts file.

Speed would improve by supporting more destructive operations that modify a number instead of returning a new object.

The double float approach looks very interesting, I didn't know about it. Triple double should allow working with products of two JavaScript numbers without any rounding errors. It might speed up a robust implementation of Bentley-Ottmann line intersection algorithm, because arbitrary precision computations would be needed less.

jjrv commented 5 years ago

It seems a better approach would be to have a static function for multiplying two JavaScript numbers, returning a BigFloat wrapping a triple double. Those could then be compared and in some cases added / subtracted while remaining triple doubles. Further operations would switch to arbitrary precision.

munrocket commented 5 years ago

Did not notice the .js version in npm package, also you not answered 20 days so it lead me to create my own version :) Also I am trying to find a fulltime job by creating open source libraries.

munrocket commented 5 years ago

Yes i think static functions are posible solution.

jjrv commented 5 years ago

The new BigFloat53 class is now based on a multicomponent float expansion.

munrocket commented 5 years ago

Nice!

munrocket commented 3 years ago

Hello @jjrv can you comment something on fma proposal in JS? https://es.discourse.group/t/math-float-optimisation/829/4