Michael Somos on Mon, 12 Jun 2000 17:15:54 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: turn matrix to polynomial


You asked :
> Hi - does anyone know a fastest way in gp to convert a matrix c_{i,j} into
> a polynomial sum c_{i,j}.x^i.y^j of two variables? vice versa ?

How about
gp> m2p(c)=local(rc);rc=matsize(c);sum(i=1,rc[1],sum(j=1,rc[2],c[i,j]*x^i*y^j))
gp> m2p([1,2;3,4])
%1 = (4*y^2 + 3*y)*x^2 + (2*y^2 + y)*x

Shalom, Michael

-- 
Michael Somos <somos@grail.cba.csuohio.edu>     Cleveland State University
http://grail.cba.csuohio.edu/~somos/            Cleveland, Ohio, USA 44115