I've been building a basic matrix class (based on Capper's book) to do some other work. While testing the class and functions, I noticed that the result I get for my transpose function changes whether or not it is displayed (using cout) before I use my multiply function. For example, if I do things in this order:
"transpose matrix A, multiply 2 (other) matrices, display transpose(A)"
transpose(A) comes out wrong but if the code executes in this order:
I don't know if it applies to this case, but once I had a similar problem. I purposely wrote a recursive function that used floating point equality to determine whether to return or recurse. There was infinite recursion only when the values of the parameters were printed at specific points inside the function. I was told by someone in this forum (Duoas, probably) that printing forced the values out of the FPU -- which uses floating point registers much bigger than the CPU -- back into memory, where the values were put into regular floats.
thanks for the explanation, this was really frustrating. Is there a better workaround to this issue, maybe a better way to write the transpose function (i.e. why are the values being stuck in the FPU?)