fjames86 / fpoly

Manipulate dense multivariate polynomials
0 stars 0 forks source link

Parsing pretty format input #12

Closed fjames86 closed 11 years ago

fjames86 commented 11 years ago

Would be useful to be able to parse pretty input of polynomials, i.e an input of the form x^2 + 2z -> (make-fpoly '(x z) 2 #(0 0 1 2 0 0))

Steps would be:

  1. Split the string into monomials of form [number][][^power1][[][^power2] ...]
  2. merge all the variables and find the highest degree
  3. collect all the coefficients into an array and make a polynomial

Also in the future might be good to allow bracketed sub-polys e.g. (x^2 + 2z)*y^3 etc

fjames86 commented 11 years ago

could also add a reader macro to facilitate entering polynomials at the repl. would be easy with a parse written above. e.g. #{x + y^2} -> (make-fpoly '(x y) 2 #(0 1 0 0 0 1))

fjames86 commented 11 years ago

done. reader macro #{ } also added