gmpy

Linux下安装python的gmpy2库及遇到无法定位软件包的解决办法

£可爱£侵袭症+ 提交于 2020-10-31 04:40:47
gmpy2需要gmp.h &mpfr.h &mpc.h 安装命令: sudo apt-get install libmpfr-dev libmpc-dev 成功之后再输入安装命令: pip install gmpy2 若遇到无法定位软件包: 则输入命令:sudo gedit /etc/apt/sources.list 弹出文件,在文件末尾添加: deb http: // mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib 若仍无法安装,可尝试其他kali源: # 163 源 deb http: // mirrors.163.com/debian wheezy main non-free contrib deb-src http: // mirrors.163.com/debian wheezy main non-free contrib deb http: // mirrors.163.com/debian wheezy-proposed-updates main non-free contrib deb-src http: // mirrors.163.com/debian wheezy-proposed-updates main non-free contrib deb-src http: // mirrors

python3安装gmpy2

 ̄綄美尐妖づ 提交于 2020-10-07 07:48:59
和py2py3共存的那篇随笔背景一样,还是新换了电脑,重装很多环境,记录一下 先安装 wheel 文件包 pip3 install wheel 再安装 gmpy2 所需要的 whl 文件,下载地址: https://www.lfd.uci.edu/~gohlke/pythonlibs/ whl 文件包需要和你所安装的 python3 版本一致,我是 python3.7 下载了这个 在 cmd 中输入以下命令完成安装,import 一下没有报错验证成功安装 pip3 install whl文件路径 pip3 install gmpy2 参考: https://blog.csdn.net/qq_43302174/article/details/102933164?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task 来源: oschina 链接: https://my.oschina.net/u/4345306/blog/4473303

Wiener’s attack python

[亡魂溺海] 提交于 2020-08-10 13:28:35
题目如下: 在不分解n的前提下,求d。 给定: e = 14058695417015334071588010346586749790539913287499707802938898719199384604316115908373997739604466972535533733290829894940306314501336291780396644520926473 n = 33608051123287760315508423639768587307044110783252538766412788814888567164438282747809126528707329215122915093543085008547092423658991866313471837522758159 说明过程。 这种e很大的,d可能就会比较小,可能会满足Wiener’s attack的条件,介绍如下: 英文: 中文材料参考: 这里有两个概念,连分数和渐进分数,详情自行谷歌百度 连分数概念图: 渐进分数概念: 我的理解: 上面的等式应该比较容易理解,就是等式右边的分母很大,作为整体很小,意味着等式左边的减数和被减数的差距很小很小,并且可以通过被减数的连分数求解不断逼近它本身的一个渐进分数,因此可能会存在某个渐进分数可以满足减数的要求; 当然按照求解的渐进分数的分子分母分别对应减数的分子分母

gmpy2 log2 not accurate after 16 digits

眉间皱痕 提交于 2020-01-17 09:31:03
问题 When using log2() in gmpy2 it does not seem to be accurate after 16 digits. It seems to work fine at 15 digits but after that the answer is not correct using mpz(mpfr(2) ** mpfr(x)). Do I need change the precision? I thought python by itself would be accurate up to 53 digits. Additionally, is there a way in gmpy2 to use a logarithm operation in bases besides 10 and 2? For example, base 8 or 16. 回答1: The standard Python float type is accurate to 53 bits which is roughly 16 decimal digits.

Does PyPy support gmpy2?

☆樱花仙子☆ 提交于 2020-01-06 23:52:11
问题 It seems from the discussions issue #60 and issue #40 that PyPy couldn't build gmpy before. All I intend to use currently is the probable prime is_prime code which is conveniently in gmpy2. I get the impression that the more calls to gmpy2 means less efficiency for PyPy. Is using gmpy2 possible currently, or do I have to use something like GMPY_CFFI? The error I get when using pip in PyPy is cannot open include file 'mpir.h' 回答1: You should use GMPY_CFFI. gmpy and gmpy2 rely on too many

How to calculate Python float-number-th root of float number

ぐ巨炮叔叔 提交于 2019-12-25 17:05:42
问题 I found the following answer here on Stackoverflow: https://stackoverflow.com/a/356187/1829329 But it only works for integers as n in nth root: import gmpy2 as gmpy result = gmpy.root((1/0.213), 31.5).real print('result:', result) results in: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-14-eb4628226deb> in <module>() 8 ----> 9 result = gmpy.root((1/0.213), 31.5).real 10 11 print('result:', result)

pip installation of gmpy2

99封情书 提交于 2019-12-08 11:14:54
问题 When I used pip to install gmpy2, I always got the version 1.16, i.e. gmpy instead of gmpy2. $ pip search gmpy gmpy - GMP or MPIR interface to Python 2.4+ and 3.x INSTALLED: 1.16 (latest) Is there any way to directly install gmpy2 through pip? 回答1: I have added gmpy2 to the Python Package Index. gmpy2 requires GMP 5.0 or later, MPFR 3.1 or later, and MPC 1.0 or later. You may need to compile your own version of those libraries if your operating system doesn't provide the latest versions.

Python: reduced row echelon form (mod p) of a very large matrix

风流意气都作罢 提交于 2019-12-08 08:10:02
问题 I want to find find a reduced a row echelon form (in field F_q) of a big matrix. I tried the following code. Although I used gmpy2 library to speed up, the program was still out of memory. because my input matrix is very large (100 x 2^15) and p is also very large (|p|=256 bits). Can someone suggest how to reduce the complexity of this alg. Thank you def invmodp(a, p): return gmpy2.invert(a,p) def division_mod(a, b, p): #a/b mod p invert = invmodp(b, p) return (a * invert) %p def row_echelon

How do I make gmpy array operations faster?

依然范特西╮ 提交于 2019-12-02 20:24:31
问题 I've been having trouble with speed while trying to utilise the gmpy module. import numpy as np import gmpy2 as gm N = 1000 a = range(N) %timeit [gm.sin(x) for x in a] # 100 loops, best of 3: 7.39 ms per loop %timeit np.sin(a) # 10000 loops, best of 3: 198 us per loop I was wondering if I could somehow speed this computation. I was thinking JIT or multiprocessing might help but I haven't figured out how to do it. Any help would be greatly appreciated. If you want me to post more information

How do I make gmpy array operations faster?

守給你的承諾、 提交于 2019-12-02 07:30:50
I've been having trouble with speed while trying to utilise the gmpy module. import numpy as np import gmpy2 as gm N = 1000 a = range(N) %timeit [gm.sin(x) for x in a] # 100 loops, best of 3: 7.39 ms per loop %timeit np.sin(a) # 10000 loops, best of 3: 198 us per loop I was wondering if I could somehow speed this computation. I was thinking JIT or multiprocessing might help but I haven't figured out how to do it. Any help would be greatly appreciated. If you want me to post more information please let me know. I was curious to see how much performance increase would be possible so wrote a new