fastMath

Locked
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

fastMath

Post by Tectu »

Hello Folks,

benwilliam, the guy who contributed lcdDrawEllipse() also contributed two files, fastMath.h and fastMath.c which can be found in the glcd directory. In there he has some simpler functions to get the sine value etc. That is because he used this on some small 8-bit AVRs.
However, inside fastMath.c, there is float sinetable[91]. This values are stored in RAM because the tiny AVRs would have to long to use sin().
Does it make sense to keep these 364 bytes in RAM or isn't sin() that expensive on ARMs?


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: fastMath

Post by Giovanni »

I would not write architecture-specific code, make it optimal thinking in general "C", architecture-optimized code paths can be added later.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: fastMath

Post by Tectu »

I fully agree with that. I asked some guys which know much about this stuff. They said that sin() is fine when using things like newlib etc.
This wouldn't result in any architectur specific code as well, eh?


~ Tectu
Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm

Re: fastMath

Post by Abhishek »

The fastMath code is used only for drawing rotated rectangles and other things, not for the ellipse drawing routines we are doing currently, this means, that the file is unused as of now.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: fastMath

Post by Tectu »

That's correct. I just kept it because benwilliam told me he will keep working on the rotated rectangles etc. The question was meant in general, not depending on lcdDrawEllipse()


~ Tectu
inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm

Re: fastMath

Post by inmarket »

This is code that I will probably be using when I create my audio mixer and tone generator driver. Being able to generate sin's really fast is going to be important and so I am going to be doing testing to compare with the native library routines (which I suspect will be very slow).
Please keep the code around - it will find a use, and my possible use of sin's is likely such a one.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: fastMath

Post by Tectu »

I have code is still arround, since benwilliam agreed to the license change too ;-)


~ Tectu
Locked