gmp

Linking GMP into a baremetal program

我与影子孤独终老i 提交于 2019-12-11 10:56:43
问题 I have some code which relies on a library, namely the University of Tsukuba Elliptic Pairing Library. This library itself relies on GMP. I'd like to run this program baremetal on an ARM core, specifically on a beaglebone black. GMP is a massive library, so I'd prefer to cross-compile if possible. I'd also prefer something other than the ``brute force" solution of simply dumping the entire GMP source code into the same file as my program and pushing it into arm-none-eabi-gcc. What is the

Revert number to IPv6 string representation

孤街浪徒 提交于 2019-12-11 10:19:00
问题 I'm using the IP2Location database to find country codes for IPv6 addresses. They have a method to convert an IPv6 address to a (large) number which can be used to query their database. $ipv6 = '2404:6800:4001:805::1006'; $int = inet_pton($ipv6); $bits = 15; $ipv6long = 0; while($bits >= 0){ $bin = sprintf("%08b", (ord($int[$bits]))); if($ipv6long){ $ipv6long = $bin . $ipv6long; } else{ $ipv6long = $bin; } $bits--; } $ipv6long = gmp_strval(gmp_init($ipv6long, 2), 10); In this case, $ipv6long

RSA mpz_powm() in for-loop: seg fault

你离开我真会死。 提交于 2019-12-11 09:01:45
问题 This is a follow-up question to a previous question (now that the actual issue is different): int main() { mpz_t p, q, n, phi_n, e, d; mpz_inits(p, q, n, phi_n, e, d, NULL); generate_pq(p,q); compute_n(n,p,q); compute_phiN(phi_n,p,q); mpz_clear(p,q,NULL); select_e(e,phi_n); compute_d(d,e,phi_n); mpz_clear(phi_n); mpz_t* m; int size=0; store_m(m,size); mpz_t* c; encrypt(c,m,size,e,n); return 0; } Here are the relevant functions: void store_m(mpz_t m[], int& size) { /* m = original message */

OpenMp with custom reduction for GMP addition

会有一股神秘感。 提交于 2019-12-11 08:18:57
问题 I have mpf_t omp_mpf_add(mpf_t out, mpf_t in) { mpf_add(out, out, in); return out; } And i want to make this function as an openmp reduction # pragma omp declare reduction (mpf_add:mpf_t:omp_mpf_add(omp_out,omp_in)) \ initializer(omp_priv=omp_orig) But i get error: reduction type cannot be an array type error. what should i change so that the function will work and i can use it with #pragma omp parallel for reduction(mpf_add:x) 来源: https://stackoverflow.com/questions/47617628/openmp-with

hash of libgmp.so changes automatically

懵懂的女人 提交于 2019-12-11 06:23:51
问题 I am using libgmp.so.3.3.3 in my application on RHEL 5.3. From my application I am taking the hash of /usr/lib64/libgmp.so.3.3.3 through sha512sum utility. My requirement is that the hash of gmp should match the hash of gmp when it was first installed otherwise it exits with an error. When I run my applications a few times, suddenly it appears the hash of libgmp.so.3.3.3 changes and my application exits. When I re-install the gmp, it starts to work fine again as the hash matches with the one

How do I enable GMP on Mac OS X / PHP 7?

こ雲淡風輕ζ 提交于 2019-12-11 05:35:40
问题 I'm using PHP 7 and Mac High Sierra. I'm trying to install and enable GMP. I installed via brew install homebrew/php/php70-gmp but when I try and enable the module through the php.ini (/usr/local/etc/php/7.0/php.ini) file, I'm failing . I tried uncommenting the line extension=php_gmp.dll but I get this error when running composer Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php70/7.0.27_19/lib/php/extensions/no-debug-non-zts-20151012/php_gmp.dll' - dlopen(/usr/local

Is GMP built into GCC?

依然范特西╮ 提交于 2019-12-11 04:36:59
问题 You need GMP to build GCC from source. Does that mean that GCC has built-in arbitrary precision arithmetic? 回答1: GCC uses GMP at compile-time . I believe that one of the reason may be that some language standard (probably Fortran90, but probably not C99) requires arithmetic of constant expressions to be computed with "infinite" precision. So if a source code contains 1234567890*9876543210*123098456876 that should be (at least for some dialects of Fortran?) computed in full. For that GCC uses

GMP with MinGW on Windows

坚强是说给别人听的谎言 提交于 2019-12-11 04:33:39
问题 I managed to build the GMP library successfully on my Windows 7 (64-bit computer). The steps I followed were: ./configure --enable_cxx --disable-static --enable-shared --prefix="/c/MinGW" make make install make check All of the tests pass successfully. Clearly, I'm at the point where it's possible to compile and run GMP programs. But, when I try to compile the following program: #include <stdlib.h> #include <string.h> #include <stdio.h> #include <gmp.h> char *progname; void print_usage_and

What is the standard way to maintain accuracy when dealing with incredibly precise floating point calculations in C++?

 ̄綄美尐妖づ 提交于 2019-12-11 03:24:10
问题 I'm in the process of converting a program to C++ from Scilab (similar to Matlab) and I'm required to maintain the same level of precision that is kept by the previous code. Note: Although maintaining the same level of precision would be ideal. It's acceptable if there is some error with the finished result. The problem I'm facing (as I'll show below) is due to looping, so the calculation error compounds rather quickly. But if the final result is only a thousandth or so off (e.g. 1/1000 vs 1

Should I expect GMP's mpf_class to be much slower than the primitive data type double?

我们两清 提交于 2019-12-11 02:27:41
问题 I am writing a C++ program to generate Mandelbrot set zooms. All of my complex numbers were originally two double s (one for the real part, one for the complex part). This was working pretty fast; 15 seconds per frame for the type of image I was generating. Because of the zooming effect, I wanted to increase precision for the more zoomed-in frames, since these frames have such a small difference between the min_x and max_x . I looked to GMP to help me out with this. Now, it is much much