MATLAB: Is there any means to overload ‘* (multiplication by the transpose matrix) with the own matrix class

MATLABmatrix manipulationoverloading

Hello I'm trying to make my own matrix class in Matlab. I succeed to overload the operator transpose' and mtimes, so let's A an instance of my matrix class and x, an instance of the matlab matrix. y=A'*x is really slow compared to y=A*x; Is there any means to overload the operator '*, (i.e multiplication by the transpose of an instance of my matrix class)

Best Answer

You could create a special method for this. E.g., tmtimes. Then instead of doing y = A'*x you would do tmtimes(A,x).
Or you could add a property to your class that keeps track of transpose status. Then when A' happens you simply flip the transpose property of your matrix object instead of physically transposing it. Then when the *x part happens you can check the transpose property flag of the operands. Downside of this is you would now have to check this transpose property flag for every operation you do.