Helmut,
I cannot point you in the direction of a 'quick' readily available library but
here are some thoughts that might help.
a) logf((float)v / 10000.0) is an identity with ( ie an = with 3 lines)
logf((float)v) - k where k=logf(10000.0)
k you can pre-calculate on your calculator so the floating division is
replaced by a subtract. This should save a good few cycles for free.
b) since you do not seem to need full float precision (presumably you're
casting v from some sort of int) you could construct a piecewise linear
approximation of the function such that the error is within your required
limits. Then all you need is a linear interpolation lookup which will give a
calculation of the following form
vTable[i] + (vTable[i+1] - vTable[i])/k
where k is the fraction of the distance form vTable[i] to vTable[i+1] of
your input parameter v. (0 <= k <= 1)
this reduces the function to 2 floating add/subs and a float division plus 2
float array reads and some int index cals. Alternatively you might get away
with a table of the same int type as v in which case (vTable[i+1] - vTable[i])
becomes 2 int array lookups and 1 float cast. Unlikely to save any time but
should give a significant reduction in the size of the table.
A non-linear spaced table would be even smaller but you have to find the table
index by some sore of search which would add a few cycles.
Does that help?
Best wishes,
John Pote
----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Wednesday, July 19, 2006 1:15 PM
Subject: [Mspgcc-users] Libmath: powf() and logf() are too slow
Hello,
recently i discovered that the powf() and logf() are
sooooooooooooooooooooooooooooooo
slow that it hurts.
If youre watching execution on a Scope a
----8<----
DbgOut_P20_ON;
r = logf((float)v / 10000.0); // takes up about 10 ms (!!)
DbgOut_P20_OFF;
----8<----
and a
----8<----
DbgOut_P20_ON;
r = powf(10,(float)v / 10000.0); // takes up about 32 ms (!!!!!!)
DbgOut_P20_OFF;
----8<----
this is pure horror 4 me!
Has anybody a faster (and only slightly less precise) version of these?
Cutting calulation time by 10...50 is my goal.
Ciao,
Helmut
------------------------------------------------------------------------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
------------------------------------------------------------------------------
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.1/391 - Release Date: 18/07/2006