Hi people. New to this site, new to c++ so excuse me if i lack the normal decorum.
Im writing a program thats supposed to multiply 2x2 matrices together, multiple times, while updating the values of the elements in the matrix each loop. At the moment its just 2 alternating matrices. I then calculate some values at the end using the 'final matrix' elements.
I should output data which fits a curve with a maximum... a somewhat gaussian shape. The graphs produced are completely random. I think the problem may be in the implementation of the operator *= overload .
as I say i think the probllem is in the *= overload where I keep defining MyMatrix newMat each time I use the *= in the main. Would much appreciate any advice, please talk to me like a novice im new to this.
Also the det calculation gives 1, when I do it manually from the data outputted by the program i get 1.0004 or 0.999934 etc..
I cant see how.. i checked the calculation, im worried about the redeclaration of MyMatrix newMat = MyMatrix(0,0,0) every time I used *= ? Surely this will screw it up ..
Ok other than the math, which im sorry, isnt wrong. Im using M_ij where i is the row and j the column maybe thats the confusion? Can you see where errors may be
Normally I wouldn't question Duoas but the math actually looks correct to me -- at least on lines 20/21. Or am I crazy?
Apart from your transpose function not doing anything (should be returning a value..but you aren't using it anyway) I don't see any major C++ errors.
Your *= function looks ok...you could do it without MyMatrix newMat = MyMatrix(0,0,0) if you wanted to but I don't see that hurting anything. Are you sure all of your calculations are correct?
Im pretty sure but checking again cant hurt i guess. I used transpose to chek whether the final matrix is correct as itz supposed to symmetric. Its wierd because using the m_ij values outputted by the function, when i calculate det manually its almost 1 i.e 0.9997 ,wen the det function does it its exactly 1, using the same values??? Wtf. Also i get the ocasional m_ij = 234 or 2e+360 .. and ur nt crazy.. unless im crazy and its circular
The graph looks like a sinusoid on meth dno whats happening
Thanks
Tried your code and I get the same result. Shouldn't make any difference but the following is the header file that I used. The rest of the code was c/p from above.
Yeah sorry you're right. It does give those results. It stil has the det error, where when i do it by calculator its 0.99999 but the goddamm machine gives out 1 exactly. thats odd?? Also every nnow and again m12 or m22 is like 500.. what could cause these random errors any ideas?
its the m1 or m2 elements which are bllown up sometimes, but for the most part say 95% of the time are in the normal range for sines and cosines.
The setprecision() worked for the matrix elements, but for det it still gives 1. not even 1.00000 just 1 ?
Is there something wrong with the way ive written it to output det?
Im at a loss, is there any way i can upload armadillo library to my crappy bloodshed? Might be the only solution