Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Beginner
27 Views

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

Jump to solution

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

Accepted Solutions
27 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
28 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