CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

c/c++/Fortran efficient indexing

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By arjun
  • 1 Post By SergeAS
  • 1 Post By Sixkillers

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 25, 2011, 03:54
Default c/c++/Fortran efficient indexing
  #1
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 151
Rep Power: 17
Ford Prefect is on a distinguished road
Hey,

If I want to access an integer array several times in a loop is is more efficient to use a variable to hold the integer value, e.g.:

int array[];
int k;

for(i)
{
array[i]=k;
(k+5)/k+k^4;
}

rather than

for(i)
{
(array[i]+5)/array[i] + array[i]^4;
}

?

Thank you!
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:17.