gmp

Getting GMP to work with GCC 4.5.2

孤街醉人 提交于 2019-12-06 12:11:18
I'm trying to make a cross compiler with the files from http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac I'm on an Intel Mac (10.6.6, x86_64) I compiled: gmp, mpfr, mpc for the cross compiler as 32bit (as I'm on a 64bit Mac) but I'm getting ld: warning: option -s is obsolete and being ignored ld: warning: ignoring file /gmp1/lib/libmpc.dylib, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: ignoring file /gmp1/lib/libmpfr.dylib, file was built for unsupported file format which is not the architecture being linked (i386) ld

Calculating the n-th root of an integer using PHP/GMP

假如想象 提交于 2019-12-06 12:04:46
How can I calculate the n-th root of an integer using PHP/GMP? Although I found a function called gmp_root(a, nth) in the PHP source , it seems that this function has not been published in any release yet*: http://3v4l.org/8FjU7 *) 5.6.0alpha2 being the most recent one at the time of writing ComFreek Original source: Calculating Nth root with bcmath in PHP – thanks and credits to HamZa ! I've rewritten the code to use GMP instead of BCMath: function gmp_nth_root($num, $n) { if ($n < 1) return 0; // we want positive exponents if ($num <= 0) return 0; // we want positive numbers if ($num < 2)

Restore a number from several its remainders (chinese remainder theorem)

你离开我真会死。 提交于 2019-12-06 03:32:24
问题 I have a long integer number, but it is stored not in decimal form, but as set of remainders. So, I have not the N number, but set of such remainders: r_1 = N % 2147483743 r_2 = N % 2147483713 r_3 = N % 2147483693 r_4 = N % 2147483659 r_5 = N % 2147483647 r_6 = N % 2147483629 I know, that N is less than multiplication of these primes, so chinese remainder theorem does work here ( http://en.wikipedia.org/wiki/Chinese_remainder_theorem ). How can I restore N in decimal, if I have this 6

How to initialize a mpz_t in gmp with a 1024-bit number from a character string?

戏子无情 提交于 2019-12-06 03:25:11
问题 I want to initialize a mpz_t variable in gmp with a very large value like a 1024 bit large integer. How can I do so ? I am new to gmp. Any help would be appreciated. 回答1: Use mpz_import. For example: uint8_t input[128]; mpz_t z; mpz_init(z); // Convert the 1024-bit number 'input' into an mpz_t, with the most significant byte // first and using native endianness within each byte. mpz_import(z, sizeof(input), 1, sizeof(input[0]), 0, 0, input); 回答2: To initialize a GMP integer from a string in C

Build GMP for iOS

核能气质少年 提交于 2019-12-06 01:31:27
问题 I need to use GMP in an iphone program I'm working on, but don't really know where to begin. I know that I have to build a version for the device and a version for the simulator, but that is as much as I know. I've tried looking around but haven't been able to find much. Has anyone here successfully build GMP for iphone that would care to guide me through the process? I saw Building GMP for iOS but it is not working for me. I thought I had built it successfully using: ./configure CC="

GMP mpz_array_init is an obsolete function - How should we initialize mpz arrays?

不问归期 提交于 2019-12-05 13:52:25
Having only used the GNU MP Bignum Library a few times, I was interested to see that the way I had previously allocated/initiated arrays is now obsolete. From Integer Special Functions : 5.16 Special Functions The functions in this section are for various special purposes. Most applications will not need them. — Function: void mpz_array_init (mpz_t integer_array, mp_size_t array_size, mp_size_t fixed_num_bits) This is an obsolete function. Do not use it. This is how I would allocate and initialze an array of mpz_t . int array_size = 100; mpz_t *num_arr; num_arr = malloc(arr_size * sizeof(mpz_t

How does one calculate 2 ^ -18 using GMP?

爱⌒轻易说出口 提交于 2019-12-05 11:57:34
I've just discovered, to my embarrassment, that feeding negative exponents to mpz_pow_ui doesn't work very well. ("The manual does say unsigned long, you know.") For the other mpz_pow functions, the manual uses concepts I don't understand. For example " base ^ exp mod mod " in the following: void mpz_powm (mpz_t rop, mpz_t base, mpz_t exp, mpz_t mod) void mpz_powm_ui (mpz_t rop, mpz_t base, unsigned long int exp, mpz_t mod) Set _rop_ to _base_^_exp_ mod _mod_. Negative exp is supported if an inverse base-1 mod mod exists (see mpz_invert in Section 5.9 [Number Theoretic Functions], page 35). If

avoiding abort in libgmp

烈酒焚心 提交于 2019-12-05 08:36:04
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 <cmath> #include <gmp.h> #include <iostream> int main() { mpz_t result; mpz_init(result); mpz_fac_ui(result, 20922789888000); std::cout << mpz_get_si(result) << std::endl; } Results in: $ ./test gmp: overflow in mpz type Aborted Apparently, the number produced is REALLY big. Is there anyway to handle the error more gracefully than an abort. This is a GUI based application and it aborting

solaris - compile 64bit gcc - elf class error

北城以北 提交于 2019-12-04 20:15:22
I'm installing a modern version of gcc on solaris. I compiled gmp, mpfr and mpc, they're all 64bit. When I try to configure gcc as follows I get an error complaining that mpc,mpfr and gmp are the wrong elf class. What gives? ./../gcc-4.5.1/configure --prefix=/opt/OurAppDir/gcc --with-gmp=/opt/OurAppDir/gmp --with-mpfr=/opt/OurAppDir/mpfr --with-gnu-as --with-gnu-ld --build=sparc-sun-solaris2.10 checking build system type... sparc-sun-solaris2.10 checking host system type... sparc-sun-solaris2.10 checking target system type... sparc-sun-solaris2.10 checking for a BSD-compatible install... ./..

Build GMP for iOS

谁说我不能喝 提交于 2019-12-04 07:26:35
I need to use GMP in an iphone program I'm working on, but don't really know where to begin. I know that I have to build a version for the device and a version for the simulator, but that is as much as I know. I've tried looking around but haven't been able to find much. Has anyone here successfully build GMP for iphone that would care to guide me through the process? I saw Building GMP for iOS but it is not working for me. I thought I had built it successfully using: ./configure CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2" CXX="/Developer/Platforms