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

Looking Faster alternative to this simple construct

Tags: None
(comma "," separated)
vak
Registered Member
Posts
23
Karma
0
OS
Dear all,

consider this simple construct:

Code: Select all
   for(i=0;i<k1;i++){
      for(j=0;j<k1;j++){
         for(m=0;m<h_m;m++)   proj(m)=Tabfl(Tabid(m,i),j); //[1] is this really necessary?
         TabF(i,j)=proj.head(h_m).maxCoeff();         
      }
   }


Where Tabfl is a n by k1 MatrixXf and Tabid is a n by k1 MatrixXi and proj a length h_m VectorXf.
I'm doing this sort of thing a lot. In Armadillo, there is a function to replace [1] by a matlab-like
expression:

i.e.
Code: Select all
         for(m=0;m<h_m;m++)   proj(m)=Tabfl(Tabid(m,i),j); //[1] is this really necessary?
         TabF(i,j)=proj.head(h_m).maxCoeff();         


would become:
Code: Select all
         TabF(i,j)=Tabfl(Tabid(,i).array(),j).maxCoeff();      


Is there anything comparable in Eigen? This is the closest alternative i can think of in this particular case:


Code: Select all
   for(i=0;i<k1;i++){
      for(m=0;m<h_m;m++)   Tabf2.row(m)=Tabfl.row(Tabid(m,i)); //is this really necessary?
      TabF.row(i)=Tabf2.colwise().maxCoeff();         
   }


Where Tabf2 is a h_m by k1 MatrixXf
Best regards,
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
vak
Registered Member
Posts
23
Karma
0
OS
thanks (you gotta <3 Eigen :) )


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]