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*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Mon, 17 May 2010 13:32:22 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=GLbZ6YVHyXi8BXehDL8Ehg/sHbFeRIVd8ddEpH62asA=; b=UNHHUAhr9x6r+omQngSNRVny9ka4vvFjEeePnWNMB84XbCo61OQprpj4hcnBCwbNMp JsCZ84mT4hvqTlhfTo+A1qPkWnlWfBl6GPWQNKc7NMoV85uhkvs/Ca830NJ9f9i6o4TJ IFMPnB+1trV3rXrFHJ68IHu74nE6xQMkR4mUE=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=cyeQbKYxRpgMjahfBbKaHkO+/nRGoeJPjjvkD/rRVOebh/rE3sZ+i0qUlYwW6jc21y SCVpahUlu/UDzPP0wL15k0+pj3xXHHE5Yr9Un+99wZ4S0bcdD3aGGSYn0JlAGdiOtQOM LLCveS0RmQCPWs4n97pe3h7+G3hJCsvlJdz4k=

On Mon, May 17, 2010 at 12:30 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:

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

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

>

>

>

**Follow-Ups**:**Re: [eigen] How to create a Matrix<...> without copying data ?***From:*vincent.lejeune

**References**:**[eigen] How to create a Matrix<...> without copying data ?***From:*vincent.lejeune

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

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Indexes: why signed instead of unsigned?** - Next by Date:
**Re: [eigen] Indexes: why signed instead of unsigned?** - Previous by thread:
**Re: [eigen] How to create a Matrix<...> without copying data ?** - Next by thread:
**Re: [eigen] How to create a Matrix<...> without copying data ?**

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