Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

How to translate a 2007 sympy/sage/python code to a modern day sympy/python code?

Me struggling with the General Number Field Sieve : round 2 ! As usual : english is not my first langage so 'sorry for bad english'. So : I'm trying to implement this algorithm and to do it I'm heavily relying on sympy. But I'm also basing parts of my work on the code of Pr. William Stein (https://wstein.org/misc/aly-lll/gnfs.html), written in python/sympy/sage in 2007.

In it, there is this peice of code (which, of course, happens to be one of the most important) :

def find_kernel_vectors(M):
    return M.kernel().basis_matrix().rows()    [1]

It will be applied the matrix :

M = Matrix(GF(2), len(sel), ev)    [2]

where sel is a list and ev the coefficients of the matrix, which are each either 0 or 1.

However, when I copy-paste it, adding from sympy import Matrix, GF, I run in quite a lot of troubles.

Upon execution of [2], I get the error message GF(2) is not an integer I looked up how to use matrices in sympy and from what I gathered, only the list of coefficients in an acceptable input.

So I decided to define M as follows in order to be able to test [1] :

M = Matrix(ev)

And upon execution of 1, I get the error message MutableDenseMatrix has no attribute kernel

The thing is, it's not the first time that things like this happen, because Pr. Stein was coding in a 2007 version of python/sympy/sage.

I don't really think that the issue with [2] is an actual issue because, as I said, the coefficients of my matrix are already 0 or 1 (i.e. elements of GF(2)), however I'm not sure about it. But I'm sure about the fact that [1] is a big issue that I don't have any idea to solve.

I beleive it all boils down to the translation between 2007 sage/sympy/python to modern day python, so if someone knows how to do it, it would save my code.

Thanks a lot !

question from:https://stackoverflow.com/questions/65833914/how-to-translate-a-2007-sympy-sage-python-code-to-a-modern-day-sympy-python-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...