Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average on array

Status
Not open for further replies.

azer2k20

Technical User
Feb 15, 2007
1
GB
Hi,

I am quite new in C programming.
I would like to calculate the average of a single dimension int array: CODEC_DATA_R[3000]; Hence it's a big array, i am looking for the quicker solution...
Any idea? ( I would like to do it without loop)

thanks!
 
Do you want to average to be exact or approximate?
Is the array sorted?
 
> i am looking for the quicker solution...
How quick do you need it to be?
3K isn't much at all to most modern machines.

How do you know this is the problem area - I smell premature optimisation.

How often do you need to calculate the average - once?
How often does the data change?

If the data is pretty uniform, then getting the average of say the first 30 or first 300 (or pick a number) will give you an approximate answer.

But if the data has no useful properties you can make use of, then visiting all 3000 entries is unavoidable.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top