#7377: Symbolic Ring to Maxima via EclObject
-----------------------------------------------------------------------+----
   Reporter:  nbruin                                                   |       
Owner:  nbruin      
       Type:  enhancement                                              |      
Status:  needs_work  
   Priority:  major                                                    |   
Milestone:  sage-feature
  Component:  symbolics                                                |    
Keywords:              
     Author:  Nils Bruin, Jean-Pierre Flori                            |    
Upstream:  N/A         
   Reviewer:  Jean-Pierre Flori, François Bissey, Karl-Dieter Crisman  |      
Merged:              
Work_issues:                                                           |  
-----------------------------------------------------------------------+----

Comment(by nbruin):

 Replying to [comment:68 jpflori]:
 > That's because sr_to_max calls op_max=caar(maxima(expr).ecl()) and
 maxima(expr) can simplify the object change its structure, so the
 dictionary is wrongly built (we get "ceil" for "+").
 >
 > Putting op_max=maxima(op).ecl() seems functional.

 A little digging gives us a way to access *just* the maxima reader,
 without the extra evaluation:
 {{{
 mymread=ecl_eval("""
 (defun my-mread (cmd)
   (caddr (mread (make-string-input-stream cmd))))
 """)

 def parsemaxstring(l):
   return mymread('"%s;"'%l)
 }}}
 Examples:
 {{{
 sage: parsemaxstring("integral(x^2,x)")
 <ECL: (($INTEGRAL) ((MEXPT) $X 2) $X)>
 sage: parsemaxstring("ceiling(x^2+floor(x))")
 <ECL: (($CEILING) ((MPLUS) ((MEXPT) $X 2) (($FLOOR) $X)))>
 sage: parsemaxstring("log(9^x)")
 <ECL: ((%LOG) ((MEXPT) 9 $X))>
 }}}
 The effect is about the same as
 {{{
 sage: EclObject("#$ceiling(x^2+floor(x))$").cdr().car().cdr().car()
 <ECL: (($CEILING) ((MPLUS) ((MEXPT) $X 2) (($FLOOR) $X)))>
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7377#comment:71>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to