Click here to Skip to main content
15,913,487 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Storing more values in single BYTE. Pin
Sameerkumar Namdeo6-Nov-07 19:33
Sameerkumar Namdeo6-Nov-07 19:33 
GeneralRe: Storing more values in single BYTE. Pin
Dan Neely7-Nov-07 2:19
Dan Neely7-Nov-07 2:19 
GeneralRe: Storing more values in single BYTE. Pin
Sameerkumar Namdeo7-Nov-07 17:04
Sameerkumar Namdeo7-Nov-07 17:04 
AnswerRe: Storing more values in single BYTE. Pin
sgorozco28-Nov-07 19:52
sgorozco28-Nov-07 19:52 
QuestionRelative Speed of Trigonometry functions Pin
MikeMarq4-Nov-07 6:46
MikeMarq4-Nov-07 6:46 
AnswerRe: Relative Speed of Trigonometry functions Pin
Luc Pattyn4-Nov-07 6:59
sitebuilderLuc Pattyn4-Nov-07 6:59 
AnswerRe: Relative Speed of Trigonometry functions Pin
Paul Conrad4-Nov-07 7:31
professionalPaul Conrad4-Nov-07 7:31 
AnswerRe: Relative Speed of Trigonometry functions Pin
cmk4-Nov-07 10:22
cmk4-Nov-07 10:22 
Although the CRT is free to wrap, or even ignore, the CPU float functions when calculating sqrt, sin, cos, ... the following should give a rough idea of relative costs.

http://www.singlix.com/trdos/pentium.txt[^]

So, on a pentium, the following asm instructions take the following # of clock cycles:
FADD, FSUB, FMUL : 3
FDIV : 39
FSQRT : 70
FSIN, FCOS, FSINCOS, FPTAN : ~17-140

So, from the above we can make the following general recomendations:
- If you need to divide several values by the same amount, instead multiple them by the reciprical amount.
- sqrt is bad, try to avoid whenever possible.
- If you need both sin and cos use sincos, you get one for free.
- based on the low value for the trig functions it seems _likely_ (not sure) that they impliment a lookup table for some values, so adding your own on top will likely give little, if any, improvement.


...cmk

The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack

GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad4-Nov-07 10:53
professionalPaul Conrad4-Nov-07 10:53 
GeneralRe: Relative Speed of Trigonometry functions Pin
Dan Neely5-Nov-07 2:20
Dan Neely5-Nov-07 2:20 
GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad5-Nov-07 12:05
professionalPaul Conrad5-Nov-07 12:05 
GeneralRe: Relative Speed of Trigonometry functions Pin
Dan Neely5-Nov-07 12:46
Dan Neely5-Nov-07 12:46 
GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad5-Nov-07 14:05
professionalPaul Conrad5-Nov-07 14:05 
GeneralRe: Relative Speed of Trigonometry functions Pin
Robodroid17-Jan-08 10:15
Robodroid17-Jan-08 10:15 
GeneralRe: Relative Speed of Trigonometry functions Pin
MikeMarq4-Nov-07 19:54
MikeMarq4-Nov-07 19:54 
GeneralRe: Relative Speed of Trigonometry functions Pin
cp98764-Nov-07 22:27
cp98764-Nov-07 22:27 
AnswerRe: Relative Speed of Trigonometry functions Pin
Luc Pattyn5-Nov-07 2:36
sitebuilderLuc Pattyn5-Nov-07 2:36 
AnswerRe: Relative Speed of Trigonometry functions Pin
Alan Balkany29-Nov-07 5:02
Alan Balkany29-Nov-07 5:02 
AnswerRe: Relative Speed of Trigonometry functions Pin
serge_bal19-Dec-07 5:38
serge_bal19-Dec-07 5:38 
QuestionAlogorithim to compare two pictures Pin
w2094-Nov-07 3:33
w2094-Nov-07 3:33 
AnswerRe: Alogorithim to compare two pictures Pin
Luc Pattyn4-Nov-07 4:10
sitebuilderLuc Pattyn4-Nov-07 4:10 
AnswerRe: Alogorithim to compare two pictures Pin
FriendOfAsherah6-Nov-07 5:26
FriendOfAsherah6-Nov-07 5:26 
AnswerRe: Alogorithim to compare two pictures Pin
schoetbi26-Nov-07 10:50
schoetbi26-Nov-07 10:50 
QuestionInput suffers security. Pin
Cryptogrpahy2-Nov-07 21:33
Cryptogrpahy2-Nov-07 21:33 
AnswerRe: Input suffers security. Pin
cp98762-Nov-07 21:59
cp98762-Nov-07 21:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.