Registered Member
|
in octave, I can do:
I = [1 2 3]; J = [3 1 2]; V = [32 42 53]; sp = sparse(I, J, V, 5, 4, 10) size(sp) nnz(sp) returns 3 nzmax(sp) returns 10 With Eigen, I can use 'reserve' but how to get this value after ? I found a method allocatedSize() but how to have access to this method ? Eigen::SparseMatrix<double, 0, signedIndexType> *spmat = ... spmat->reserve(10) How to get reserved value ? Thanks |
Moderator
|
|
Registered Member
|
Exposed code:
I = [1 2 3]; J = [3 1 2]; V = [32 42 53]; sp = sparse(I, J, V, 5, 4, 10) size(sp) nnz(sp) nzmax(sp) spmat allocated with : Eigen::SparseMatrix<T, 0, signedIndexType> *spmat = nullptr; spmat = new Eigen::SparseMatrix<T, 0, signedIndexType>(maxrow, maxcol); spmat ->conservativeResize(maxrow, maxcol); spmat ->finalize(); spmat ->makeCompressed(); after: int nnz = 10; spmat->reserve(nnz); spmat->finalize(); spmat->makeCompressed(); int nzmax = spmat->data().allocatedSize(); nzmax equals to 13 and not 10 as expected. "How to get 10 ?" I modified my code as: spmat->reserve(nnz); spmat->finalize(); spmat->makeCompressed(); spmat->data().squeeze() |
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]