Is there any means to overload '* (multiplication by the transpose matrix) with my own matrix class?
2 views (last 30 days)
Show older comments
Nicolas Bellot
on 6 Jul 2016
Edited: Nicolas Bellot
on 20 Jul 2016
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)
2 Comments
Adam
on 19 Jul 2016
' and * are two separate operations, not a single one. You can overload either of them individually if you wish by using their function name rather than symbol.
Accepted Answer
James Tursa
on 19 Jul 2016
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.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!