Hi!

i have a question. I have a lot of data in a 2d array and want to know the most efficient way to save it. It mainly has numbers of long long. Is vector of vectors a good idea where one vector holds the info of a row and the other vector the starting address of each row? If there be an better way please help!!

Thanks!

Tacy :)

i have a question. I have a lot of data in a 2d array and want to know the most efficient way to save it. It mainly has numbers of long long. Is vector of vectors a good idea where one vector holds the info of a row and the other vector the starting address of each row? If there be an better way please help!!

Thanks!

Tacy :)

Yes, a vector of vectors.

Ideally, not

but

one vector holds the the vectors for each row

and the vector for each row holds the long long values in that row

Ideally, not

one vector holds the info of a row and the other vector the starting address of each row? |

but

`std::vector< std::vector< ``long` `long` > > ;

one vector holds the the vectors for each row

and the vector for each row holds the long long values in that row

Since 80% of my matrix is full of 0s i think using a map nested in a vector would be a better idea. However I am having trouble with syntax coz I defined it like:

`std::vector< std::map<std::string,``long` `long`> > data;

but now how do I add an element or value???
¿string?

http://www.boost.org/doc/libs/1_52_0/libs/numeric/ublas/doc/matrix_sparse.htm

`data[13][``"answer"`] = 42;

http://www.boost.org/doc/libs/1_52_0/libs/numeric/ublas/doc/matrix_sparse.htm

Last edited on

Topic archived. No new replies allowed.