Registered Member
|
Hi,
Is it possible to reserve space for inner vectors of a sparse matrix one by one? I'm not sure ahead of time how many entries each row will require, and they can be highly variable. I'd like to count the entries for each row as I compute them, storing them in a large intermediate array that I can re-use for all the rows, before putting them in the matrix. It should be a lot more memory efficient than the triplet method, and more computation efficient than computing all the entries twice (once for counting and once for storing). |
Moderator
|
Reserving memory one by one means N memory reallocation, so that would be extremely slow !
|
Registered Member
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]