gmp

How to Install a C++ library on Windows for Dev-C++

≯℡__Kan透↙ 提交于 2019-12-19 09:37:52
问题 I downloaded a library called GMP (it's for doing calculations with arbitrarily large numbers) and I can't figure out how to actually install and use it. All of the instructions I find tell me to run the files configure , MakeFile , and install , but when I try to do that I get 'install' is not a recognized internal or external command. All I can figure is that the instructions are for Linux, but I'm running Windows. I found a couple of instructions here on SO that tell me to copy certain

In R, using Ubuntu, try to install a lib depending on GMP C lib, it won't find GMP, but I have GMP installed

倾然丶 夕夏残阳落幕 提交于 2019-12-19 05:05:21
问题 I want to install the Rmpfr library of R, so I type within R: install.packages("Rmpfr") This package requires the GMP C library to be installed, which in Ubuntu can be installed typing on the terminal sudo apt-get install libgmp-dev So, after I try to install Rmpfr library in R, I receive an error message containing configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org The problem is, I already have GNU MP installed, and its version is 5.1.2. So, something is wrong

Arbitrary-Precision Math in PHP

淺唱寂寞╮ 提交于 2019-12-18 19:07:25
问题 I'm currently trying to figure out how to work with arbitrary-precision numbers in PHP. So I guess my first question would be what exactly is arbitrary-precision math. I tried Googling for a good definition but for some reason nobody can put it in simple enough words. Second, what are the differences between the BCMath and GMP libraries in PHP? I've heard claims that GMP's API is "fresher", but idk. Is one better? And my final question would be what type of numbers BCMath/GMP takes. Obviously

Getting gmp libraries to

做~自己de王妃 提交于 2019-12-18 09:25:29
问题 I am having a problem getting a program to compile using: Latest Msys and MinGW installations Windows 7 Pro / Intel Core I5 / 8GB GMP 5.1.2 libraries - the header file is in C:\gmp\include - the .a and .la files are in C:\gmp\lib I originally posted this as an Eclipse question, but the silence has been deafening. I have since tried compiling using just gcc in msys, and I get the same problem. I compile using: g++ -I /c/gmp/include -O0 -g3 -Wall -c -fmessage-length=0 -o main.o ./main.cpp which

GMP mpz_sizeinbase returns size 2 for 9 in base 10

旧街凉风 提交于 2019-12-14 03:57:53
问题 I'm trying to use libgmp and I encountered something strange using mpz_sizeinbase. If I use a number which starts by base - 1 the size is one too big. #include <gmp.h> mpz_t n; int main() { unsigned int base = 10; mpz_init_set_str (n, "90", base); mpz_out_str(stdout, base, n); printf(" has length %zu in base %d\n", mpz_sizeinbase (n, base), base); } when I run it: $ gcc -g draft.c -o draft -lgmp && ./draft 90 has length 3 in base 10 Am I doing something wrong? 回答1: The kkk's answer already

R: Difficulties manipulating bigz vectors/list

泄露秘密 提交于 2019-12-13 07:27:29
问题 Below are two schemes that I use on a daily basis that I'm having trouble with using the gmp package: Normal Behavior: ### example 1 (changing a subset of a vector) > v1 <- rep(1,10) > v1[3:7] <- 2:6 > v1 [1] 1 1 2 3 4 5 6 1 1 1 ### example 2 (flattening a list to a vector) > mylist1 <- list(1:5,6:10) > unlist(mylist1) [1] 1 2 3 4 5 6 7 8 9 10 GMP equivalents: ### example 1 (when changing a subset, the vector is lost) > v2 <- as.bigz(rep(1,10)) > v2[3:7] <- as.bigz(2:6) > v2 Big Integer (

Link the gmp library with Xcode 7.2

不打扰是莪最后的温柔 提交于 2019-12-13 07:25:34
问题 I try to link the gmp library with Xcode. This is what I (with the help of multiple stackoverflow articles) did: I downloaded the gmp file and installed it (in the default location: /usr/local ) using "sudo make install" and I checked it with "make check". In Xcode I added under "Other Linker Flags" (as described in multiple articles) -lgmp . I also tried -lgmpxx . In main I included <stdio.h> and <gmp.h> . After all I still got the error: " 'gmp.h' file not found ", which indicates that the

gmp_pow() will not accept a GMP number for exponent

筅森魡賤 提交于 2019-12-13 06:15:03
问题 I am playing around in PHP with RSA and big numbers. I need to be able to take numbers to the power of an exponent that has ~256 to ~512 bytes using gmp_pow(). Does anyone have any suggestions? 回答1: You should use gmp_powm() which automatically reduces the intermediate values to be less than the modulus value. This exactly what you want for RSA. gmp_pow() doesn't accept an exponent large than a long since the intermediate values will be larger than the addressable memory in your computer. 来源:

Converting an ull to an mpz_t

一世执手 提交于 2019-12-13 05:48:50
问题 I saw the post at question mpz_t to unsigned long long conversion (gmp lib) and Chris Jester-Young gave me the answer mpz_t ull2mpz(unsigned long long ull) { char buf[40]; int len; mpz_t result; len = snprintf(buf, sizeof buf, "%llx"); if (len >= sizeof buf) { /* oops */ } mpz_init(result); len = gmp_sscanf(buf, "%Zx", result); if (len != 1) { /* oops */ } return result; } The problem here is that, as stated in How to convert GMP C parameter convention into something more natural? mpz_t is an

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

被刻印的时光 ゝ 提交于 2019-12-13 04:07:50
问题 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 see the hash when I debug, but cannot seem to turn this into an int . It is SHA-512 so 512 bits? Weird characters come out of printf("%s",hash); atoi gives 0 too, do I have to break up the hash by character? That would work I think. 回答1: mpz_set_str