#12554: Adding a "swap" method to equation objects.
---------------------------+------------------------------------------------
   Reporter:  JoalHeagney  |          Owner:  AlexGhitza                        
                 
       Type:  enhancement  |         Status:  new                               
                 
   Priority:  minor        |      Milestone:  sage-5.0                          
                 
  Component:  algebra      |       Keywords:  swap, left hand side, right hand 
side, inequalities
Work_issues:               |       Upstream:  N/A                               
                 
   Reviewer:               |         Author:                                    
                 
     Merged:               |   Dependencies:                                    
                 
---------------------------+------------------------------------------------
 Often when working with sage equations, it's desirable to swap the left
 and right hand side of the equations. (Makes substitutions easier for a
 start, allows manual solving of inequalities, etc.)

 A model implementation by Ivan Andrus
 [https://groups.google.com/forum/#!topic/sage-support/lKbMSQrFhGg]
 (in function form) is supplied below (with some rearrangement so equal
 operator case is tested first):


 {{{
 import operator
 def reverse_inequality(eq):
     """
     Reverse the order of the inequality without changing it's meaning.
     """
     orig_op = eq.operator() # The "top-level" operator
     if orig_op == operator.eq:
         op = operator.eq
     elif orig_op == operator.lt:
         op = operator.gt
     elif orig_op == operator.le:
         op = operator.ge
     elif orig_op == operator.gt:
         op = operator.lt
     elif orig_op == operator.ge:
         op = operator.le
     elif orig_op == operator.ne:
         op = operator.ne
     else:
         raise TypeError, "this expression must be a relation"
    return op(eq.rhs(), eq.lhs())
 }}}

 My request is that something similar be attached to equation objects as a
 method.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12554>
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