Ticket #9880: pynac-order.patch

File pynac-order.patch, 2.6 KB (added by jpflori, 9 years ago)

Access to comparison function used for printing.

  • c_lib/include/ginac_wrap.h

    # HG changeset patch
    # User Jean-Pierre Flori <flori@enst.fr>
    # Date 1298990841 -3600
    # Node ID afc2b3d6e435d3330331e432f7c1465701cac681
    # Parent  bebf93b78a833a4a22b4bf95f04046097e40b13d
    Access to Pynac printing order
    
    diff -r bebf93b78a83 -r afc2b3d6e435 c_lib/include/ginac_wrap.h
    a b  
    136136extern const ex _ex1_2;
    137137
    138138}
     139
     140#include <pynac/order.h>
     141
     142int cmp_add(const ex& lh, const ex& rh) {
     143  return ex_is_greater_degrevlex::in_type(&add::tinfo_static).compare(lh,rh);
     144}
     145
     146int cmp_mul(const ex& lh, const ex& rh) {
     147  return ex_is_greater_degrevlex::in_type(&mul::tinfo_static).compare(lh,rh);
     148}
  • sage/libs/ginac/decl.pxi

    diff -r bebf93b78a83 -r afc2b3d6e435 sage/libs/ginac/decl.pxi
    a b  
    505505        object (*py_rational_power_parts)(object basis, object exp)
    506506
    507507    py_funcs_struct py_funcs "GiNaC::py_funcs"
     508
     509    int cmp_add(GEx left, GEx right) except +
     510    int cmp_mul(GEx left, GEx right) except +
  • sage/symbolic/expression.pxd

    diff -r bebf93b78a83 -r afc2b3d6e435 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 -r bebf93b78a83 -r afc2b3d6e435 sage/symbolic/expression.pyx
    a b  
    23752375    cdef int _cmp_c_impl(left, Element right) except -2:
    23762376        return left._gobj.compare((<Expression>right)._gobj)
    23772377
     2378    cpdef int _cmp_add(left, Element right) except -2:
     2379        return cmp_add(left._gobj,(<Expression>right)._gobj)
     2380
     2381    cpdef int _cmp_mul(left, Element right) except -2:
     2382        return cmp_mul(left._gobj,(<Expression>right)._gobj)
     2383
    23782384    def __pow__(self, exp, ignored):
    23792385        """
    23802386        Return self raised to the power of exp.