codeZ
codeZ

Reputation: 55

function returning Matrix using Eigen library

using Eigen library, which I am new to:

I want to write a function that returms a 4x4 Matrix

Should it be a pointer to the matrix ??

Thanks all

MatrixXd Construct_TM(string tx, string ty, string tz)
    {
        MatrixXd T(4,4);
        T(0,0)=1;            T(0,1)=0;          T(0,2)=0;       T(0,3)=stoi(tx);
        T(1,0)=0;            T(1,1)=1;          T(1,2)=0;       T(1,3)=stoi(ty);
        T(2,0)=0;            T(2,1)=0;          T(2,2)=1;       T(2,3)=stoi(tz);
        T(3,0)=0;            T(3,1)=0;          T(3,2)=0;       T(3,3)=1;
        return T;
    }

Upvotes: 0

Views: 995

Answers (1)

luk32
luk32

Reputation: 16070

No. You should depend on compiler performing (N)RVO for this. Just remember to turn on all recommended optimizations, which should be obvious, since running c++ and Eigen with out them is kinda slow by definition.

Using a pointer would complicate the logic unnecessarily.

Upvotes: 1

Related Questions