|Bill Allombert on Thu, 14 Jun 2012 21:03:36 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
On Thu, Jun 14, 2012 at 08:22:42PM +0200, Dirk Laurie wrote: > I'm programming in library mode, and have some GEN's around that > never were assigned to anything in a `gp_read_str` call. I now want > to make such a call involving some of these GEN's, and find it hard > to get `gp_read_str` to see those GEN's. In the following minimal > example, I'm trying and failing to assign an expression to variable `b`. Hello Dirk, You are mixing two unrelated concepts. The confusion is probably due to the fact that in GP, a global GP variable is initialised to a polynomial variable of the same name, but actually there are two completly different concepts: 1) polynomial variables ('b in GP) which are supposed to be immutable. (doing pol_x[fetch_user_var("b")] = gaddsg(1, x); is really ill advised, like doing gen_0=stoi(5)) fetch_user_var("b") return the 'variable number' of the polynomial variable displayed as "b". 2) GP variables which for the most part are not supposed to be used in library mode. Maybe it would help if you explained what you really want to do with them? > pari_init(1000000,0); > GEN x = pol_x[fetch_user_var("x")]; > pol_x[fetch_user_var("b")] = gaddsg(1, x); > pariprintf("%Z\n",pol_x[fetch_user_var("b")]); // prints x+1 > pariprintf("%Z\n",gp_read_str("b+10")); // prints b+10, not x+11 You are using a very old PARI version... pol_x is a function now. Cheers, Bill.