Alright, sorry to take so long.
If I understand what you are trying to do correctly, the issue isn't in the multiplication operator, its in your Resultant() iteration.
Comment out line 32 in main.cpp (only multiply by m2
once, before the loop).
Also, on lines 9 and 10 of matrix.cpp you have swapped the signs. It should read
1 2
|
m12= -(1/n)*sin(k*d);
m21= n*sin(k*d);
|
As an aside, the *= operator should be:
1 2 3 4 5
|
MyMatrix& operator *= ( const MyMatrix& fred )
{
...
return *this;
}
|
Hope this helps.
[edit] Oh, before you run that and say "what?", I modified the parameters a little to get a more sane matrix.
First, in
main(), I looped over
(k=0; k < 2; k+=0.001). A tenth isn't a very small sample for the wavelength of your graphs.
Second, in
Resultant(), I set the 'd' arguments to 10.0 and 5.0, respectively, which is a bit more sane for viewing.
If you want I'll post an image of what I'm seeing.
Hope this helps.
[edit 2]
http://home.comcast.net/~michaelthomasgreer/temp/fea12rs-wave-matrix.png