hi,
i would like to add my two matrices, using __add__
but i always get an error.
Hope you can help me
i would like to add my two matrices, using __add__
Code:
class m: def __init__(self, mtx={}, m=0, n=0): self.matrix = {} self.matrix.update(mtx) self.row = m self.col = n def __getitem__(self, ij): return self.matrix.get(ij,0) def __setitem__(self, ij, val): self.matrix[i,j] = val def __add__(self, other): result = m() for i in other: self.result[i] = self.matrix.get(i, 0) + other[i] return result
Hope you can help me
Comment