[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Ref<> Problem
- From: Gabriel <gnuetzi@xxxxxxxxx>
- Date: Thu, 04 Dec 2014 00:14:21 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=kqYXuP90cpJs5/u9MssuU2Di2ZnOLvLIvEFMEEL0pRs=; b=YNcwlaqmronFVDt1/MiRyVxCqW/8naQDUKwGqKIAwE0wBbYxojrjxIJ+3HQOlHXoA3 mf9negH4WnhQQEVWvP9gSRMOVuUsLjCOJdyye8i1XV4YgaUka0LSPsipYD6WXjyl0d+3 as65ZCqHTPj25QP00zAYjoBnWjEwBHiA9fpUA2gnhJu1ZS+nYKUA7UDUX/vHpudq6DfJ UWqaS/j31aXnq7nhV1rfbBTqTPrsXpqNWhf2xAgQTQsZHCm+lk6l3rFmDC00DuQWN3Zt wc3qK2XNkxtLwtFabzbii5qAoBX8RhFxhkT5jDurbpkp/0Ikv6/Y4id6s90iJilEda3M IYJg==
Dear all,
If I want to store a Matrix as a reference for read only acces in a
class ( I wanted to be able to also reference a Block<> of Matrix, thats
why Ref<> )
I wanted to used the Ref<> class but the following gives some problems:
struct A{
A( const Eigen::Ref< const Eigen::MatrixXd> & in)
: r(in){}
Eigen::Ref< const Eigen::MatrixXd> r;
};
Eigen::MatrixXd a(3,3); a.setOnes();
A myA(a.topRows<2>());
std::cout << myA.r << std::endl; ///< No crash
A myA2(a.topRows<2>() * 2);
std::cout << myA.r << std::endl; ///< crash since the expression
a.topRows<2>() * 2 was evaluated into a temporary and assigned to a
Ref<> in the class
How can I avoid such errors, and whats the correct way of storing a
reference to a Matrix in a class?
Thanks a lot!!
Gabriel