Re: [eigen] Pass column by reference |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Pass column by reference
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Fri, 21 May 2010 12:04:46 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.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=M90jRbK6Qng4zcQKGafdRRkDRHYfZrYDn7IEecoHoUY=; b=YljorHIHn9tMDSEk8K7DVNbCaV3qEjiXkf93vXrXtEb+bzvPI5Kmabj4DGC/MHXd9z sW3vx5PqtJY9pRvOUUCl+YjiXqzSmt20Gt2cLc9tvYcSyDV/yb5bDcwf/uHEPUWwCmsW TgbLu2HI389//MOVdZtXSCBpCo6Na1MzJOJvc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=MIxnOSj0j4DO4WjrmSN+gY4NxM3Zw4RBU6CQeh5uD4i6mEr/BNNXqOC3bBJxt27/Y1 nlNAFogSfBvGbjrSziy+tWLVOXBN2adxF8Xa3OcIDkZ2rgjPKk6yqcewdFSiTIkuyB7Y FOC/qGE4rDCGzaNfXTt/9vKjLTfJuP/ndazcc=
You have two options:
a) declare a template function (that will take vectors as well as
col/row expressions)
template <typename Derived>
void putSomethingInVector(MatrixBase<Derived>& data {}
b) explicitly allows this for MatrixXf columns only by utilizing
Matrix typedefs for special expressions (here ColXpr)
void putSomethingInVector( MatrixXf::ColXpr& data) {}
I hope I did not make any mistake since I did not test, but that's how
it should be working.
- Hauke
On Fri, May 21, 2010 at 11:57 AM, Carlos Becker <carlosbecker@xxxxxxxxx> wrote:
> Hi everyone, I was wondering if it is possible to do something like this:
> void putSomethingInVector( VectorXf &data ) { work with data and modify it;
> }
> ---------------------------------------------------------------------
> MatrixXf myMatrix(100,100);
> putSomethingInVector( myMatrix.col(4) );
> ---------------------------------------------------------------------
> I know it is not possible like that, but is there any way? or .col() returns
> a read-only reference? I was looking for something like colRef() but no luck
> Thanks!
> Carlos