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
17
votes
3 answers

undefined reference to `__imp___gmpz_init', building GMP program on Cygwin

I'm trying to compile this simple GMP program on Cygwin: #include int main(){ mpz_t i; mpz_init(i); } This is the command: gcc -lgmp test.c I get this error: /tmp/ccJpGa7K.o:test.c:(.text+0x17): undefined reference to…
sciencectn
  • 1,405
  • 1
  • 16
  • 25
17
votes
3 answers

Adding Linker Flags in Xcode

(I'm not sure if "flag" is the word I'm looking for, but I'll explain it.) I am trying to compile a program that uses the GMP big number library. But to be able to compile with GMP, I have to add -lgmp to the end of the command. For example, if I…
Michael Dickens
  • 1,454
  • 4
  • 18
  • 26
16
votes
1 answer

What does it mean double free detected in tcache 2 while using mpz?

I use this program to store a mpz value but when I add a 0 ( 400000000000000000000000000000000000000 instead of 40000000000000000000000000000000000000 -> 38 0s instead of 37) I get free(): double free detected in tcache 2 Aborted (core…
user11903678
16
votes
14 answers

In PHP, how do I generate a big pseudo-random number?

I'm looking for a way to generate a big random number with PHP, something like: mt_rand($lower, $upper); The closer I've seen is gmp_random() however it doesn't allow me to specify the lower and upper boundaries only the number of bits per limb…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
14
votes
4 answers

Custom types in OpenCL kernel

Is it possible to use custom types in OpenCL kernel like gmp types (mpz_t, mpq_t, …) ? To have something like this (this kernel doesn't build just because of #include ) : #include __kernel square( __global mpz_t* input, …
Studer
  • 611
  • 2
  • 8
  • 21
14
votes
5 answers

Is there any GMP logarithm function?

Is there any logarithm function implemented in the GMP library?
eddy ed
  • 917
  • 2
  • 10
  • 21
14
votes
4 answers

No usable M4 in $PATH or /usr5bin

As part of a long, sordid story whose end goal is simply to get GMP installed for use with code::blocks in Windows, I am trying to configure gmp. I do this with the following command: ./configure --prefix=${gmp_install} Everything starts out well…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
12
votes
1 answer

Error with gmp when compiling helloworl in COBOL

I want to run this hello world program, in COBOL : Identification Division. program-id. HelloWorld. Procedure Division. Display 'Bonjour '. Display 'Comment allez vous ? ' . goback. But, I have this error : In file included from…
Stalyon
  • 538
  • 5
  • 20
12
votes
5 answers

Installing gmpy on OSX - mpc.h not found

I have brew installed mpcand gmp , but when I try to pip install gmpy2 I get a compile error on the line #include "mpc.h" so for some reason clang is having trouble finding the mpc library. I'm not sure what I should do at this point.
Jakob Weisblat
  • 7,450
  • 9
  • 37
  • 65
11
votes
4 answers

XAMPP (WIndows) PHP GMP Functions

Is there any way to use PHP GMP Functions on windows without using a virtual machine? Thanks in advance. [http://php.net/manual/en/ref.gmp.ph]
Mark
  • 780
  • 1
  • 6
  • 17
11
votes
1 answer

How does GMP stores its integers, on an arbitrary number of bytes?

2^64 is still far from the "infinity" my ram/hard drive can handle... First I wonder how GMP works with memory/processor since it does some kind of shady optimisations... I was also wondering if there is a way of storing an integer (unsigned, it's…
gokoon
  • 1,017
  • 3
  • 11
  • 14
11
votes
2 answers

GMP: initializing multiple variables

You can initialize a GMP variable 'mpz_t n' as mpz_init(n). The documentation sais 'void mpz_inits (mpz_t x, ...) Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.' I'm not sure what a 'NULL-terminated list' here…
user3810155
11
votes
2 answers

Building GMP library with Visual Studio?

Is there an easy way to build the GMP (GNU Multiple Precision Arithmetic Library, http://gmplib.org) under Windows, using Visual Studio 2005? I tried to find information about building the library myself, but could not find anything that really…
ToastedSoul
  • 1,296
  • 1
  • 17
  • 27
10
votes
1 answer

Shallow copy of mpz_t

GMP provides methods for initializing and assigning an mpz_t. A call to mpz_init_set(a, b) will assign to a the content of b. However, I assume, this performs a deep copy on b. On my project I need to work with arrays of mpz_t that are as long as…
James
  • 145
  • 3
  • 11
10
votes
1 answer

Printing a base 4294967296 integer in base 10

I have in C++ a vector of 32 bits integers (variable size, continous memory; like a C-array), representing a number in base 4294967296. I would like to print it in base 10. These numbers can be extremely big and take over a few megabytes of…
user142019
1
2
3
68 69