1

In eigen, i need to place a MatrixXf unto an existing array. Now, this works:

    MatrixXf Um=FFMatBas(xi,CalcMetod);
    Map<VectorXf>Uv(Um.data(),ppp);
    Map<VectorXf>(Q,ppp)=Uv; 

but it seems a bit convoluted (Q is an existing array of length ppp). Can we do the last two lines in one step?

Community
  • 1
  • 1
user189035
  • 5,589
  • 13
  • 52
  • 112

2 Answers2

1
MatrixXf Um=FFMatBas(xi,CalcMetod);
Map<VectorXf>(Q,ppp)=Map<VectorXf>Uv(Um.data(),ppp); 
hmatar
  • 2,437
  • 2
  • 17
  • 27
1

Assuming that Q is big enough to contain the matrix, you can also write this as:

MatrixXf Um = FFMatBas(xi,CalcMetod);
Map<MatrixXf>(Q, Um.rows(), Um.cols()) = Um;
Jitse Niesen
  • 4,492
  • 26
  • 23