Page 1 of 1

fastMath

Posted: Fri Aug 03, 2012 7:16 am
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

Re: fastMath

Posted: Fri Aug 03, 2012 7:26 am
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

Re: fastMath

Posted: Fri Aug 03, 2012 7:32 am
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

Re: fastMath

Posted: Fri Aug 03, 2012 11:56 am
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.

Re: fastMath

Posted: Fri Aug 03, 2012 11:59 am
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

Re: fastMath

Posted: Sat Aug 04, 2012 4:56 pm
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.

Re: fastMath

Posted: Sat Aug 04, 2012 5:18 pm
by Tectu
I have code is still arround, since benwilliam agreed to the license change too ;-)


~ Tectu