Registered Member
|
hello all,
i need to put a eigen::VectorXi inside an *int container: extern "C"{ void R_fastr(int* n, int* p, int* k0,float* x,int* k1,int* RIndexC,int* nsamp,int* J,float* objfunC,int* h_m){ Map<MatrixXf> x_cen(x,*n,*p); MatrixXf x_cen1 = x_cen; int h_i=*p+1; while(Binomial(h_i,*p)<=*k0) h_i++; int h,j,h_o,i; float objfunA,objfunB=*objfunC; VectorXi RIndexB(*h_m); RIndexB=call_to_a_function_returning_vectorXi(x_cen1) //here: for(i=0;i<ih_m;i++){ RIndexC[i]=RIndexB(i); } } } I was wondering whether there was a way to replace for(i=0;i<ih_m;i++){ RIndexC[i]=RIndexB(i); } by a map/cast/...i.e. a pre-written method. Best, |
Moderator
|
I did not read your code, but you can get inspiration from that:
int * data; VectorXi vec(size); Map<VectorXi> (data, size) = vec; |
Registered Member
|
Dear ggael,
corrct me if i misunderstood your answer, it seems your advice would help me move the content of data unto a vectXi object vec (this is covered in the manual). i'm trying to do the opposite: move the content of a vectorXi to data. //say: int n=100; vector<int> second (n,0); VectorXi vec= VectorXi::Random(n); for(int i=0;i<n;i++){ data[i]=vec(i); } my question is: is there a method to do this loop? (a sort of reverse map, really) |
Moderator
|
what I wrote exactly does that. A Map object is just like an Eigen's matrix object.
|
Registered Member
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]