Matlab is able to distinguish between โcorrectโ matrix multiplication and matrix matrix multiplication by different operators, so that the former is executed as A * B , and the latter as A .* B This is pretty convenient, and I was wondering if there is a way to do the same in C ++ for a custom matrix class (as well as for ./ and .^ ). That is, I was wondering if it is possible, through the definition of macros or any other method, to have something like the following, actually compiled:
MyMatrix A(2,3), B(2,3), C(2,3);
I tried to do this with the simple #define function and could not get it to work, so I decided that I would put it in SO. I can take "misses", i.e. If .* Can't work, but somehow :* maybe pretty good. NB, I am specifically looking for operators - of course, this behavior can be performed using functions in an obvious way, but Matlab-like operators would be quite convenient.
source share