How can I override the __call__ method of a matrix
I'd like to override the __call__ method of a matrix so that M(v) returns M*v. That is, I'd like to use functional notation. So I tried the following:
class MyMatrix(Matrix):
def __call__(self, v):
return self*v
but this doesn't work because Matrix work. Here is a MatrixFactory, so is a metaclass, not a class. the error message I get the following error when I try the above code in sage:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-88-e8d789594dd8> in <module>()
----> 1 class MyMatrix(Matrix):
2 def __call__(self, v):
3 return self*v
4
TypeError: Error when calling the metaclass bases
object() takes no parameters
I don't know anything about metaclasses. After banging my head against various walls, trying to learn, I am asking here.