First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring which morally should be C-valued, ϕ:RZ, bt from that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if type(other) == Integers
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring which morally should be $\mathbb C$-valued, Z$-valued, ϕ:RZ, bt from that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if type(other) == Integers
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.) SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring which morally should be Z-valued, ϕ:RZ, bt from that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if type(other) == Integers
Integers:
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring R, which morally should be Z-valued, $\phi: R \to \mathbb Z$, bt from Z$. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if type(other) == Integers:
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if type(other) other == Integers:
 0:
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if other ==  0:
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if other ==  0:
                return self

How can I define the addition of a left argument in Z with an element of my phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers classclass (need 0+x=x, x belonging to custom class)

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if other ==  0:
                return self

How can I define the addition of a to be trivial if the left argument is 0Z and the right in Z with an element of my the phi class to be trivial, without changing the __add__ of the Integer class? (Or a work arround. workaround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class (need 0+x=x, x belonging to custom class)

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if other ==  0:
                return self

How can I define the addition to be trivial if the left argument is 0Z and the right in the phi class without changing the __add__ of the Integer class? (Or a workaround. Actually my target is not the integers but the sage symbolic ring, SR.)

Alternative to changing the __add__ of Integers class (need $0 $0_{\mathbb Z} + x = x,x$ belonging to custom class)

I have a class called phi defined on certain ring R, which morally should be Z-valued, ϕ:RZ. From that I need only that adding 0Z to the phi-elements does nothing, and the next (pseudocode) works for adding 0 by the right to the phi elements:

class phi: ...
    ...
   def __add__(self, other):  
          if other ==  0:
                return self

How can I define the addition to be trivial if the left argument is 0Z and the right in the phi class without changing the __add__ of the Integer class? (Or a workaround. Actually my target is not the integers but the sage symbolic ring, SR.)