# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1357729454 -3600
# Node ID 3f48fc260356d410748c33ee88d8346b4ede202c
# Parent 960df3da463d46c98242b364071cc1aaf35ed8b5
[mq]: trac_7660-inequality_arithmetic.patch
diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
a
|
b
|
|
2431 | 2431 | cdef GEx x |
2432 | 2432 | cdef Expression _right = <Expression>right |
2433 | 2433 | cdef operators op |
2434 | | if is_a_relational(left._gobj): |
2435 | | if is_a_relational(_right._gobj): |
| 2434 | if is_a_relational(left._gobj) and is_a_relational(_right._gobj): |
2436 | 2435 | op = compatible_relation(relational_operator(left._gobj), |
2437 | 2436 | relational_operator(_right._gobj)) |
2438 | 2437 | x = relational(gadd(left._gobj.lhs(), _right._gobj.lhs()), |
2439 | 2438 | gadd(left._gobj.rhs(), _right._gobj.rhs()), |
2440 | 2439 | op) |
2441 | | else: |
2442 | | x = relational(gadd(left._gobj.lhs(), _right._gobj), |
2443 | | gadd(left._gobj.rhs(), _right._gobj), |
2444 | | relational_operator(left._gobj)) |
2445 | | elif is_a_relational(_right._gobj): |
2446 | | x = relational(gadd(left._gobj, _right._gobj.lhs()), |
2447 | | gadd(left._gobj, _right._gobj.rhs()), |
2448 | | relational_operator(_right._gobj)) |
| 2440 | # else: |
| 2441 | # x = relational(gadd(left._gobj.lhs(), _right._gobj), |
| 2442 | # gadd(left._gobj.rhs(), _right._gobj), |
| 2443 | # relational_operator(left._gobj)) |
| 2444 | #elif is_a_relational(_right._gobj): |
| 2445 | # x = relational(gadd(left._gobj, _right._gobj.lhs()), |
| 2446 | # gadd(left._gobj, _right._gobj.rhs()), |
| 2447 | # relational_operator(_right._gobj)) |
2449 | 2448 | else: |
2450 | 2449 | x = gadd(left._gobj, _right._gobj) |
2451 | 2450 | return new_Expression_from_GEx(left._parent, x) |
… |
… |
|
2483 | 2482 | """ |
2484 | 2483 | cdef GEx x |
2485 | 2484 | cdef Expression _right = <Expression>right |
2486 | | if is_a_relational(left._gobj): |
2487 | | if is_a_relational(_right._gobj): |
| 2485 | if is_a_relational(left._gobj) and is_a_relational(_right._gobj): |
2488 | 2486 | op = compatible_relation(relational_operator(left._gobj), |
2489 | 2487 | relational_operator(_right._gobj)) |
2490 | 2488 | x = relational(gsub(left._gobj.lhs(), _right._gobj.lhs()), |
2491 | 2489 | gsub(left._gobj.rhs(), _right._gobj.rhs()), |
2492 | 2490 | op) |
2493 | | else: |
2494 | | x = relational(gsub(left._gobj.lhs(), _right._gobj), |
2495 | | gsub(left._gobj.rhs(), _right._gobj), |
2496 | | relational_operator(left._gobj)) |
2497 | | elif is_a_relational(_right._gobj): |
2498 | | x = relational(gsub(left._gobj, _right._gobj.lhs()), |
2499 | | gsub(left._gobj, _right._gobj.rhs()), |
2500 | | relational_operator(_right._gobj)) |
| 2491 | # else: |
| 2492 | # x = relational(gsub(left._gobj.lhs(), _right._gobj), |
| 2493 | # gsub(left._gobj.rhs(), _right._gobj), |
| 2494 | # relational_operator(left._gobj)) |
| 2495 | #elif is_a_relational(_right._gobj): |
| 2496 | # x = relational(gsub(left._gobj, _right._gobj.lhs()), |
| 2497 | # gsub(left._gobj, _right._gobj.rhs()), |
| 2498 | # relational_operator(_right._gobj)) |
2501 | 2499 | else: |
2502 | 2500 | x = gsub(left._gobj, _right._gobj) |
2503 | 2501 | return new_Expression_from_GEx(left._parent, x) |
… |
… |
|
2679 | 2677 | cdef GEx x |
2680 | 2678 | cdef Expression _right = <Expression>right |
2681 | 2679 | cdef operators o |
2682 | | if is_a_relational(left._gobj): |
2683 | | if is_a_relational(_right._gobj): |
| 2680 | if is_a_relational(left._gobj) and is_a_relational(_right._gobj): |
2684 | 2681 | op = compatible_relation(relational_operator(left._gobj), |
2685 | 2682 | relational_operator(_right._gobj)) |
2686 | 2683 | x = relational(gmul(left._gobj.lhs(), _right._gobj.lhs()), |
2687 | 2684 | gmul(left._gobj.rhs(), _right._gobj.rhs()), |
2688 | 2685 | op) |
2689 | | else: |
2690 | | o = relational_operator(left._gobj) |
2691 | | x = relational(gmul(left._gobj.lhs(), _right._gobj), |
2692 | | gmul(left._gobj.rhs(), _right._gobj), |
2693 | | o) |
2694 | | elif is_a_relational(_right._gobj): |
2695 | | o = relational_operator(_right._gobj) |
2696 | | x = relational(gmul(left._gobj, _right._gobj.lhs()), |
2697 | | gmul(left._gobj, _right._gobj.rhs()), |
2698 | | o) |
| 2686 | # else: |
| 2687 | # o = relational_operator(left._gobj) |
| 2688 | # x = relational(gmul(left._gobj.lhs(), _right._gobj), |
| 2689 | # gmul(left._gobj.rhs(), _right._gobj), |
| 2690 | # o) |
| 2691 | #elif is_a_relational(_right._gobj): |
| 2692 | # o = relational_operator(_right._gobj) |
| 2693 | # x = relational(gmul(left._gobj, _right._gobj.lhs()), |
| 2694 | # gmul(left._gobj, _right._gobj.rhs()), |
| 2695 | # o) |
2699 | 2696 | else: |
2700 | 2697 | x = gmul(left._gobj, _right._gobj) |
2701 | 2698 | return new_Expression_from_GEx(left._parent, x) |
… |
… |
|
2782 | 2779 | cdef Expression _right = <Expression>right |
2783 | 2780 | cdef operators o |
2784 | 2781 | try: |
2785 | | if is_a_relational(left._gobj): |
2786 | | if is_a_relational(_right._gobj): |
| 2782 | if is_a_relational(left._gobj) and is_a_relational(_right._gobj): |
2787 | 2783 | op = compatible_relation(relational_operator(left._gobj), |
2788 | 2784 | relational_operator(_right._gobj)) |
2789 | 2785 | x = relational(gdiv(left._gobj.lhs(), _right._gobj.lhs()), |
2790 | 2786 | gdiv(left._gobj.rhs(), _right._gobj.rhs()), |
2791 | 2787 | op) |
2792 | | else: |
2793 | | o = relational_operator(left._gobj) |
2794 | | x = relational(gdiv(left._gobj.lhs(), _right._gobj), |
2795 | | gdiv(left._gobj.rhs(), _right._gobj), |
2796 | | o) |
2797 | | elif is_a_relational(_right._gobj): |
2798 | | o = relational_operator(_right._gobj) |
2799 | | x = relational(gdiv(left._gobj, _right._gobj.lhs()), |
2800 | | gdiv(left._gobj, _right._gobj.rhs()), |
2801 | | o) |
| 2788 | # else: |
| 2789 | # o = relational_operator(left._gobj) |
| 2790 | # x = relational(gdiv(left._gobj.lhs(), _right._gobj), |
| 2791 | # gdiv(left._gobj.rhs(), _right._gobj), |
| 2792 | # o) |
| 2793 | # elif is_a_relational(_right._gobj): |
| 2794 | # o = relational_operator(_right._gobj) |
| 2795 | # x = relational(gdiv(left._gobj, _right._gobj.lhs()), |
| 2796 | # gdiv(left._gobj, _right._gobj.rhs()), |
| 2797 | # o) |
2802 | 2798 | else: |
2803 | 2799 | x = gdiv(left._gobj, _right._gobj) |
2804 | 2800 | return new_Expression_from_GEx(left._parent, x) |
… |
… |
|
2979 | 2975 | nexp = exp |
2980 | 2976 | base = nexp.coerce_in(self) |
2981 | 2977 | cdef GEx x |
2982 | | if is_a_relational(base._gobj): |
2983 | | x = relational(g_pow(base._gobj.lhs(), nexp._gobj), |
2984 | | g_pow(base._gobj.rhs(), nexp._gobj), |
2985 | | relational_operator(base._gobj)) |
2986 | | else: |
2987 | | x = g_pow(base._gobj, nexp._gobj) |
| 2978 | #if is_a_relational(base._gobj): |
| 2979 | # x = relational(g_pow(base._gobj.lhs(), nexp._gobj), |
| 2980 | # g_pow(base._gobj.rhs(), nexp._gobj), |
| 2981 | # relational_operator(base._gobj)) |
| 2982 | #else: |
| 2983 | x = g_pow(base._gobj, nexp._gobj) |
2988 | 2984 | return new_Expression_from_GEx(base._parent, x) |
2989 | 2985 | |
2990 | 2986 | def derivative(self, *args): |