-
-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unnecessary constraint for berlekamp_massey
function
#39082
base: develop
Are you sure you want to change the base?
Conversation
Documentation preview for this PR (built with commit 7374bd5; changes) is ready! 🎉 |
please add doctests for the new capabilities |
also check the failures reported above in
|
hly@DESKTOP-0UAQV2N:~/repos/sage$ ./sage -t --long --warn-long 30.0 --random-seed=286735480429121101562228604801325644303 src/sage/mat
rix/matrix2.pyx
Running doctests with ID 2024-12-07-19-11-45-0dc28d8d.
Git branch: dev/bm
Git ref: 1ef8b18488f
Running with SAGE_LOCAL='/home/hly/repos/sage/local' and SAGE_VENV='/home/hly/repos/sage/local/var/lib/sage/venv-python3.12.5'
Using --optional=debian,pip,sage,sage_spkg
Features to be detected: 4ti2,SAGE_SRC,benzene,bliss,buckygen,conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_ellcurves,database_graphs,database_jones_numfield,database_knotinfo,dot2tex,dvipng,ecm,fpylll,fricas,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polenta,gap_package_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,giac,glucose,graphviz,imagemagick,info,ipython,jmol,jupymake,jupyter_sphinx,kenzo,kissat,latte_int,lrcalc_python,lrslib,mathics,matroid_database,mcqd,meataxe,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pycosat,pycryptosat,pynormaliz,pyparsing,python_igraph,requests,rpy2,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.braiding,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.giac,sage.libs.homfly,sage.libs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,scipy,singular,sirocco,sloane_database,sphinx,symengine_py,sympy,tdlib,threejs,topcom
Doctesting 1 file.
sage -t --long --warn-long 30.0 --random-seed=286735480429121101562228604801325644303 src/sage/matrix/matrix2.pyx
**********************************************************************
File "src/sage/matrix/matrix2.pyx", line 6158, in sage.matrix.matrix2.Matrix.wiedemann
Failed example:
t.wiedemann(0)
Expected:
x^2 - 12*x - 18
Got:
x^3 - 12*x^2 - 18*x
**********************************************************************
1 item had failures:
1 of 4 in sage.matrix.matrix2.Matrix.wiedemann
[2932 tests, 1 failure, 11.72s wall]
----------------------------------------------------------------------
sage -t --long --warn-long 30.0 --random-seed=286735480429121101562228604801325644303 src/sage/matrix/matrix2.pyx # 1 doctest failed
----------------------------------------------------------------------
Total time for all tests: 12.9 seconds
cpu time: 9.5 seconds
cumulative wall time: 11.7 seconds
Features detected for doctesting: numpy,pillow,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.flint,sage.libs.m4ri,sage.libs.pari,sage.libs.singular,sage.modular,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.real_mpfr,sage.symbolic,scipy sage/src/sage/matrix/matrix2.pyx Lines 6138 to 6190 in 8a972c4
It seems that the reason is that the original implementation is incorrect. Test on sagecell. The minimal polynomial of |
Thanks for reviewing! I am going to add some doctests for the odd length case, but I can't add cases that the characteristic polynomial is not unique since it seems the output of any valid characteristic polynomial is okay but the algorithm only gives one so the verification may needs some special treatment. |
I also fixed the statement in Since we find the denominator of a rational power series |
resolve #33537
The original implementation only works when the length of the given sequence is a mitiple of 2, and only gives the correct characteristic polynomial when the length of the sequence is at least double of the degree of characteristic polynomial. I removed these unnecessary constraints by making a new implementation.
I will add some descriptions of the modification later.UPD: added.If my implementation is not correct, please tell me, thanks!
The idea of this implementation is based on the continued fraction and rational reconstruction (If we are given fractional part of a rational number, we can do it similarly), I have made a code snippet and some comments to explain how it works.
For the definition of$\mathbb{K}((x^{-1}))$ , one can find it in Shoup's book: A Computational Introduction to Number Theory and Algebra (v2) pp. 448. url: https://www.shoup.net/ntb/
If you are familiar with the formal Laurent Series Ring$\mathbb{K}((x))$ , just replace $x$ with $x^{-1}$ .
Then we will find that we are actually computing the denominator of continued fraction, so it convenient to make an iterative implementation.
📝 Checklist
⌛ Dependencies