Re: [eigen] Let's get reshape in shape for 3.4 |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Let's get reshape in shape for 3.4*From*: Julian Kent <jkflying@xxxxxxxxx>*Date*: Wed, 22 Feb 2017 11:49:57 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=fz1w5nVLBYxkTfdK49QAQ9PK5r0jEcETaa6ZFgD/nc8=; b=QSHCX0Nc+QeIBV6if0/2TmbtnB1Goouu423lMeOWqdKfpdM/3rK/e96OB+YP0YM4C9 V/8bFGK/tFkTfTLyhheiIGJueFF3t/yDjJJMD1dKZom+JLIiWbK9GbmpcekwMpq0PGPA MFKzUDgbZrd19BfR+hsvIdAayGRuH6sOqa61LjnqMD4GABEQCl8i9S2wtOD5lkh0yu04 um6te7JZfZtZX0SKOj283FvshXm015UBggDRDdK+5RwxldTxvVPMD6Ea/DpRwTDOpAoN xtLAP2VwhmDKJwfKqlTCoZ8gQfi2VIC6igjQZwUViF1cJfvVZ1i0F5HGMrmHUGCXbsU5 iYaw==

On 21 February 2017 at 20:47, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:

On Tue, Feb 21, 2017 at 8:30 PM, Julian Kent <jkflying@xxxxxxxxx> wrote:

A question, is this implemented for sparse matrices as well?

Not yet, and I did not plan it for 3.4, but contributions are always welcome. Do you have use cases in mind?

I have a few specific use-cases where the current indexing was painful:

1) Getting many small (less than 15xk, k << n), dense subsets of a large, sparse matrix where I already know that all of the elements at the column/row indices I'm requesting are non-zero. I'm doing this with InnerIterator at the moment, but it isn't obvious what is happening due to the verbosity. The code would be much more readable if it was obvious that I was getting values at specific indexes.

2) Reordering with a subset at the same time. This could also be done with a lossy (non-square) permutation matrix. Instead I need to reorder the entire matrix, then take the subset with (for example) leftColumns or topRows. Even if the rest of the reorder due to the subset taken, what is done with the extra permutation indices in the ignored part of the matrix feels like an implementation detail I shouldn't have to worry about, and if the number of columns (or rows) I need is small, it feels like a waste constructing the entire permutation matrix (which is different in every case). I guess I could also do this with a SparseMatrix, but reshape would be much more concise.

1) Getting many small (less than 15xk, k << n), dense subsets of a large, sparse matrix where I already know that all of the elements at the column/row indices I'm requesting are non-zero. I'm doing this with InnerIterator at the moment, but it isn't obvious what is happening due to the verbosity. The code would be much more readable if it was obvious that I was getting values at specific indexes.

2) Reordering with a subset at the same time. This could also be done with a lossy (non-square) permutation matrix. Instead I need to reorder the entire matrix, then take the subset with (for example) leftColumns or topRows. Even if the rest of the reorder due to the subset taken, what is done with the extra permutation indices in the ignored part of the matrix feels like an implementation detail I shouldn't have to worry about, and if the number of columns (or rows) I need is small, it feels like a waste constructing the entire permutation matrix (which is different in every case). I guess I could also do this with a SparseMatrix, but reshape would be much more concise.

3) Make a copy of a sparse matrix, but only keeping the pattern of non-zeros which are already present in the destination. Reshape would let me at least do this on a column-wise basis, using the indexes of the destination to get the data from the source. Like in 1), I'm doing this the long verbose way with InnerIterator at the moment.

Mostly though, it is for ease of translating algorithms from Matlab into Eigen. The closer the syntax, the less likely there are bugs. This is already a benefit of reshape for dense matrices, but I work mostly with sparse matrices.

--

Julian

**Follow-Ups**:**Re: [eigen] Let's get reshape in shape for 3.4***From:*Gael Guennebaud

**References**:**Re: [eigen] Let's get reshape in shape for 3.4***From:*Gael Guennebaud

**Re: [eigen] Let's get reshape in shape for 3.4***From:*Julian Kent

**Re: [eigen] Let's get reshape in shape for 3.4***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Let's get reshape in shape for 3.4** - Next by Date:
**Re: [eigen] Let's get reshape in shape for 3.4** - Previous by thread:
**Re: [eigen] Let's get reshape in shape for 3.4** - Next by thread:
**Re: [eigen] Let's get reshape in shape for 3.4**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |