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

Method __sub__

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

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

(self, other)

Source from the content-addressed store, hash-verified

119 return Vector(result)
120
121 def __sub__(self, other):
122 """
123 input: other vector
124 assumes: other vector has the same size
125 returns a new vector that represents the differenz.
126 """
127 size = self.size()
128 result = []
129 if size == other.size():
130 for i in range(size):
131 result.append(self.__components[i] - other.component(i))
132 else: # error case
133 raise Exception("must have the same size")
134 return Vector(result)
135
136 def __mul__(self, other):
137 """

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