This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Resizing Refs

Tags: None
(comma "," separated)
michej
Registered Member
Posts
3
Karma
0

Resizing Refs

Sat Jun 22, 2013 12:55 pm
Hi,

I'm trying to use the Ref class to define function arguments in a convenient way. I'm wondering however if it's possible to use these objects without initializing their size - e.g. I would like to do something like this:

Code: Select all
#include <Eigen/Dense>
#include <Eigen/Core>
#include <Eigen/src/Core/Ref.h>
using namespace Eigen;

void foo(const Ref<const MatrixXd>& A, Ref<MatrixXd> B){
B.resizeLike(A);
}

int main(){
MatrixXd A = MatrixXd::Constant(5,5,1);
MatrixXd B;

foo(A,B);

return 0;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Resizing Refs

Sat Jun 22, 2013 1:58 pm
The purpose of Ref is unify matrices, sub-matrices and mapped matrices. However, only Matrix<> objects are resizable, so if you want a resizable object use a Matrix<> type for the argument.
michej
Registered Member
Posts
3
Karma
0

Re: Resizing Refs

Sat Jun 22, 2013 2:32 pm
Ok, that works! Thanks for helping me!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]