Re: [eigen] How to create a Matrix<...> without copying data ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] How to create a Matrix<...> without copying data ?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 17 May 2010 09:02:41 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=okuN5tjSnBx5p0vvdbBy1Z3laRdWu9WdWwvIHSalVNY=; b=ckt9Ka00/yDnkldS/4stcx06fHkjn43COjgdBqI4miSmEjx38phegXYLPJLc4X2L1+ /y0TSU/Woh3aM8aqzhLAmTRlj6sl0v8+W1gvuhjXC8eNox0DI+K5wUhuHMaB11qfLIt4 Vb6AmjiwOTupF8S4DeX9FfMfEf0JjHxxata9Q=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=MlQjSl43z81VQPUU1BC1AS3QlwMb7EfZPPS9b35J3eR5LTqU3rA6ksbUkbvxa1RU6S hi4k9G14j3ssXgCTauh/5GvEYfoVOOyCDAF4E4FZNd1lhuvUD6VCkkBOvkbwq0C63g0Z Fd6gFBYTeZSd6Uoe9ljfO6d9Nmk/1gqh4WkHU=
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
>
>>> >
>
>>> >
>
>>> >
>
>>>
>
>>>
>
>>>
>
>
>