Re: [eigen] Permuted Matrix |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Permuted Matrix*From*: Manoj Rajagopalan <rmanoj@xxxxxxxxx>*Date*: Mon, 19 Jul 2010 19:57:33 -0400*Organization*: EECS Dept., University of Michigan, Ann Arbor, MI, USA

If implementing in Eigen is not possible for any reason, can you, for your application, use the existing Eigen machinery as follows ... The class Transpositions represents row/column interchanges. You can create one for row-interchanges and one for column and then apply them using the * operator like normal matrix multiplication. eg: Transpositions rowTransp, colTransp; // initialize them MatrixXd A(N,N), B(N,N); B = rowTransp * A * colTransp; // () if/as necessary If you want to store the product expression as a temporary then you will need to use typedefs to "cache" the fairly-involved type expressions (using ei_transposition_matrix_product_retval<> etc.). See Transpositions.h Also, I see a Transpose<Transpositions<...> > and Transpose<PermutationMatrix<...> > in the doxygen documentation. They might be useful to you in achieving your objective indirectly. cheers! Manoj On Monday 19 July 2010 05:39:11 pm ESCANDE Adrien 222264 wrote: > Hello, > > I'd like to implement a permuted matrix i.e. a matrix P base on another M, > such as P(i,j) = M(r[i], c[j]) for some permutation vectors r and c. It is > very similar to the subject of another thread (how to create a "virtual" > array or matrix) whose conclusion was to look at the way Minor class is > implemented. > > Based on this Minor example, it is indeed easy to implement a > PermutedMatrix class for read-only purpose. It goes like this: > template<typename MatrixType> class PermutedMatrix > > : public MatrixBase<PermutedMatrix<MatrixType> > > > { > ctor > overload of coeff and coeffRef > } > > One can then access to coefficients of the matrix, use block expression, > triangular view,... > > Writing in such a matrix is however a problem: PermutedMatrix can't have > the DirectAccessBit bit because the "layout of the array of coefficients" > is not "exactly the natural one suggested by rows(), cols(), outerStride(), > innerStride(), and the RowMajorBit" DirectAccessBit documentation). Thus > PermutedMatrix only derives from DenseCoeffsBase<Derived, false> and not > DenseCoeffsBase<Derived, true>. In particular, it does not inherit the good > operator() (Index, Index), and the copyCoeffByOuterInner(Index, Index, > const DenseBase<OtherDerived>&) methods, the latter being needed in the > assignation. > > Adding these missing methods directly in PermutedMatrix solves part of the > problem: one can do P(i,j) = some_value or P = some_matrix, but they are > still missing in expression based on PermutedMatrix , thus one can not do > P.block(i,j,r,c) = another_matrix, because the copyCoeffByOuterInner of > DenseCoeffsBase<Expr<PermutedMatrix<MatrixType> > > (in my example, Expr is > Block) is not correctly defined. > > Do I miss something on this problem ? Any direction I could take, or flag I > don't know of ? I'm not very familiar with Eigen internals yet, so any > pointers would be welcome. > > Thank you, > > Adrien Escande

**References**:**[eigen] Permuted Matrix***From:*ESCANDE Adrien 222264

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Permuted Matrix** - Next by Date:
**[eigen] sparse solvers issues 2.0.15** - Previous by thread:
**Re: [eigen] Permuted Matrix** - Next by thread:
**[eigen] sparse solvers issues 2.0.15**

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