Modifying the element in the vector of vectors


What should I do if I just want to modify the fifth element in the third vector?

The vector of vectors, has several copies of the same vector (backed by same memory). The proper way to initialize a vector with different vectors is:

waccf = [zeros(5) for _ in 1:7]

This way, every vector is in a different memory location and the assignment works as expected.

2 Likes

To nitpick on terminology, it’s the same vector referenced by all elements of the vector-vector; copy implies different memory.

2 Likes