#7490: refactor symbolic functions
-------------------------+--------------------------------------------------
   Reporter:  burcin     |       Owner:  burcin       
       Type:  defect     |      Status:  new          
   Priority:  major      |   Milestone:  sage-4.3     
  Component:  symbolics  |    Keywords:  pynac        
Work_issues:             |      Author:  Burcin Erocal
   Reviewer:             |      Merged:               
-------------------------+--------------------------------------------------
 Attached patch refactors the symbolic function code in
 `sage/symbolic/function.pyx`.

  * `evalf()` now accepts a parent argument instead of a precision
   This allows us to use the numeric evaluation framework in ginac for
   evaluating things with `RIF`, `CIF` as well, not just `RealField`, or
 `ComplexField` with the given precision.

  * python arguments passed to custom methods of sfunctions are not
    wrapped in `Expression` objects any more. No need to call `.pyobject()`
    to unwrap these.

  * custom methods support calling methods on `self`.
   This would be useful if you need access to other function of the
   defining class, or store tables of data calculated on demand.

  * `__call__` method supports hold parameter
   This works:
 {{{
         sage: exp(log(x))
         x
         sage: exp(log(x), hold=True)
         e^log(x)
 }}}

  * Custom methods for symbolic functions (`_eval_`, `_evalf_`,
 `_conjugate_`,
    `_derivative_`, etc.) can be
    written in Cython for builtin functions (that are provided by the
    Sage library)

  * New class hiearchy:
 {{{
 Function
   GinacFunction
   CustomizableFunction
     BuiltinFunction
     SymbolicFunction
 }}}
  We have 4 different types of functions, those defined by
   * ginac (sin, cos, ...),
   * the Sage library (cot)
   * the user (in a python file, subclassing the new
     SymbolicFunction)
   * the command line function_factory (by calling function('f') )

  Things we need to do for these functions different for each of these,
  perhaps similar for the last two. Normally initializing a function
  means checking if it's already defined, if not, initializing a
  structure from ginac called function_options, and registering this in
  a table. There are also issues with pickling.

  For ginac functions, we don't need any of this, since we can't change
  it at python level. We only need to look up the serial number (the
  indicator in the table) of the function. We don't need to do anything
  to pickle or unpickle these either.

  Pickling and unpickling library functions only needs an identifier
  for the class to initialize it again if necessary.

  User defined functions need to lookup if there is an existing
  function in the table, since we should try to keep the table small.

  There is also a new `function_factory()` function in
 `sage.symbolic.function_factory`
  (it needs to be in a python file) that creates `NewSymbolicFunction`
  classes on the fly for the function() calls from the command line.


 The pynac package here is required for this patch:

 http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.10.a0.spkg

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7490>
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].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=.


Reply via email to