Questions tagged [gmp]

The GNU Multiple-Precision Library (GMP) is a mature, free library for arbitrary-precision arithmetic with support for big signed integers, rational numbers, and floating point numbers. The basic interface is for C but wrappers exist for other languages including Ada, C++, C#, OCaml, Perl, PHP, and Python. It is distributed under the GNU LGPL and is used for cryptography applications and in computer algebra systems such as Mathematica and Maple.

GMP, or GNU Multiple Precision Arithmetic Library, is a library allowing for arbitrary precision arithmetic. This means that calculations using the libraries internal variables are not limited to ordinary constraints of bit-level precision that many languages inherently possess.

It can support multiple different data types including floating-point numbers, signed integers and rational numbers. It is primarily used in areas related to cryptography, and is also heavily used in numerical research, other types of security applications and computational algebra.

Full words are used as the intrinsic data type, and logic is used to select separate algorithms depending upon the operand size for efficiency purposes. Critical parts of the library utilize Assembly code and is specialized for different processing units to further increase efficiency.

GMP is designed to run on systems running Unix derivates including Linux and Solaris, but may also work on 32-bit and 64-bit Windows machines.

The manual and information to get started using GMP are located here :

https://gmplib.org/manual/

1024 questions
6
votes
3 answers

Compiling GMP/MPFR with Emscripten

Alright, this has been driving me insane. I've been trying this for at least a month, and no where on the internet is helping. I followed the steps of this. Not even the example works when I do these steps, because when I do it, I get this. bitcode…
Flarp
  • 139
  • 1
  • 10
6
votes
3 answers

avoiding abort in libgmp

I have some code that uses libgmp. At some point the user may request a factorial of a very large number. Unfortunately, this results in libgmp raising an abort signal. For example the following code: #include #include #include…
Evan Teran
  • 87,561
  • 32
  • 179
  • 238
6
votes
4 answers

Possible side effects of doing a typedef of a struct to an array of one element in C

I came across this code. typedef __mpz_struct MP_INT; typedef __mpz_struct mpz_t[1]; Here the struct __mpz_struct is a struct that is typedefed to an array of single element. I understand that this is a trick to pass by reference in C. Then mpz_t…
6
votes
1 answer

GMP Compilation for NDK error: Oops, mp_limb_t is 64 bits, but the assembler code in this configuration expects 32 bits

I am running Arch Linux on a 64 bit system. I try to follow these instructions: # download gmp, unpack cd $NDK_ROOT/sources wget ftp://ftp.gmplib.org/pub/gmp-4.2.4/gmp-4.2.4.tar.bz2 tar -jxvf gmp-4.2.4.tar.bz2 mv gmp-4.2.4 gmp cd…
knowNothing
  • 61
  • 1
  • 4
6
votes
2 answers

Building a C library (GMP) for arm64 iOS

I'm trying to build a C library (GMP 6.0.0) for arm64 for use on iOS. I'm running the configure script with the invocation below (compiler is as found using xcrun --find). ./configure…
Patrick Pijnappel
  • 7,317
  • 3
  • 39
  • 39
6
votes
2 answers

How to serialize a GMP rational number?

Is there a way to serialize a GMP rational number in binary form? I only see functions for reading/writing to a FILE, but even there it is a text form. I could convert to numerator/denominator and use the integer functions, but again there only a…
edA-qa mort-ora-y
  • 30,295
  • 39
  • 137
  • 267
6
votes
1 answer

Very Slow Random Number Generation using dev/urandom on Mac OS 10.8

I am writing a program that uses Paillier Cryptosystem to encrypt a matrix. To encrypt a 50 x 50 matrix it takes about 12 seconds! That's painfully long considering I intend to encrypt matrices of sizes 5000 x 5000 and above. Profiling the program…
6
votes
2 answers

numpy array with mpz/mpfr values

I want to have a numpy array with mpz/mpfr values. Because my code: import numpy as np import gmpy2 A=np.ones((5,5)); print A/gmpy2.mpfr(1); generates: RuntimeWarning: invalid value encountered in divide print A/gmpy2.mpfr(1); [[1.0 1.0 1.0 1.0…
Cupitor
  • 11,007
  • 19
  • 65
  • 91
6
votes
2 answers

C++ Boost Large Number Storage

So based on the question I asked earlier, I downloaded and setup boost. I have this code: #include #include using namespace std; using namespace boost::multiprecision; void main() { mpz_int…
Richard
  • 5,840
  • 36
  • 123
  • 208
6
votes
3 answers

Math::GMP errors when installing

Im trying to install Math::GMP but it keeps failing and im not sure where to go from here . This is what im typing and here is the output pointing to the log file: [root@confeng Math-GMP-2.06-VEVNp7]# cpanm Math::GMP --> Working on…
Taz Manian
  • 91
  • 1
  • 3
5
votes
1 answer

Trying to calculate large numbers in Python with gmpy. Python keeps crashing?

I was recommended to use gmpy to assist with calculating large numbers efficiently. Before I was just using python and my script ran for a day or two and then ran out of memory (not sure how that happened because my program's memory usage should…
Ryan Peschel
  • 11,087
  • 19
  • 74
  • 136
5
votes
2 answers

How to check the version of GMP, MPFR and CamlIDL?

My question is simple... How could I check the version of GMP installed on my machine? What about MPFR? And What about CamlIDL? Thank you very much
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
5
votes
1 answer

gmp unit tests failing on Ventura Mac m1

I am running Mac OS Ventura (13.0) on M1 Pro chipset. I am successfully compiling GMP version 6.2.1, but most of unit tests are failing. Either with Segmentation fault: 11 or with Abort trap: 6 Version: GNU MP 6.2.1 Host type: …
odysseasg
  • 121
  • 1
  • 8
5
votes
4 answers

gmpxx.h: no such file or directory

I just installed a brand new copy of mingw (32 bit) downloading it from the official project page from Sourceforge. I installed everything in the package, all compilers and so on. Then I downloaded from here gmp for MinGW. I extracted…
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
5
votes
4 answers

gmp is missing while configuring building gdb from source

I am trying to build gdb from source, which version is 11.1. I have configured the GMP including path, but the configure script still report an error. configure: error: GMP is missing or unusable I copied the config log. configure:10433: checking…
user3236879
  • 511
  • 2
  • 7
  • 17