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 $\mathbb C$-valued, $\phi: R \to \mathbb Z$, bt from that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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, $\phi: R \to \mathbb Z$, bt from that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$, bt from that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$, bt from Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $0_\mathbb Z$ and the right in $\mathbb 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $0_\mathbb Z$ 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 $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ 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 $0_\mathbb Z$ 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.)