Warning: mysqli_real_connect(): Headers and client library minor version mismatch. Headers:50625 Library:50543 in /sites/rockbox.org/flyspray/adodb/drivers/adodb-mysqli.inc.php on line 108 FS#11229 : FFT: math rework



FS#11229 - FFT: math rework

Attached to Project: Rockbox
Opened by Delyan Kratunov (archivator) - Wednesday, 28 April 2010, 21:45 GMT
Last edited by Andree Buschmann (Buschel) - Wednesday, 12 May 2010, 02:42 GMT
Task Type Patches
Category Plugins
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.4
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Simplifies the math routines, removes all 64-bit math and unused 64-bit math sqrt function.
This task depends upon

Closed by  Andree Buschmann (Buschel)
Wednesday, 12 May 2010, 02:42 GMT
Reason for closing:  Accepted
Additional comments about closing:  Submitted with r25790
Comment by Bertrik Sikken (bertrik) - Thursday, 29 April 2010, 07:09 GMT
Just a quick note. It seem that in some cases you're first calculating a square root and then taking the logarithm. This can probably combined more efficiently (haven't tested it though):
* just take the logarithm without doing the square root first
* divide the result by 2
This uses the mathematical property log(x^a) = a log (x), where a = 0.5 in this case
Comment by Delyan Kratunov (archivator) - Thursday, 29 April 2010, 12:30 GMT
While that's technically true, I can't see how to use it here. Let me explain:

Before the if (tmp>0) bit, tmp is at most 29 bits (an assumption made throughout the code). The sqrt call makes sure that it's at most 14 bits, so that the right shift does not overflow.

If I don't do the sqrt, the right shift is virtually guaranteed to overflow, which is what this refactoring is trying to fix.
If I don't do the right shift at all but just leave the log call (it *is* in theory a linear mapping), values < 0xFFFF will be treated as less than 1, resulting in negative and quite large values for tmp - obviously not the desired outcome. Therefore, the right shift is needed and therefore, the sqrt call is needed to guarantee that the shift does not overflow.

If I'm missing something, do let me know.
Comment by Delyan Kratunov (archivator) - Thursday, 29 April 2010, 12:30 GMT
Sorry, that should say left shift, obviously.
Comment by Andree Buschmann (Buschel) - Tuesday, 11 May 2010, 20:01 GMT
Wasn't this submitted with r25790?
Comment by Delyan Kratunov (archivator) - Tuesday, 11 May 2010, 20:07 GMT
It was. I don't have the necessary privileges on FS to close the task (and frankly, I forgot about it :) )