Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28381 Discussions

Is it make a difference to use a matrix instead of an array (vector)?

Tai_Q_
Beginner
234 Views

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?

0 Kudos
1 Solution
Steven_L_Intel1
Employee
234 Views

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.

View solution in original post

0 Kudos
1 Reply
Steven_L_Intel1
Employee
235 Views

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.

0 Kudos
Reply