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

Method __sub__

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

101 else:
102 raise Exception("must have the same size")
103 def __sub__(self,other):
104 """
105 input: other vector
106 assumes: other vector has the same size
107 returns a new vector that represents the differenz.
108 """
109 size = len(self)
110 if size == len(other):
111 result = [self.__components[i] - other.component(i) for i in range(size)]
112 return result
113 else: # error case
114 raise Exception("must have the same size")
115 def __mul__(self,other):
116 """
117 mul implements the scalar multiplication

Callers

nothing calls this directly

Calls 1

componentMethod · 0.45

Tested by

no test coverage detected