Vector Of Vecotrs

Hello Everyone,
I am trying to build a program which develops a vector of vectors using Thrust in CUDA.
I managed to build the vector of vectors but now i cannot figure out how to manipulate each element separately within that.

Following is my code :

thrust::device_vector<thrust::device_vector<float> > Vec(4);
	for(int i=0;i<Vec.size();i++)
	{
		Vec.push_back(thrust::device_vector<float>(5,6));
	}

for(int i=0;i<Vec.size();i++)
		{
			for(int j=0;j<5;j++)
			{
				std::cout<<Vec[i][j];          //This line gives an error
			}
		}

Error: No operator “” matches these operands

I would like to know how to access each element separatly within this vector of vectors now.
Thank You.

also asked here:

https://devtalk.nvidia.com/default/topic/997266/gpu-accelerated-libraries/vector-of-vecotrs-using-thrust/

Don’t use a literal vector of vectors, that kind of design doesn’t work that well.

Instead, it’s the most simple to simply allocate a 1d array of data but then access it like it’s 2d.

Because this is C++, you can create relatively thin class wrappers around this that’ll provide 2d-based access while still maintaining a sane internal storage organization.

I have a host device matrix implementation that sort of plays to this strength. You can use Compiler Explorer to get an idea of your abstraction costs and if it’s worth it. Keep in mind, optimizations really do help eschew abstraction overhead.