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

reading from sparse

Tags: None
(comma "," separated)
johnm1019
Registered Member
Posts
46
Karma
0

reading from sparse

Mon Jul 11, 2011 10:33 am
I think this is a silly question, but is there a way to read-access sparse matricies where I can do

mySparse.someFunc(row,col)
and if there is a coeff, it will return the value, and if its empty, it will return a 0?

I ask because nothing here (http://eigen.tuxfamily.org/dox-devel/cl ... mbers.html) appears to solve this problem

To provide a little background, I have some lookup tables that are 20-40% sparse and I wanted to index into them for the interpolation functions in a reasonably logical way and in this case we would benefit by saving the memory at the expense of extra cycles on the lookup.

thanks
johnm1019
Registered Member
Posts
46
Karma
0

Re: reading from sparse

Mon Jul 11, 2011 1:24 pm
In order to keep things in one thread, my current (sub-optimal) solution crashes the vs2010 compiler itself.

My current solution is to allocate a dense vector, setZero, then insert the non-zero coeffs from the sparse into the dense.

I'm trying to compile my code using VS2010 x64 target with optimization off and the compiler itself crashes with this error.

1>c:\users\USERNAME\desktop\local_code\branches\onlinecarving\thirdparty\eigen\eigen\src/Sparse/SparseTranspose.h(48): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1> c:\users\USERNAME\desktop\local_code\branches\onlinecarving\thirdparty\eigen\eigen\src/Sparse/SparseTranspose.h(53) : see reference to class template instantiation 'Eigen::TransposeImpl<MatrixType,Eigen::Sparse>::InnerIterator' being compiled
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Something like....
Code: Select all
std::vector< Eigen::SparseMatrix<float, RowMajor> >      m_lut;
....init stuff....
Eigen::VectorXf oneRow(m_lut[k].innerSize());
oneRow.setZero();
for (int j=0; j<m_lut[k].outerSize(); ++j)
{
   for (SparseMatrixType::InnerIterator it(m_lut[k],j); it; ++it)
   {
      oneRow(it.col()) = it.value();
   }
}

..........
Thoughts?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: reading from sparse

Mon Jul 11, 2011 3:07 pm
for the first question there is a .coeff(i,j) method that does exactly that.
johnm1019
Registered Member
Posts
46
Karma
0

Re: reading from sparse

Mon Jul 11, 2011 3:11 pm
ggael wrote:for the first question there is a .coeff(i,j) method that does exactly that.


Well I feel stupid. Shouldn't that show up on that documentation page, or is my link above to a page which doesn't list all the members?


Bookmarks



Who is online

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