lets say i have a list of coordinates in vectors eg
v1 = [1,2,3]
v2 = [4,5,6]
v3 = [7,8,9]
(list is much longer)
I can imagine two ways to organise these:
-
Put them in a large matrix as done for example by
eigvecs
,V = [1 4 7 …; 2 5 8 …; 3 6 9 …]
- Advantages: Easy to grab a vector of one coordinate
i
byv[i,:]
, probably a better use of memory since everything is on one place in one piece - Disadvantage: More difficult to create a Vector of a function of the vectors, for example the norm of all vectors
- Advantages: Easy to grab a vector of one coordinate
-
Put them in a Vector of Vectors as done for example by Solvers of DifferentialEquations,
V = [[1,2,3], [4,5,6], [7,8,9]]
- Advantage: Easy to do a norm of all vectors by
norm.(V)
- Disadvantages: More difficult to grab a vector of one coordinate, maybe not continuous in memory and thus slower (is that true?)
- Advantage: Easy to do a norm of all vectors by
So is there a general recommendation/best pattern?