Skip to content

Avoiding to use polredbest, as it can be quite expensive #39920

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

Merged
merged 9 commits into from
Jun 25, 2025

Conversation

edgarcosta
Copy link
Member

@edgarcosta edgarcosta commented Apr 9, 2025

In #252 calling polredbest was made standard to workaround not integral or not monic defining polynomials.
This is an excellent workaround for small polynomials, but it takes $$O(b^2 d^5)$$ time, where $$d$$ is the degree and $$b$$ is the bitsize of the polynomial, as it calls LLL lattice basis reduction algorithm

I expect some tests will fail when it depends on the internal representation for the number field.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

Copy link

github-actions bot commented Apr 9, 2025

Documentation preview for this PR (built with commit e0c3978; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729
Copy link
Contributor

Sounds like good idea. As long as someone's willing to fix the doctests.

Do add a doctest for a case that was made (much) faster by this change.

@edgarcosta
Copy link
Member Author

I will fix the tests. Once I get this branch to compile on my computer.

What is the added value of the doctest? For one to feel the difference one needs to input a high degree polynomial, and the output is going to painfully long, e.g.:

Old:

sage: K = NumberField(ZZ['x']([1 for _ in range(100)] + [5]), 'a')
sage: time K._pari_absolute_structure()
CPU times: user 1.42 s, sys: 11.8 ms, total: 1.43 s
Wall time: 1.43 s
(y^100 - y^99 + y^98 - y^97 + y^96 - y^95 + y^94 - y^93 + y^92 - y^91 + y^90 - y^89 + y^88 - y^87 + y^86 - y^85 + y^84 - y^83 + y^82 - y^81 + y^80 - y^79 + y^78 - y^77 + y^76 - y^75 + y^74 - y^73 + y^72 - y^71 + y^70 - y^69 + y^68 - y^67 + y^66 - y^65 + y^64 - y^63 + y^62 - y^61 + y^60 - y^59 + y^58 - y^57 + y^56 - y^55 + y^54 - y^53 + y^52 - y^51 + y^50 - y^49 + y^48 - y^47 + y^46 - y^45 + y^44 - y^43 + y^42 - y^41 + y^40 - y^39 + y^38 - y^37 + y^36 - y^35 + y^34 - y^33 + y^32 - y^31 + y^30 - y^29 + y^28 - y^27 + y^26 - y^25 + y^24 - y^23 + y^22 - y^21 + y^20 - y^19 + y^18 - y^17 + y^16 - y^15 + y^14 - y^13 + y^12 - y^11 + y^10 - y^9 + y^8 - y^7 + y^6 - y^5 + y^4 - y^3 + y^2 - y + 5,
 Mod(1/5*y^99 - 1/5*y^98 + 1/5*y^97 - 1/5*y^96 + 1/5*y^95 - 1/5*y^94 + 1/5*y^93 - 1/5*y^92 + 1/5*y^91 - 1/5*y^90 + 1/5*y^89 - 1/5*y^88 + 1/5*y^87 - 1/5*y^86 + 1/5*y^85 - 1/5*y^84 + 1/5*y^83 - 1/5*y^82 + 1/5*y^81 - 1/5*y^80 + 1/5*y^79 - 1/5*y^78 + 1/5*y^77 - 1/5*y^76 + 1/5*y^75 - 1/5*y^74 + 1/5*y^73 - 1/5*y^72 + 1/5*y^71 - 1/5*y^70 + 1/5*y^69 - 1/5*y^68 + 1/5*y^67 - 1/5*y^66 + 1/5*y^65 - 1/5*y^64 + 1/5*y^63 - 1/5*y^62 + 1/5*y^61 - 1/5*y^60 + 1/5*y^59 - 1/5*y^58 + 1/5*y^57 - 1/5*y^56 + 1/5*y^55 - 1/5*y^54 + 1/5*y^53 - 1/5*y^52 + 1/5*y^51 - 1/5*y^50 + 1/5*y^49 - 1/5*y^48 + 1/5*y^47 - 1/5*y^46 + 1/5*y^45 - 1/5*y^44 + 1/5*y^43 - 1/5*y^42 + 1/5*y^41 - 1/5*y^40 + 1/5*y^39 - 1/5*y^38 + 1/5*y^37 - 1/5*y^36 + 1/5*y^35 - 1/5*y^34 + 1/5*y^33 - 1/5*y^32 + 1/5*y^31 - 1/5*y^30 + 1/5*y^29 - 1/5*y^28 + 1/5*y^27 - 1/5*y^26 + 1/5*y^25 - 1/5*y^24 + 1/5*y^23 - 1/5*y^22 + 1/5*y^21 - 1/5*y^20 + 1/5*y^19 - 1/5*y^18 + 1/5*y^17 - 1/5*y^16 + 1/5*y^15 - 1/5*y^14 + 1/5*y^13 - 1/5*y^12 + 1/5*y^11 - 1/5*y^10 + 1/5*y^9 - 1/5*y^8 + 1/5*y^7 - 1/5*y^6 + 1/5*y^5 - 1/5*y^4 + 1/5*y^3 - 1/5*y^2 + 1/5*y - 1/5, y^100 - y^99 + y^98 - y^97 + y^96 - y^95 + y^94 - y^93 + y^92 - y^91 + y^90 - y^89 + y^88 - y^87 + y^86 - y^85 + y^84 - y^83 + y^82 - y^81 + y^80 - y^79 + y^78 - y^77 + y^76 - y^75 + y^74 - y^73 + y^72 - y^71 + y^70 - y^69 + y^68 - y^67 + y^66 - y^65 + y^64 - y^63 + y^62 - y^61 + y^60 - y^59 + y^58 - y^57 + y^56 - y^55 + y^54 - y^53 + y^52 - y^51 + y^50 - y^49 + y^48 - y^47 + y^46 - y^45 + y^44 - y^43 + y^42 - y^41 + y^40 - y^39 + y^38 - y^37 + y^36 - y^35 + y^34 - y^33 + y^32 - y^31 + y^30 - y^29 + y^28 - y^27 + y^26 - y^25 + y^24 - y^23 + y^22 - y^21 + y^20 - y^19 + y^18 - y^17 + y^16 - y^15 + y^14 - y^13 + y^12 - y^11 + y^10 - y^9 + y^8 - y^7 + y^6 - y^5 + y^4 - y^3 + y^2 - y + 5),
 Mod(5*y^99 + y^98 + y^97 + y^96 + y^95 + y^94 + y^93 + y^92 + y^91 + y^90 + y^89 + y^88 + y^87 + y^86 + y^85 + y^84 + y^83 + y^82 + y^81 + y^80 + y^79 + y^78 + y^77 + y^76 + y^75 + y^74 + y^73 + y^72 + y^71 + y^70 + y^69 + y^68 + y^67 + y^66 + y^65 + y^64 + y^63 + y^62 + y^61 + y^60 + y^59 + y^58 + y^57 + y^56 + y^55 + y^54 + y^53 + y^52 + y^51 + y^50 + y^49 + y^48 + y^47 + y^46 + y^45 + y^44 + y^43 + y^42 + y^41 + y^40 + y^39 + y^38 + y^37 + y^36 + y^35 + y^34 + y^33 + y^32 + y^31 + y^30 + y^29 + y^28 + y^27 + y^26 + y^25 + y^24 + y^23 + y^22 + y^21 + y^20 + y^19 + y^18 + y^17 + y^16 + y^15 + y^14 + y^13 + y^12 + y^11 + y^10 + y^9 + y^8 + y^7 + y^6 + y^5 + y^4 + y^3 + y^2 + y + 1, y^100 + 1/5*y^99 + 1/5*y^98 + 1/5*y^97 + 1/5*y^96 + 1/5*y^95 + 1/5*y^94 + 1/5*y^93 + 1/5*y^92 + 1/5*y^91 + 1/5*y^90 + 1/5*y^89 + 1/5*y^88 + 1/5*y^87 + 1/5*y^86 + 1/5*y^85 + 1/5*y^84 + 1/5*y^83 + 1/5*y^82 + 1/5*y^81 + 1/5*y^80 + 1/5*y^79 + 1/5*y^78 + 1/5*y^77 + 1/5*y^76 + 1/5*y^75 + 1/5*y^74 + 1/5*y^73 + 1/5*y^72 + 1/5*y^71 + 1/5*y^70 + 1/5*y^69 + 1/5*y^68 + 1/5*y^67 + 1/5*y^66 + 1/5*y^65 + 1/5*y^64 + 1/5*y^63 + 1/5*y^62 + 1/5*y^61 + 1/5*y^60 + 1/5*y^59 + 1/5*y^58 + 1/5*y^57 + 1/5*y^56 + 1/5*y^55 + 1/5*y^54 + 1/5*y^53 + 1/5*y^52 + 1/5*y^51 + 1/5*y^50 + 1/5*y^49 + 1/5*y^48 + 1/5*y^47 + 1/5*y^46 + 1/5*y^45 + 1/5*y^44 + 1/5*y^43 + 1/5*y^42 + 1/5*y^41 + 1/5*y^40 + 1/5*y^39 + 1/5*y^38 + 1/5*y^37 + 1/5*y^36 + 1/5*y^35 + 1/5*y^34 + 1/5*y^33 + 1/5*y^32 + 1/5*y^31 + 1/5*y^30 + 1/5*y^29 + 1/5*y^28 + 1/5*y^27 + 1/5*y^26 + 1/5*y^25 + 1/5*y^24 + 1/5*y^23 + 1/5*y^22 + 1/5*y^21 + 1/5*y^20 + 1/5*y^19 + 1/5*y^18 + 1/5*y^17 + 1/5*y^16 + 1/5*y^15 + 1/5*y^14 + 1/5*y^13 + 1/5*y^12 + 1/5*y^11 + 1/5*y^10 + 1/5*y^9 + 1/5*y^8 + 1/5*y^7 + 1/5*y^6 + 1/5*y^5 + 1/5*y^4 + 1/5*y^3 + 1/5*y^2 + 1/5*y + 1/5))

New:

sage: K = NumberField(ZZ['x']([1 for _ in range(100)] + [5]), 'a')
sage: time K._pari_absolute_structure()
CPU times: user 1.42 s, sys: 11.8 ms, total: 1.43 s
Wall time: 1.43 s
CPU times: user 13.6 ms, sys: 302 µs, total: 13.9 ms
Wall time: 15.1 ms
(y^100 + y^99 + 5*y^98 + 25*y^97 + 125*y^96 + 625*y^95 + 3125*y^94 + 15625*y^93 + 78125*y^92 + 390625*y^91 + 1953125*y^90 + 9765625*y^89 + 48828125*y^88 + 244140625*y^87 + 1220703125*y^86 + 6103515625*y^85 + 30517578125*y^84 + 152587890625*y^83 + 762939453125*y^82 + 3814697265625*y^81 + 19073486328125*y^80 + 95367431640625*y^79 + 476837158203125*y^78 + 2384185791015625*y^77 + 11920928955078125*y^76 + 59604644775390625*y^75 + 298023223876953125*y^74 + 1490116119384765625*y^73 + 7450580596923828125*y^72 + 37252902984619140625*y^71 + 186264514923095703125*y^70 + 931322574615478515625*y^69 + 4656612873077392578125*y^68 + 23283064365386962890625*y^67 + 116415321826934814453125*y^66 + 582076609134674072265625*y^65 + 2910383045673370361328125*y^64 + 14551915228366851806640625*y^63 + 72759576141834259033203125*y^62 + 363797880709171295166015625*y^61 + 1818989403545856475830078125*y^60 + 9094947017729282379150390625*y^59 + 45474735088646411895751953125*y^58 + 227373675443232059478759765625*y^57 + 1136868377216160297393798828125*y^56 + 5684341886080801486968994140625*y^55 + 28421709430404007434844970703125*y^54 + 142108547152020037174224853515625*y^53 + 710542735760100185871124267578125*y^52 + 3552713678800500929355621337890625*y^51 + 17763568394002504646778106689453125*y^50 + 88817841970012523233890533447265625*y^49 + 444089209850062616169452667236328125*y^48 + 2220446049250313080847263336181640625*y^47 + 11102230246251565404236316680908203125*y^46 + 55511151231257827021181583404541015625*y^45 + 277555756156289135105907917022705078125*y^44 + 1387778780781445675529539585113525390625*y^43 + 6938893903907228377647697925567626953125*y^42 + 34694469519536141888238489627838134765625*y^41 + 173472347597680709441192448139190673828125*y^40 + 867361737988403547205962240695953369140625*y^39 + 4336808689942017736029811203479766845703125*y^38 + 21684043449710088680149056017398834228515625*y^37 + 108420217248550443400745280086994171142578125*y^36 + 542101086242752217003726400434970855712890625*y^35 + 2710505431213761085018632002174854278564453125*y^34 + 13552527156068805425093160010874271392822265625*y^33 + 67762635780344027125465800054371356964111328125*y^32 + 338813178901720135627329000271856784820556640625*y^31 + 1694065894508600678136645001359283924102783203125*y^30 + 8470329472543003390683225006796419620513916015625*y^29 + 42351647362715016953416125033982098102569580078125*y^28 + 211758236813575084767080625169910490512847900390625*y^27 + 1058791184067875423835403125849552452564239501953125*y^26 + 5293955920339377119177015629247762262821197509765625*y^25 + 26469779601696885595885078146238811314105987548828125*y^24 + 132348898008484427979425390731194056570529937744140625*y^23 + 661744490042422139897126953655970282852649688720703125*y^22 + 3308722450212110699485634768279851414263248443603515625*y^21 + 16543612251060553497428173841399257071316242218017578125*y^20 + 82718061255302767487140869206996285356581211090087890625*y^19 + 413590306276513837435704346034981426782906055450439453125*y^18 + 2067951531382569187178521730174907133914530277252197265625*y^17 + 10339757656912845935892608650874535669572651386260986328125*y^16 + 51698788284564229679463043254372678347863256931304931640625*y^15 + 258493941422821148397315216271863391739316284656524658203125*y^14 + 1292469707114105741986576081359316958696581423282623291015625*y^13 + 6462348535570528709932880406796584793482907116413116455078125*y^12 + 32311742677852643549664402033982923967414535582065582275390625*y^11 + 161558713389263217748322010169914619837072677910327911376953125*y^10 + 807793566946316088741610050849573099185363389551639556884765625*y^9 + 4038967834731580443708050254247865495926816947758197784423828125*y^8 + 20194839173657902218540251271239327479634084738790988922119140625*y^7 + 100974195868289511092701256356196637398170423693954944610595703125*y^6 + 504870979341447555463506281780983186990852118469774723052978515625*y^5 + 2524354896707237777317531408904915934954260592348873615264892578125*y^4 + 12621774483536188886587657044524579674771302961744368076324462890625*y^3 + 63108872417680944432938285222622898373856514808721840381622314453125*y^2 + 315544362088404722164691426113114491869282574043609201908111572265625*y + 1577721810442023610823457130565572459346412870218046009540557861328125,
Mod(1/5*y, y^100 + y^99 + 5*y^98 + 25*y^97 + 125*y^96 + 625*y^95 + 3125*y^94 + 15625*y^93 + 78125*y^92 + 390625*y^91 + 1953125*y^90 + 9765625*y^89 + 48828125*y^88 + 244140625*y^87 + 1220703125*y^86 + 6103515625*y^85 + 30517578125*y^84 + 152587890625*y^83 + 762939453125*y^82 + 3814697265625*y^81 + 19073486328125*y^80 + 95367431640625*y^79 + 476837158203125*y^78 + 2384185791015625*y^77 + 11920928955078125*y^76 + 59604644775390625*y^75 + 298023223876953125*y^74 + 1490116119384765625*y^73 + 7450580596923828125*y^72 + 37252902984619140625*y^71 + 186264514923095703125*y^70 + 931322574615478515625*y^69 + 4656612873077392578125*y^68 + 23283064365386962890625*y^67 + 116415321826934814453125*y^66 + 582076609134674072265625*y^65 + 2910383045673370361328125*y^64 + 14551915228366851806640625*y^63 + 72759576141834259033203125*y^62 + 363797880709171295166015625*y^61 + 1818989403545856475830078125*y^60 + 9094947017729282379150390625*y^59 + 45474735088646411895751953125*y^58 + 227373675443232059478759765625*y^57 + 1136868377216160297393798828125*y^56 + 5684341886080801486968994140625*y^55 + 28421709430404007434844970703125*y^54 + 142108547152020037174224853515625*y^53 + 710542735760100185871124267578125*y^52 + 3552713678800500929355621337890625*y^51 + 17763568394002504646778106689453125*y^50 + 88817841970012523233890533447265625*y^49 + 444089209850062616169452667236328125*y^48 + 2220446049250313080847263336181640625*y^47 + 11102230246251565404236316680908203125*y^46 + 55511151231257827021181583404541015625*y^45 + 277555756156289135105907917022705078125*y^44 + 1387778780781445675529539585113525390625*y^43 + 6938893903907228377647697925567626953125*y^42 + 34694469519536141888238489627838134765625*y^41 + 173472347597680709441192448139190673828125*y^40 + 867361737988403547205962240695953369140625*y^39 + 4336808689942017736029811203479766845703125*y^38 + 21684043449710088680149056017398834228515625*y^37 + 108420217248550443400745280086994171142578125*y^36 + 542101086242752217003726400434970855712890625*y^35 + 2710505431213761085018632002174854278564453125*y^34 + 13552527156068805425093160010874271392822265625*y^33 + 67762635780344027125465800054371356964111328125*y^32 + 338813178901720135627329000271856784820556640625*y^31 + 1694065894508600678136645001359283924102783203125*y^30 + 8470329472543003390683225006796419620513916015625*y^29 + 42351647362715016953416125033982098102569580078125*y^28 + 211758236813575084767080625169910490512847900390625*y^27 + 1058791184067875423835403125849552452564239501953125*y^26 + 5293955920339377119177015629247762262821197509765625*y^25 + 26469779601696885595885078146238811314105987548828125*y^24 + 132348898008484427979425390731194056570529937744140625*y^23 + 661744490042422139897126953655970282852649688720703125*y^22 + 3308722450212110699485634768279851414263248443603515625*y^21 + 16543612251060553497428173841399257071316242218017578125*y^20 + 82718061255302767487140869206996285356581211090087890625*y^19 + 413590306276513837435704346034981426782906055450439453125*y^18 + 2067951531382569187178521730174907133914530277252197265625*y^17 + 10339757656912845935892608650874535669572651386260986328125*y^16 + 51698788284564229679463043254372678347863256931304931640625*y^15 + 258493941422821148397315216271863391739316284656524658203125*y^14 + 1292469707114105741986576081359316958696581423282623291015625*y^13 + 6462348535570528709932880406796584793482907116413116455078125*y^12 + 32311742677852643549664402033982923967414535582065582275390625*y^11 + 161558713389263217748322010169914619837072677910327911376953125*y^10 + 807793566946316088741610050849573099185363389551639556884765625*y^9 + 4038967834731580443708050254247865495926816947758197784423828125*y^8 + 20194839173657902218540251271239327479634084738790988922119140625*y^7 + 100974195868289511092701256356196637398170423693954944610595703125*y^6 + 504870979341447555463506281780983186990852118469774723052978515625*y^5 + 2524354896707237777317531408904915934954260592348873615264892578125*y^4 + 12621774483536188886587657044524579674771302961744368076324462890625*y^3 + 63108872417680944432938285222622898373856514808721840381622314453125*y^2 + 315544362088404722164691426113114491869282574043609201908111572265625*y + 1577721810442023610823457130565572459346412870218046009540557861328125),
Mod(5*y, y^100 + 1/5*y^99 + 1/5*y^98 + 1/5*y^97 + 1/5*y^96 + 1/5*y^95 + 1/5*y^94 + 1/5*y^93 + 1/5*y^92 + 1/5*y^91 + 1/5*y^90 + 1/5*y^89 + 1/5*y^88 + 1/5*y^87 + 1/5*y^86 + 1/5*y^85 + 1/5*y^84 + 1/5*y^83 + 1/5*y^82 + 1/5*y^81 + 1/5*y^80 + 1/5*y^79 + 1/5*y^78 + 1/5*y^77 + 1/5*y^76 + 1/5*y^75 + 1/5*y^74 + 1/5*y^73 + 1/5*y^72 + 1/5*y^71 + 1/5*y^70 + 1/5*y^69 + 1/5*y^68 + 1/5*y^67 + 1/5*y^66 + 1/5*y^65 + 1/5*y^64 + 1/5*y^63 + 1/5*y^62 + 1/5*y^61 + 1/5*y^60 + 1/5*y^59 + 1/5*y^58 + 1/5*y^57 + 1/5*y^56 + 1/5*y^55 + 1/5*y^54 + 1/5*y^53 + 1/5*y^52 + 1/5*y^51 + 1/5*y^50 + 1/5*y^49 + 1/5*y^48 + 1/5*y^47 + 1/5*y^46 + 1/5*y^45 + 1/5*y^44 + 1/5*y^43 + 1/5*y^42 + 1/5*y^41 + 1/5*y^40 + 1/5*y^39 + 1/5*y^38 + 1/5*y^37 + 1/5*y^36 + 1/5*y^35 + 1/5*y^34 + 1/5*y^33 + 1/5*y^32 + 1/5*y^31 + 1/5*y^30 + 1/5*y^29 + 1/5*y^28 + 1/5*y^27 + 1/5*y^26 + 1/5*y^25 + 1/5*y^24 + 1/5*y^23 + 1/5*y^22 + 1/5*y^21 + 1/5*y^20 + 1/5*y^19 + 1/5*y^18 + 1/5*y^17 + 1/5*y^16 + 1/5*y^15 + 1/5*y^14 + 1/5*y^13 + 1/5*y^12 + 1/5*y^11 + 1/5*y^10 + 1/5*y^9 + 1/5*y^8 + 1/5*y^7 + 1/5*y^6 + 1/5*y^5 + 1/5*y^4 + 1/5*y^3 + 1/5*y^2 + 1/5*y + 1/5))

ps: it might be worth to run polredbest for small inputs, but the threshold will depend strongly on the what follows up next, so I will just add the methods polredbest/polredabs in another PR

@user202729
Copy link
Contributor

the threshold will depend strongly on the what follows up next

you're right, it seems likely that it would be difficult to determine accurately.

I think it would suffice if user have a manual knob to run it if they want to. (Likely they wouldn't though)

What is the added value of the doctest?

Just add a Ensure this finishes in reasonable time (1s on my computer):: [something]. The output itself can be (...) or # random. So that if something else degrades the performance we would know. (That's the whole point of doctest right?)

Why do you need to call an internal method to benchmark it anyway? Surely it should be visible to users?

@edgarcosta
Copy link
Member Author

Ok, I will add something like:

sage: K = NumberField(ZZ['x']([1 for _ in range(101)] + [5]), 'a')
sage:  K.is_isomorphic(NumberField(ZZ['x']([1,1]), 'b'))
CPU times: user 1.4 s, sys: 9.49 ms, total: 1.41 s
Wall time: 1.41 s
False

@edgarcosta
Copy link
Member Author

All the tests pass locally.

@edgarcosta
Copy link
Member Author

I thinks this ready for review again, all tests pass

@roed314
Copy link
Contributor

roed314 commented Jun 13, 2025

Looks good to me.

@edgarcosta
Copy link
Member Author

I looked further, and _pari_absolute_structure is used very minimally.
For example, internal arithmetic is done via NTL and using the given the initial polynomial.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 15, 2025
sagemathgh-39920: Avoiding to use polredbest, as it can be quite expensive
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

In sagemath#252 calling `polredbest` was made standard to workaround not
integral or not monic defining polynomials.
This is an excellent workaround for small polynomials, but it takes
$$O(b^2 d^5)$$ time, where $$d$$ is the degree and $$b$$ is the bitsize
of the polynomial, as it calls [LLL lattice basis reduction algorithm](h
ttps://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz
_lattice_basis_reduction_algorithm)

I expect some tests will fail when it depends on the internal
representation for the number field.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

-  [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#39920
Reported by: Edgar Costa
Reviewer(s): Edgar Costa, user202729
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 17, 2025
sagemathgh-39920: Avoiding to use polredbest, as it can be quite expensive
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

In sagemath#252 calling `polredbest` was made standard to workaround not
integral or not monic defining polynomials.
This is an excellent workaround for small polynomials, but it takes
$$O(b^2 d^5)$$ time, where $$d$$ is the degree and $$b$$ is the bitsize
of the polynomial, as it calls [LLL lattice basis reduction algorithm](h
ttps://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz
_lattice_basis_reduction_algorithm)

I expect some tests will fail when it depends on the internal
representation for the number field.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

-  [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#39920
Reported by: Edgar Costa
Reviewer(s): Edgar Costa, user202729
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 18, 2025
sagemathgh-39920: Avoiding to use polredbest, as it can be quite expensive
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

In sagemath#252 calling `polredbest` was made standard to workaround not
integral or not monic defining polynomials.
This is an excellent workaround for small polynomials, but it takes
$$O(b^2 d^5)$$ time, where $$d$$ is the degree and $$b$$ is the bitsize
of the polynomial, as it calls [LLL lattice basis reduction algorithm](h
ttps://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz
_lattice_basis_reduction_algorithm)

I expect some tests will fail when it depends on the internal
representation for the number field.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

-  [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#39920
Reported by: Edgar Costa
Reviewer(s): Edgar Costa, user202729
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 21, 2025
sagemathgh-39920: Avoiding to use polredbest, as it can be quite expensive
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

In sagemath#252 calling `polredbest` was made standard to workaround not
integral or not monic defining polynomials.
This is an excellent workaround for small polynomials, but it takes
$$O(b^2 d^5)$$ time, where $$d$$ is the degree and $$b$$ is the bitsize
of the polynomial, as it calls [LLL lattice basis reduction algorithm](h
ttps://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz
_lattice_basis_reduction_algorithm)

I expect some tests will fail when it depends on the internal
representation for the number field.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

-  [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#39920
Reported by: Edgar Costa
Reviewer(s): Edgar Costa, user202729
@vbraun vbraun merged commit 5391017 into sagemath:develop Jun 25, 2025
25 of 26 checks passed
@user202729 user202729 mentioned this pull request Jun 26, 2025
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 27, 2025
sagemathgh-40309: Fix lint
    
Fix lint failure introduced in
sagemath#39920 . Strangely, https://github.
com/sagemath/sage/actions/runs/15639025083/job/44061585299 had no
failure.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40309
Reported by: user202729
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 5, 2025
sagemathgh-40309: Fix lint
    
Fix lint failure introduced in
sagemath#39920 . Strangely, https://github.
com/sagemath/sage/actions/runs/15639025083/job/44061585299 had no
failure.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40309
Reported by: user202729
Reviewer(s): Frédéric Chapoton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants