Registered Member
|
very newbie questions:
We create a sparse matrix: SparseMatrix<double> sm; don't know the size until later, and it will change, so: sm.resize(N,N); does this simply set the matrix dimensions, but no memory allocation? then, assume we would have no more than 5 elements per column sm.reserve(5*N); this is what allocates internal memory, right? load the matrix with sm.setFromTriplets(...) next, we use our matrix for some solutions, then we want to reuse the matrix with new values, so: sm.resize(M,M); what does this do to the values already in the matrix, and the memory allocation? do we need to reserve memory again, if it hasn't changed? sm.reserve(5*N); same question -- what about existing values? next, load the matrix with new values sm.setFromTriplets(...); at this point, is it certain that the matrix contains only new values, and no old values? thanks in advance for any responses Kevin |
Moderator
|
Currently, calling reserve before setFromTriplets is counter productive because setFromTriplets does it for you. And yes, setFromTriplets replace the entire content of the matrix. Same for resize(), which turns the matrix as an empty matrix.
|
Registered Member
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]