View previous topic :: View next topic |
Author |
Message |
Nikki Guest
|
math.h, how fast or slow? |
Posted: Mon Jun 23, 2003 4:41 pm |
|
|
I'm using an 18F452.
Can it be right for math.h to take 11078 instructions to calculate cosine?
Inside "float cos(float x)", the line below costs just 1780 instructions.
quad = (int)(x / PI_DIV_BY_TWO); // quadrant
Is this expected?
It seems to be calculating correct values as I'm using these functions in graphics routines, but it's so sloooww.
Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515490 |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
Re: math.h, how fast or slow? |
Posted: Mon Jun 23, 2003 5:24 pm |
|
|
One way to work around the slowness of the Cos function is to set up a Cosine table in your program and then simply perform a table look-up whenever you need a Cos value.
Ali
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515493 |
|
|
Nikki Guest
|
Re: math.h, how fast or slow? |
Posted: Mon Jun 23, 2003 5:53 pm |
|
|
:=One way to work around the slowness of the Cos function is to set up a Cosine table in your program and then simply perform a table look-up whenever you need a Cos value.
Thanks, I'm having a look at the CORDIC algorithm at the moment, though I'll probably go with a table.
Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515497 |
|
|
|