81 questions
3
votes
0
answers
138
views
Memory usage accumulates in simple loop until PC crashes
I have recently experienced major crashes on my computer after executing some Python code of mine. My PC would freeze and sometimes show a bluescreen after a few rounds of a seemingly unproblematic ...
1
vote
0
answers
58
views
Cython function to return array of mpz_t objects
I am trying to write a Cython function which returns an array of mpz_t (number type of integers from the gmpy2 library). I can successfully define a fixed-size array:
cpdef void pows(mpz number):
...
0
votes
0
answers
23
views
How to add a column in a panda series that contains the exponential of another column in multiprecision? [duplicate]
Considering this panda data frame :
df = pd.DataFrame({'x': list(range(-10000, 10001, 1000))})
I would like to insert a column (named exp_x) that contains the exponential of these numbers.
Multi ...
2
votes
0
answers
65
views
How to change __repr__ for an imported class of immutable type
I am using gmpy2 to work with high-precision floats (>500 bit of precision). My code contains long lists of such floats, e.g.
import gmpy2
gmpy2.get_context().precision = 500
rs = gmpy2....
0
votes
0
answers
80
views
Using Conda environment in Matlab on Windows (import DLL error)
The conda environment with numpy and gmpy2 packages was created using
conda create --name py4mat python=3.9 numpy gmpy2
Created environment was tested using
PS C:\_users\rad> conda activate py4mat
...
1
vote
2
answers
772
views
Preventing overflow of large integers in (GPU) optimized methods such as gmpy2 and numba
I am trying to check whether a large integer is a perfect square using gmpy2 in a JIT-decorated (optimized) routine using numba. The example here is for illustrative purposes only (from a theoretical ...
1
vote
3
answers
148
views
How to check if a variable is an instance of mpfr in Python 3?
I want to know how to check whether a variable is of type mpfr or not, this might sound trivial but a simple isinstance(v, mpfr) can't do the trick.
Example: create a variable that is an instance of ...
0
votes
1
answer
887
views
How to install gmpy2 on Google Colab?
I am trying to install "gmpy2" on Google Colab via the command:
!pip3 install gmpy2
I get the error:
Collecting gmpy2
Downloading gmpy2-2.0.8.zip (280 kB)
|███████████████████████████...
1
vote
1
answer
148
views
Pylint cannot recognize gmpy2 members
I use pylint and gmpy2 on Kali Linux(WSL2). Pylint makes many complaints about being unable to find gmpy2 members. How can I avoid this?
Here is a little example:
import gmpy2
print(gmpy2.is_even(6))
...
0
votes
1
answer
1k
views
Python: inverse a matrix with high precision floats
I am following a tutorial on how to work on multiple-precision arithmetic in Python.
In the end I would like to have a numpy array with floats of arbitrary high precision and I need to inverse that ...
0
votes
1
answer
357
views
How to compare various multiplication algorithms over a range of numbers
While going through a MIT lecture in MITOpencourseware (6.006 lecture 12), I came across the mention of 4 multiplication algorithms (to multiply two n-digit numbers) -
Ordinary naive approach with O(...
1
vote
1
answer
758
views
Cython same classes with different types
I have two cdef classes B and C whose methods are exactly the same. The only difference between them is the type of their attributes: one has mpz attributes, the other one int attributes.
My first ...
2
votes
1
answer
289
views
Is there a c++ gmp library function that does the same as the python gmpy2 library divm(...) function?
Just as the title says I am trying to find a function in the C++ gmp library that does the same thing as the gmpy2 python library's divm(...) function.
I can't imagine that gmpy2 has this method and ...
2
votes
1
answer
5k
views
Python: "pip install gmpy" on Windows 10 returns "cl.exe' failed with exit status 2"
I've installed Pyhton 3.7 on Windows10 and when I run pip install gmpy the console return me this error:
Collecting gmpy
Using cached https://files.pythonhosted.org/packages/26/37/...
1
vote
1
answer
1k
views
Has anyone encountered the same Error while installing ludwig on colab?
I'm getting the below error while installing ludwig on colab. Tried a few things but not able to resolve this.
ERROR: Command "/usr/bin/python3 -u -c 'import setuptools, tokenize;file='"'"'/tmp/pip-...
3
votes
2
answers
112
views
How to tackle calculating then verifying 10^8 solutions to find the one true answer?
I have a number which is 615 digits in length. Throughout the number, there 8 fixed places where a digit is missing. I have to find what those missing digits are. So there are 10^8 possibilities. ...
0
votes
1
answer
93
views
gmpy2 qdiv() returns mpq where mpz would be possible
I wonder if I don't get something here... Why does qdiv(8,2) return an mpq instead of an mpz?
See here:
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "...
1
vote
1
answer
838
views
How can I set the precision of a number to have 10 decimal digits using the python module gmpy2
I created the following piece of python code. It should first set the precision of numbers to 10 decimal digits, but printing pi shows 3.156, which only has 3 decimal digits! Would someone please let ...
1
vote
1
answer
191
views
Storing really huge ints in MySQL
Is it possible to efficiently store big ints in MySQL? Not big as in bigint, more like 1000th Catalan number or so, and there are at least hundreds of them. More likely, thousands. The speed of ...
0
votes
1
answer
199
views
How could I implement a xor operation of big integers with gmpy?
I want to xor two big integers.
Just installed the gmpy2 library, but no mpz_xor operation anywhere.
Am I missing something?
2
votes
1
answer
1k
views
Python Numpy Exponential Value from Array of BigFloats
I'm trying to compute the natural log of the exponential plus the median of an array but precision of the floating point numbers has to be at 2000 or the answer will always be 0.
Here is what I have ...
0
votes
1
answer
616
views
GMPY2 - How to avoid gmpy2.floor() returning mpfr instead of mpz?
After using gmpy2.floor() on an mpz variable:
x = mpz(5)
x = gmpy2.floor(x/256)
x has the type mpfr and not mpz anymore, even though to my understanding, floor always returns integers.
How can I ...
0
votes
2
answers
1k
views
gmpy2 installs but can't find libmpc.so.3
I want to use gmpy2 with python 2.7 but when I try to import it I get:
>>> import gmpy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: ...
2
votes
1
answer
1k
views
Python multi-precision rational comparison: Fraction, mpq and mpfr
I understand that floating-point calculation is not accurate due to its nature. I'm trying to find out the best library/way to do multi-precision ration comparison. I'm comparing Fraction, mpq and ...
0
votes
3
answers
354
views
Python - How to avoid discrepancy of base y**log base y of x, in gmpy2
The Following code examples my problem which does not occur between 10 power 10 and 10 power 11, but does for the example given in code and above it.
I can't see where in my code I am not properly ...