Ilya Zakharevich on Mon, 1 Jul 2002 11:06:10 -0400 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
polcoeff() mystery |
How polcoeff() is supposed to work? I try to understand why the coeff() example of the manual works, and fail... I try this: coeffs(P, nbvar) = { local(v); if (type(P) != "t_POL", for (i=0, nbvar-1, P = [P]); return (P) ); v = vector(poldegree(P)+1, i, polcoeff(P,i-1)); vector(length(v), i, coeffs(v[i], nbvar-1)) } c(P) = coeffs(P,2) PP = x^2 + x*y + z; temp = polcoeff(PP,0); temp1 = polcoeff(PP,1); print("z -> "z", c(z) -> "c(z)); print("temp -> "z", c(temp) -> "c(temp)); print("y -> "y", c(y) -> "c(y)); print("temp1 -> "temp1", c(temp) -> "c(temp1)); This gives z -> z, c(z) -> [[0], [1]] temp -> z, c(temp) -> [[0, 1]] y -> y, c(y) -> [[0], [1]] temp1 -> y, c(temp) -> [[0], [1]] As one can see, z and temp have the same value, but the results of c() are different! Moreover, x and temp give the same \x... Puzzled, Ilya