This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.
Wren-gmp is a module which brings the speed and power of the GNU Multiple Precision Arithmetic Library ('GMP') to the Wren programming language. It consists of three classes: Mpz, Mpq and Mpf which operate on arbitrary precision signed integers, rational numbers and floating-point numbers respectively.
Some methods in the Mpf class require the GNU MPFR library ('MPFR') to work as they not supported by GMP itself.
It is the twenty-ninth in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.
To use it you need to copy the Wren source code (in the talk page) to a text file called gmp.wren and place this in the same directory as the importing script so the Wren-gmp executable can find it.
As there is a dependency on the Wren-trait module, you also need to copy that (if it is not already present) to the same directory as described here. Unless you are using classes in that module directly, there is no need to 'import' them into your script and the Comparable class can even be imported via Wren-gmp itself.
Currently, Wren-cli does not support plug-ins though this or similar functionality is likely to be added in a future version (it's already present in DOME). Consequently, scripts using the Wren-gmp module must be run under the control of a special executable whose source code (wren-gmp.c) is also included (in the talk page). This executable translates Wren method calls to calls to the corresponding GMP/MPFR functions and can be built with a command line such as the following using GCC under Linux:
$ gcc -O3 wren-gmp.c -o wren-gmp -lmpfr -lgmp -lwren -lm
If you then want to run a script called myscript.wren you would type at the command-line:
$ ./wren-gmp myscript.wren
myscript.wren should include a line such as the following to import the classes you want to use in that particular script:
import "./gmp" for Mpz, Mpq, Mpf
The same executable can be used to run any other Wren-gmp scripts unless they require additional functionality not available in Wren itself in which case the C code will need to be suitably modified and recompiled.
GMP is dual licensed under GNU LGPL v3 and GNU GPL v2, and MPFR is licensed under the former. Full details can be found on their websites' home pages linked to above.
Pages in category "Wren-gmp"
The following 42 pages are in this category, out of 42 total.