Cymbeline
07-05-2000, 02:42 PM
This may be a stupid question, but here it is:
Which array declaration will be faster to access?
1.
int Matrix1[5][12];
int Matrix2[5][12];
int Matrix3[5][12];
2.
int Matrix[3][5][12];
Cymbeline
Paul Victorey
07-05-2000, 03:08 PM
Well, option #2 is easier to program with, as you will have only a single array.
As to speed, I really couldn't tell you. It may vary depending on compiler even.
Why not create code to read, one at a time, every element of the array(s) using both styles, do this something like 1000 times (it would be too quick to really measure otherwise) and have the program take a beginning and end time and subtract? I don't think it's going to be much different though. I wouldn't know how to get this info except by testing it.
------------------
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.