Ben Bacarisse a écrit :
Not all such sets of matrices from a ring. I'm sure you know that.
Agreed. But conversely, the fact that you can restrict the operation
does not diminish the fact that, to some, the analogy with
multiplication is strained.
Discussions here would be so much more productive if people took the
time to acknowledge some validity (if there is some) in other people's
point of view. Pretty much the only reason I posted was that your
reply was so totally dismissive of Alan's view. I am with you in that
I see why mathematicians call it multiplication, but I can also see
the craziness -- the operation is not even defined for some pairs of
matrices. Your reply essentially said "it is called multiplication
because it is multiplication".
<snip>
To come back to the operator overloading discussion.
The big problem with operator overloading and matrices multiplication
is the intermediate objects problem.
If we overload in a "standard" way matrix multiplication, addition etc
we can write:
C = (A+B)/(B*D);
The overloaded "*" operator creates a temporary (t1) so we have
C = (A+B)/t1;
The overloaded "+" operator creates a t2 temporary so that
C = t2/t1;
If the matrices are big, we have 2 times the storage...
There are solutions to this problem, but they are tricky. One of them
is that all operators return a tokenized structure, that instructs
the overloaded assignment operators what operations should be done.
This should be done at runtime, what makes this solution the equivalent
of having a run time interpreter of this precompiled instructions...
not very easy.