Duoas: BTW, the word "scalar" is spelt "scalar", not "scaler". |
Oh, man... that's embarrassing. Uhm... my only defense is that it's been 5 years since I was in linear algebra. My browser even told me it was misspelled but I guess I ignored it.
But yeah,
Duoas, that makes sense to me now. In my reference material they only ever defined one operator function but it still behaved like it was commutative. Now I realize that it only appeared to be commutative because the the operands were of the same type. I should have thought it through a bit more.
Although I hadn't thought of defining one function as member and the other as a friend so it's good to see how that's done. Thanks.
I'm a few chapters off from templates so that other stuff will probably make sense to me later.
shacktar: ...though you usually see the scalar on the left on paper. |
I thought about that as well, but then I wondered what would happen if I wrote an assignment like this:
C =
A * c *
B
If I had only defined the scalar to operate before the matrix it seems like the compiler would say this is in error because it would try to do
A * c first. I guess it depends on whether it works the expression from right to left or left to right. Does anyone happen to know which direction it works?
Thanks for catching that memory leak!