MCPcopy Index your code
hub / github.com/geekcomputers/Python / __add__

Method __add__

linear-algebra-python/src/lib.py:106–119  ·  view source on GitHub ↗

input: other vector assumes: other vector has the same size returns a new vector that represents the sum.

(self, other)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.95
VectorClass · 0.85
appendMethod · 0.45
componentMethod · 0.45

Tested by

no test coverage detected