This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Reserve inner vector of sparse matrix

Tags: None
(comma "," separated)
recarroll
Registered Member
Posts
2
Karma
0
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).
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Reserving memory one by one means N memory reallocation, so that would be extremely slow !
recarroll
Registered Member
Posts
2
Karma
0
Good point, thanks!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]