[3/3] gdiplus: Make GdipInvertMatrix test pass on native

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sat Jul 12 18:14:31 CDT 2008


Am Samstag, den 12.07.2008, 23:56 +0100 schrieb Reece Dunn:
> > Nikolay: Please write a test whether the matrix
> >  1.0/131072, 2.0/131072, 4.0/131072, -1/131072, 0, 0
> > is invertible. According to your criterion, it is *not* invertible, as
> > the determinant will be 9.0/17179869184, which is way below 1e-5, but
> > this matrix still *is* invertible. What happens on Windows?
> The identity matrix would also be a nice test case - for the other GDI
> and DirectX matrix operations as well.
Yes. Excellent idea! Determinant is one. Division by one is exact. This
should definitely yield exact results.

Now, add the identity matrix scaled by a big power of two (like 2^60)
and divided by that power of two. Powers of two are as good as a simple
one if you are on floating point numbers.

If you are brave enough to really find out what happens (might be
different depending on Windows version, instruction sets available and
things like that), also try the identity matrix scaled by 2^66 and
2^(-66). The square of 2^66 overflows a 32 bit floating point number.
So, if you calculate within x87 coprocessor registers, you can invert
the matrix. If you store to double variables too. If you store to float
variables or calc via SSE or 3Dnow! (overkill for a matrix inversion, I
know), matrix inversion probably fails, if no tricks are used.

Regards,
  Michael Karcher




More information about the wine-devel mailing list