Re: [eigen] How to create a Matrix<...> without copying data ?

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


Yes, Eigen defaults to column-major. You can change that per-matrix by
using the RowMajor option, for example:

 typedef Matrix<double, Dynamic, Dynamic, RowMajor>  MyRowMajorMatrixXd;

or you can change the global default, breaking the ABI, by doing

#define EIGEN_DEFAULT_TO_ROW_MAJOR

Benoit

2010/5/17  <vincent.lejeune@xxxxxxxxxx>:
>
> Thx.
>
> BTW are Eigen matrix stored in column major format, as with blas/lapack,
>
> by default ?
>
> Is there a command to change storage order of a matrix ?
>
>
>
> On Mon, 17 May 2010 13:32:22 +0200, Gael Guennebaud
>
> <gael.guennebaud@xxxxxxxxx> wrote:
>
>> On Mon, May 17, 2010 at 12:30 PM, Benoit Jacob
>
>> <jacob.benoit.1@xxxxxxxxx>wrote:
>
>>
>
>>> You can do:
>
>>>
>
>>> PartialPivLU<MatrixXd> lu(matrix.block(...));
>
>>>
>
>>> or, from your double* pointer,
>
>>>
>
>>> PartialPivLU<MatrixXd>
>
>>>  lu(Map<MatrixXd>(pointer,rows,cols).block(...));
>
>>>
>
>>> or you can even get rid of the block() call by doing a strided Map.
>
>>>
>
>>> What we don't allow at the moment is in-place LU, i.e. allowing to not
>
>>> even copy that block.
>
>>>
>
>>
>
>> well, if you are not afraid about using internal functions, and so
>
>> functions
>
>> which can be removed/changed in the future, you can use this one:
>
>>
>
>> template<typename MatrixType, typename IntVector>
>
>> void ei_partial_lu_inplace(MatrixType& lu, IntVector&
>
> row_transpositions,
>
>> int& nb_transpositions);
>
>>
>
>> e.g.,
>
>>
>
>> // declare a name variable for the block because current C++ standard
>
>> sucks.
>
>> Block<MyMatrix> bl(matrix, ....);
>
>> VectorXi row_transpositions(matrix.rows());
>
>> int nb_transpositions;
>
>>
>
>> ei_partial_lu_inplace(bl, row_transpositions, nb_transpositions);
>
>>
>
>> The problem is that now you cannot exploit this LU dec via the
>
> PartialPivLU
>
>> API, but maybe that's enough for your needs... ?
>
>>
>
>> gael
>
>>
>
>>
>
>>>
>
>>> Benoit
>
>>>
>
>>> 2010/5/17  <vincent.lejeune@xxxxxxxxxx>:
>
>>> >
>
>>> > Hi,
>
>>> >
>
>>> >
>
>>> >
>
>>> > I have a matrix stored as a double* in columnsmajor format.
>
>>> >
>
>>> > I would like to compute the LU factorisation of a part of the matrix
>
>>> (that
>
>>> >
>
>>> > is, not the whole matrix, just a sub square of it) inplace, ie I do
>
> not
>
>>> >
>
>>> > want to copy data to an temporary buffer.
>
>>> >
>
>>> >
>
>>> >
>
>>> > Is it possible using Eigen ? I saw that PartialPivLU class copy input
>
>>> >
>
>>> > matrix when constructed...
>
>>> >
>
>>> >
>
>>> >
>
>>> > Thx,
>
>>> >
>
>>> > Vincent
>
>>> >
>
>>> >
>
>>> >
>
>>>
>
>>>
>
>>>
>
>
>



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