input: other vector assumes: other vector has the same size returns a new vector that represents the sum.
(self, other)
| 104 | return math.sqrt(summe) |
| 105 | |
| 106 | def __add__(self, other): |
| 107 | """ |
| 108 | input: other vector |
| 109 | assumes: other vector has the same size |
| 110 | returns a new vector that represents the sum. |
| 111 | """ |
| 112 | size = self.size() |
| 113 | result = [] |
| 114 | if size == other.size(): |
| 115 | for i in range(size): |
| 116 | result.append(self.__components[i] + other.component(i)) |
| 117 | else: |
| 118 | raise Exception("must have the same size") |
| 119 | return Vector(result) |
| 120 | |
| 121 | def __sub__(self, other): |
| 122 | """ |