daninet / gmp-wasm Goto Github PK
View Code? Open in Web Editor NEWArbitrary-precision Integer, Rational and Float types based on the GMP and MPFR libraries
License: GNU Lesser General Public License v3.0
Arbitrary-precision Integer, Rational and Float types based on the GMP and MPFR libraries
License: GNU Lesser General Public License v3.0
I've been trying on and off to get gmp-wasm
to work for me, and I'm getting a variety of weird behaviors. I suspect one of my bugs can be blamed on Kotlin/JS and another might be related to gmp-wasm
. I've created a minimal repository that allows the bugs to be reproduced:
https://github.com/danwallach/gmp-wasm-kotlin
The README.md
documents how to run the code and has the outputs. In short, I built a Kotlin BigInteger
class that speaks directly to the mpz
functions, and tries to manage gmp-wasm
memory using FinalizationRegistry
(so when the JavaScript wrapper object is garbage collected, it will tell gmp-wasm
to free the corresponding mpz
object).
I'd appreciate if you could take a look at this.
I'm looking at the way you're managing memory, by keeping mpz_t_arr
for all the temporary values and then blowing all of them away when the surrounding context finishes. I'm curious if you've looked at the possibility of leveraging finalizers, to allow the JavaScript garbage collector call back to you when it's time to ultimately call mpz_t_free
.
This would allow higher-level logic to write arithmetic expressions as normal, without having to worry about object lifetimes.
Hi! I am using the gmp-wasm in typescript, the link to typescript API on README seems not working.(https://paka.dev/npm/gmp-wasm/v/0.9.4)
For what it's worth, I want to call this library from Kotlin, which apparently would be easier if there was a declaration file (*.d.ts
). Not that I have any idea what that is, but I'm curious if it's on your agenda to make such a thing.
First, thank you for this library. It's exactly what I need.
GnuMP has a very useful feature for selecting bit ranges from an xmpz. For my particular application, this allows for an optimization worth about 9x (precompute to optimize modular exponentiation for known bases).
Python binding: https://gmpy2.readthedocs.io/en/latest/advmpz.html
I'd love something analogous to the "bit slice" read feature. I don't actually need anything else, but I imagine others might want the full suite of xmpz mutability features.
Also, in terms of general purpose features, it would be handy to have input and output as byte arrays. Java BigInteger defines this to be big endian, twos complement, which seems as good as anything else you might do.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.