MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / __add__

Method __add__

linear_algebra_python/src/lib.py:91–102  ·  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

89 summe += c**2
90 return math.sqrt(summe)
91 def __add__(self,other):
92 """
93 input: other vector
94 assumes: other vector has the same size
95 returns a new vector that represents the sum.
96 """
97 size = len(self)
98 if size == len(other):
99 result = [self.__components[i] + other.component(i) for i in range(size)]
100 return Vector(result)
101 else:
102 raise Exception("must have the same size")
103 def __sub__(self,other):
104 """
105 input: other vector

Callers

nothing calls this directly

Calls 2

VectorClass · 0.85
componentMethod · 0.45

Tested by

no test coverage detected