- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I have a matrix
complex mat(3, 2, 3)
I can also declare it as
complex array(18)
I can use both ways. This is a small matrix. Right now I have a very big matrix.
I want to know if it will make a difference with respect to the speed.
I mean when one is using this matrix/vector, will it take identical time to obtain one number from the memory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should use whichever way is easiest to understand by someone reading the code. The compiler knows how to optimize either one. If you use "a matrix", just be sure to vary the leftmost subscript the fastest so that you get the best memory access. That said, for such a small variable, it won't matter either way.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should use whichever way is easiest to understand by someone reading the code. The compiler knows how to optimize either one. If you use "a matrix", just be sure to vary the leftmost subscript the fastest so that you get the best memory access. That said, for such a small variable, it won't matter either way.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page