Ticket #9880: trac_9880_pynac_order.patch

File trac_9880_pynac_order.patch, 2.5 KB (added by vbraun, 10 years ago)

Initial patch

  • c_lib/include/ginac_wrap.h

    # HG changeset patch
    # User Jean-Pierre Flori <flori@enst.fr>
    # Date 1298990841 -3600
    # Node ID 859858d8d29ba03198f011c7a95202128ca582d3
    # Parent  98b80ddf6c9f18409d222bcb01622aa32ef8d18f
    Trac #9880: Give Sage access to the PyNaC printing order
    
    This allows automated doctests to check the PyNaC printing
    sort order.
    
    diff --git a/c_lib/include/ginac_wrap.h b/c_lib/include/ginac_wrap.h
    a b  
    143143extern const ex _ex1_2;
    144144
    145145}
     146
     147#include <pynac/order.h>
     148
     149int cmp_add(const ex& lh, const ex& rh) {
     150  return ex_is_greater_degrevlex::in_type(&add::tinfo_static).compare(lh,rh);
     151}
     152
     153int cmp_mul(const ex& lh, const ex& rh) {
     154  return ex_is_greater_degrevlex::in_type(&mul::tinfo_static).compare(lh,rh);
     155}
  • sage/libs/ginac/decl.pxi

    diff --git a/sage/libs/ginac/decl.pxi b/sage/libs/ginac/decl.pxi
    a b  
    507507        object (*py_rational_power_parts)(object basis, object exp)
    508508
    509509    py_funcs_struct py_funcs "GiNaC::py_funcs"
     510
     511    int cmp_add(GEx left, GEx right) except +
     512    int cmp_mul(GEx left, GEx right) except +
  • sage/symbolic/expression.pxd

    diff --git a/sage/symbolic/expression.pxd b/sage/symbolic/expression.pxd
    a b  
    11include "../libs/ginac/decl.pxi"
    22
    3 from sage.structure.element cimport CommutativeRingElement
    4 
     3from sage.structure.element cimport CommutativeRingElement, Element
    54
    65cdef class Expression(CommutativeRingElement):
    76    cdef GEx _gobj
     
    1211    cpdef bint is_relational(self)
    1312    cpdef object pyobject(self)
    1413    cpdef Expression _subs_expr(self, expr)
     14    cpdef int _cmp_add(left, Element right) except -2
     15    cpdef int _cmp_mul(left, Element right) except -2
    1516   
    1617cdef Expression new_Expression_from_GEx(parent, GEx juice)
    1718cdef Expression new_Expression_from_pyobject(parent, x)
     19
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    25012501    cdef int _cmp_c_impl(left, Element right) except -2:
    25022502        return left._gobj.compare((<Expression>right)._gobj)
    25032503
     2504    cpdef int _cmp_add(left, Element right) except -2:
     2505        return cmp_add(left._gobj,(<Expression>right)._gobj)
     2506
     2507    cpdef int _cmp_mul(left, Element right) except -2:
     2508        return cmp_mul(left._gobj,(<Expression>right)._gobj)
     2509
    25042510    def __pow__(self, exp, ignored):
    25052511        """
    25062512        Return self raised to the power of exp.