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

blocks with nonconsecutive rows

Tags: None
(comma "," separated)
jzxu
Registered Member
Posts
2
Karma
0

blocks with nonconsecutive rows

Mon Apr 29, 2013 9:00 pm
Hi,

I was wondering if Eigen supports blocks with nonconsecutive rows/columns yet. Variations of this feature has been requested several times already (I didn't want to necrobump these posts, so I created a new one):

viewtopic.php?f=74&t=97652
viewtopic.php?f=74&t=98093
viewtopic.php?f=74&t=98382

However, I can't find anything in the changelogs about this feature being implemented.

I'm using Eigen for a machine learning application where I have a large matrix from which I repeatedly choose subsets of rows for linear regression. It'd be nice to not have to copy data around in each iteration.

Thanks,

Joseph
twithaar
Registered Member
Posts
23
Karma
0

Re: blocks with nonconsecutive rows

Mon May 06, 2013 2:32 pm
For a similar problem, I worked around this as follows:

initilization:
- pre-allocate a matrix 'sub' for the subset.
per iteration:
- use sub.row() or sub.col() to copy data into the subset (copying is much faster than memory-allocation)
- use sub.block().triangularView<Eigen::Upper>().solveInPlace(x) to solve for a variable number of parameters, without memory re-allocation.

I suspect the copying can be prevented by being clever with the permutation matrix.
It is my understanding that Eigen's current implementation requires the permutation matrix to have full rank,
which is cumbersome in this case, I assume.
jzxu
Registered Member
Posts
2
Karma
0

Re: blocks with nonconsecutive rows

Mon May 06, 2013 6:28 pm
This is essentially what I'm doing already. Can you explain your comment on permutation matrices? Are they an extra parameter into the solve function or something?
twithaar
Registered Member
Posts
23
Karma
0

Re: blocks with nonconsecutive rows

Tue May 07, 2013 6:40 pm
jzxu wrote:Can you explain your comment on permutation matrices? Are they an extra parameter into the solve function or something?


There's a permutation class in Eigen:
http://eigen.tuxfamily.org/dox-devel/classEigen_1_1PermutationMatrix.html
The subset could then be defined as:
Code: Select all
Eigen::MaxtrixXd sub, full;
Eigen::PermutationMatrix permutation(indices);
auto sub = (full*permutation).topRows(n);
qr.compute(sub);
auto x = qr.solve(b);

Eigen is then probably capable of doing all computations efficient.
I've never tried it, though, so I have no idea whether this would actually work.


Bookmarks



Who is online

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