close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

Changeset 1066


Ignore:
Timestamp:
2015-06-10T09:12:53-07:00 (9 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r1054 r1066  
    322322  (declare (type poly p))
    323323  (reduce (ring-gcd ring) (mapcar #'term-coeff (rest (poly-termlist p))) :initial-value (poly-lc p)))
     324
     325(defun parse-expr (&optional stream)
     326  "Parser of infix expressions with integer/rational coefficients
     327The parser will recognize two kinds of polynomial expressions:
     328
     329- polynomials in fully expanded forms with coefficients
     330  written in front of symbolic expressions; constants can be optionally
     331  enclosed in (); for example, the infix form
     332        X^2-Y^2+(-4/3)*U^2*W^3-5
     333  parses to
     334        (+ (- (EXPT X 2) (EXPT Y 2)) (* (- (/ 4 3)) (EXPT U 2) (EXPT W 3)) (- 5))
     335
     336- lists of polynomials; for example
     337        [X-Y, X^2+3*Z]         
     338  parses to
     339          (:[ (- X Y) (+ (EXPT X 2) (* 3 Z)))
     340  where the first symbol [ marks a list of polynomials.
     341
     342-other infix expressions, for example
     343        [(X-Y)*(X+Y)/Z,(X+1)^2]
     344parses to:
     345        (:[ (/ (* (- X Y) (+ X Y)) Z) (EXPT (+ X 1) 2))
     346Currently this function is implemented using M. Kantrowitz's INFIX package."
     347  (read-from-string
     348   (concatenate 'string
     349     "#I("
     350     (with-output-to-string (s)
     351       (loop
     352         (multiple-value-bind (line eof)
     353             (read-line stream t)
     354           (format s "~A" line)
     355           (when eof (return)))))
     356     ")")))
     357       
Note: See TracChangeset for help on using the changeset viewer.