implements the matrix-vector multiplication. implements the matrix-scalar multiplication
(self,other)
| 254 | """ |
| 255 | return self.__height |
| 256 | def __mul__(self,other): |
| 257 | """ |
| 258 | implements the matrix-vector multiplication. |
| 259 | implements the matrix-scalar multiplication |
| 260 | """ |
| 261 | if isinstance(other, Vector): # vector-matrix |
| 262 | if (len(other) == self.__width): |
| 263 | ans = zeroVector(self.__height) |
| 264 | for i in range(self.__height): |
| 265 | summe = 0 |
| 266 | for j in range(self.__width): |
| 267 | summe += other.component(j) * self.__matrix[i][j] |
| 268 | ans.changeComponent(i,summe) |
| 269 | summe = 0 |
| 270 | return ans |
| 271 | else: |
| 272 | raise Exception("vector must have the same size as the " + "number of columns of the matrix!") |
| 273 | elif isinstance(other,int) or isinstance(other,float): # matrix-scalar |
| 274 | matrix = [[self.__matrix[i][j] * other for j in range(self.__width)] for i in range(self.__height)] |
| 275 | return Matrix(matrix,self.__width,self.__height) |
| 276 | def __add__(self,other): |
| 277 | """ |
| 278 | implements the matrix-addition. |
nothing calls this directly
no test coverage detected