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
0
votes
1 answer

How do I use GMP properly to do this operation?

My code in C++ long long N=1000000000000LL; long long a = N; mpz_class v; mpz_mul(v, a, a); cout<
KaliMa
  • 1,970
  • 6
  • 26
  • 51
0
votes
1 answer

Role of cores in Parallel GMP-Chudnovsky using OpenMP with factorization

I recently found this implementation of Chudnovsky's algorithm for calculating pi: Parallel GMP-Chudnovsky using OpenMP with factorization I have compiled it for various numbers from 1o^3 to 10^8 with the default 1 core option. However, I have…
Ivan
  • 347
  • 2
  • 4
  • 16
0
votes
1 answer

How to convert OpenSSL SHA-512 hash to GMP number to use in RSA encryption method

SHA1(data, length, hash); unsigned char *labelPtr; labelPtr = hash; mpz_set_str (encrypted, labelPtr, 16); gmp_printf("hashed= %Zd\n", encrypted); encrypted equals 0? I need to get an integer from this hash so that I can perform RSA encryption. I…
csestony
  • 215
  • 2
  • 12
0
votes
1 answer

Im using gmp in C and next prime isnt working? Im trying to generate rsa keys

mpz_t rand1,rand2; mpz_init (rand1); mpz_init (rand2); mpz_random (rand1,512); //mpz_random (rand2,512); mpz_nextprime ( rand2, rand1 ); gmp_printf("random %Zd\n", rand2); //free the big ints mpz_clear(rand1); mpz_clear(rand2); However is i print…
csestony
  • 215
  • 2
  • 12
0
votes
2 answers

Fastest C++ Rational Number library

I'm using GMPXX wrapper of GMP and it is not fast enough. Is it possible to find some comparison of rational number libraries' speed? During my calculation a very big rational number will appear with 10^100 denominator and same size numerator. Do…
petRUShka
  • 9,812
  • 12
  • 61
  • 95
0
votes
3 answers

Segmentation fault when wxThread::OnExit() is called

Update 2: See the section after my code. I'm using a thread for calculating PI using the GMP library, but somehow I'm now getting a segmentation fault when wxThread::OnExit() is internally in wxWidgets called. Here is the line in wxWidgets source…
ComFreek
  • 29,044
  • 18
  • 104
  • 156
0
votes
1 answer

C++ mpz_class and binary files

I am using the mpz_class (using MPIR 2.5.1 with Visual Studio C++ 2010, and the C++ version of MPIR), and for me it's not feasible to store huge numbers in memory, so I want to do it with binary files. I already finished this with text files, but…
Dragan R.
  • 598
  • 4
  • 18
0
votes
1 answer

Cygwin crashing when building gmp library

I'm trying to build the gmp library using cygwin. At a point in the configure process, it crashes, telling me that no usable M4 in $PATH or /usr/5bin I think that this means it is looking for MinGW, under which MSYS and M4 exist. I have verified…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
0
votes
2 answers

Compiling GMP Library on Windows

I've downloaded and extracted the files for the GMP library. My objective is to use this library working with my c++ code with code::blocks as my IDE. I have verified that there is a makefile among the files that I extracted. In fact, there are two…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
0
votes
1 answer

Is this a bug in GMP 4.1.2 or is it something I'm doing wrong?

To this bit of code I pass the string "kellogs special k" and I get 1 which means that the string is an integer. What on earth am I doing wrong? Or is it a GMP problem? #define F(x) mpf_t (x); mpf_init( (x) ); long __stdcall FBIGISINTEGER(BSTR p1)…
bugmagnet
  • 7,631
  • 8
  • 69
  • 131
0
votes
2 answers

Using the mpz_powm functions from the GMP/MPIR libraries with negative exponents

Please consider the following code: mpz_t x, n, out; mpz_init_set_ui(x, 2UL); mpz_init_set_ui(n, 7UL); mpz_init(out); mpz_invert(out, x, n); gmp_printf ("%Zd\n", out);//prints 4. 2 * 4 (mod 7) = 1. OK mpz_powm_ui(out, x, -1, n);//prints 1. 2 * 1…
Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
0
votes
1 answer

Which library should I use on OSX for arbitrary precision arithmetic?

I tried already GMP, MPFR. But I can't accomplish a simple division like below. BTW I have LLVM compiler in Xcode. I try to compile, run it to IOS Simulator. mpf_t a; mpf_init2 (a, 256); mpf_set_d(a, 0.7); mpf_t b; mpf_init2 (b, 256); mpf_set_d(b,…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

Function Parameter causes segmentation fault in GMP

I am trying to change the value of d which is of type mpz_t in the function extended_gcd and then pass it back to my main function and I get a segmentation fault when I execute the program. int extended_gcd(mpz_t c, mpz_t a, mpz_t b) { …
CherryBrandy
  • 55
  • 1
  • 6
0
votes
1 answer

Calculate machine precision on gmp arbitrary precision

I'm trying to obtain the machine precision on gmp variables. To that end, I adapted the code from wikipedia, to compute the precision of a gmp with a fixed precision: int main( int argc, char **argv ) { long int precision =…
Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
0
votes
1 answer

How to trace or debug GMP?

I have downloaded the source of GMP library 5.02, and - as suggested here for maximum debuggability - I ran : ./configure --disable-shared --enable-assert --enable-alloca=debug --host=none CFLAGS=-g and compiled it with make, then installed the…
Tibor Vass
  • 157
  • 14