hermann on Fri, 06 Oct 2023 19:14:39 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
"my(...)" scoping question |
Running this GP script https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/pari/all_rsa.foursquare.gp all is fine: $ gp -q < all_rsa.foursquare.gp ...2048 [28, 158197984288196117699097355897947500264458455190848222964138664214873348733353898043756194523483689509093385743402168573089458743256253901017830264069606012704497883085623209455523704906878923700142603965513457096959088734082854043425944788477935555382589380809038501009740812793032665236884977009980514922487, 13011773238477059231321994244187743729468594581843753487082884034603212622185946597112257777907861613001484624197063577339843512098442794834693496703933881475402708427339094714589624392731377779402228770755581888942318831433232790010161732825667949844267841944332119616646371761146340753071052451512068626398, 0]~
*** last result computed in 3,373 ms. all asserts OK hermann@7600x:~/RSA_numbers_factored/pari$ I added "if(n%8!=7,assert(F[4]==0));" as last line into main "{ ... }" block (to prove that really sum of 3 squares got computed): { foreach(rsa,r,[l,n]=r; my(F=foursquarep(n)); print(l," ",F); assert(vecsum([x^2|x<-F])==n)); if(n%8!=7,assert(F[4]==0)); } Although output for RSA-2048 as well as vecsum assert are good, the following assert "thinks" F is a t_POL: ...2048 [28, 158197984288196117699097355897947500264458455190848222964138664214873348733353898043756194523483689509093385743402168573089458743256253901017830264069606012704497883085623209455523704906878923700142603965513457096959088734082854043425944788477935555382589380809038501009740812793032665236884977009980514922487, 13011773238477059231321994244187743729468594581843753487082884034603212622185946597112257777907861613001484624197063577339843512098442794834693496703933881475402708427339094714589624392731377779402228770755581888942318831433232790010161732825667949844267841944332119616646371761146340753071052451512068626398, 0]~
*** at top-level: ...)==n));if(n%8!=7,assert(F[4]==0)) *** ^-------- *** incorrect type in _[_] OCcompo1 [not a vector] (t_POL). *** last result computed in 0 ms. all asserts OK hermann@7600x:~/RSA_numbers_factored/pari$Moving "my(F)" before foreach loop makes it work again like initially shown:
{ my(F); foreach(rsa,r,[l,n]=r; F=foursquarep(n); print(l," ",F); assert(vecsum([x^2|x<-F])==n)); if(n%8!=7,assert(F[4]==0)); }Is the t_POL assertion a bug, or do I understand "my(...)" scoping wrong?
Regards, Hermann.