问题标签 [gmp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
18937 浏览

types - OpenCL 内核中的自定义类型

是否可以在 OpenCL 内核中使用自定义类型,例如 gmp 类型 (mpz_t, mpq_t, ...)?

拥有这样的东西(这个内核不会仅仅因为#include <gmp.h>):

也许通过向第四个参数(选项)添加不同的参数clBuildProgram

还是 OpenCL 已经有了可以处理大量数字的类型?

0 投票
3 回答
3718 浏览

gmp - GMP 变量的位大小

如何知道 GMP 中声明变量的大小?或者我们如何确定 GMP 中整数的大小?

在手册中给出这个函数为“temp”分配1limb(= 32bits for my comp)大小....但它只有9位数字..所以我不认为32位大小的数字只包含9位数字数字..

所以请帮我知道 GMP 中整数变量的大小..

谢谢你的建议。。

0 投票
3 回答
493 浏览

gmp - GMP 变量的位大小

在 GMP 库中,

_mp_size 保存整数的肢体数。

我们可以创建大小为 1 个肢体(32 位)、2 个肢体(64 位)、3 个肢体(96 位)...等等的整数。使用 mpz_init 或 mpz_random 函数..

我们不能创建一个大小为 8 位或 16 位的整数变量。除了 32 位大小的倍数吗?

你可以为此编码吗?

谢谢你 ..

0 投票
1 回答
2946 浏览

gmp - GMP 与 java BIG INTEGERS,,,

哪个工具是访问大位数以测试加密系统的最佳工具..GMP 库或 JAVA 大整数..??在速度,内存,功能,对 crptosystems 的灵活性(数学函数,如反转,pwm ..等)方面。

0 投票
1 回答
1232 浏览

haskell - 使用 GHC,在用户空间安装 GMP 的 cabal

我一直在尝试在cabal-install没有安装 GNU 多精度包 (GMP) 的系统上安装 Haskell 平台并安装在用户空间中的 Linux 上。

我设法通过设置LB_LIBRARY_PATH指向我安装 GMP 的 lib 目录来安装 GHC-6.12.1 和 GHCi 工作,但是在下一步cabal-install开始工作时遇到了问题。它一直试图(静态)链接到 GMP。

这失败了,因为 GMP 没有安装在系统中并且ld不知道在哪里可以找到库,并且没有环境变量(我知道)可以告诉 ld 在哪里可以找到用户安装的 GMP,并且(显然)无法告诉配置 Cabal 提供相关-L标志。

经过多次徒劳的搜索和黑客尝试后,我想到了安装我自己的 shell 脚本的荒谬简单的想法,该脚本使用适当的标志ld调用系统。ld-L

这是 shell 脚本 101,当然:

随着这个脚本安装在我PATH前面的目录中,/usr/bin所有问题似乎都消失了。

0 投票
5 回答
26910 浏览

c++ - What are the best (portable) cross-platform arbitrary-precision math libraries?

I’m looking for a good arbitrary precision math library in C or C++. Could you please give me some advices or suggestions?

The primary requirements:

  1. It must handle arbitrarily big integers—my primary interest is on integers. In case that you don’t know what the word arbitrarily big means, imagine something like 100000! (the factorial of 100000).

  2. The precision must not need to be specified during library initialization or object creation. The precision should only be constrained by the available resources of the system.

  3. It should utilize the full power of the platform, and should handle “small” numbers natively. That means on a 64-bit platform, calculating (2^33 + 2^32) should use the available 64-bit CPU instructions. The library should not calculate this in the same way as it does with (2^66 + 2^65) on the same platform.

  4. It must efficiently handle addition (+), subtraction (-), multiplication (*), integer division (/), remainder (%), power (**), increment (++), decrement (--), GCD, factorial, and other common integer arithmetic calculations. The ability to handle functions like square root and logarithm that do not produce integer results is a plus. The ability to handle symbolic computations is even better.

Here are what I found so far:

  1. Java's BigInteger and BigDecimal class: I have been using these so far. I have read the source code, but I don’t understand the math underneath. It may be based on theories and algorithms that I have never learnt.

  2. The built-in integer type or in core libraries of bc, Python, Ruby, Haskell, Lisp, Erlang, OCaml, PHP, some other languages: I have used some of these, but I have no idea which library they are using, or which kind of implementation they are using.

What I have already known:

  1. Using char for decimal digits and char* for decimal strings, and do calculations on the digits using a for-loop.

  2. Using int (or long int, or long long) as a basic “unit” and an array of that type as an arbitrary long integer, and do calculations on the elements using a for-loop.

  3. Using an integer type to store a decimal digit (or a few digits) as BCD (Binary-coded decimal).

  4. Booth’s multiplication algorithm.

What I don’t know:

  1. Printing the binary array mentioned above in decimal without using naive methods. An example of a naive method: (1) add the bits from the lowest to the highest: 1, 2, 4, 8, 16, 32, … (2) use a char*-string mentioned above to store the intermediate decimal results).

What I appreciate:

  1. Good comparisons on GMP, MPFR, decNumber (or other libraries that are good in your opinion).

  2. Good suggestions on books and articles that I should read. For example, an illustration with figures on how a non-naive binary-to-decimal conversion algorithm works would be good. The article “<strong>Binary to Decimal Conversion in Limited Precision” by Douglas W. Jones is an example of a good article.

  3. Any help in general.

Please do not answer this question if you think that using double (or long double, or long long double) can solve this problem easily. If you do think so, you don’t understand the issue in question.

0 投票
1 回答
436 浏览

c - 用 mpz_t 制作帕斯卡三角形

嘿,我正在尝试将我编写的用于生成表示 Pascal 三角形的 long 数组的函数转换为返回 mpz_t 数组的函数。但是使用以下代码:

我收到错误消息:在三角形中设置位置的所有行的分配类型不兼容(即:triangle[position] = one;)。

有谁知道我可能做错了什么?

0 投票
1 回答
1513 浏览

c - 从浮动到 mpz_t

我在 C 中使用 GMP。是否可以将 mpz_t 设置为浮点值?

0 投票
1 回答
1263 浏览

php - 安装具有 GMP 扩展要求的 PEAR 包时出现问题

我想安装 Crypt_DiffieHellman PEAR 包,这给了我以下错误:

所以我安装了 gmp 扩展(使用 MacPorts 的“php5-gmp”),php -mextension_loaded('gmp')表明扩展已加载。但是,当我尝试安装软件包时,我仍然收到 PEAR 错误。

我在这里错过了什么吗?或者这是包/PEAR 安装程序的(已知)错误?

0 投票
1 回答
2573 浏览

c - 将 gdb 与 GMP 变量一起使用

我正在用 gdb 调试一些 C 代码。我的程序有一个类型为 的变量mpz_t * retval。如果我运行命令

我得到输出

我还能做些什么来获取有关存储的值的更多信息retval吗?