2015年5月25日 星期一

Convert Eigen Matrix to C-style array

We can convert C-style array to Eigen Matrix :

double C_arr[N*N]
MatrixXd EigenMatrix
EigenMatrix=Map<MatrixXd>(C_arr,N,N)

And there is the same way to covert Eigen Matrix to C-style:

Map<MatrixXd>(C_arr,N,N)=EigenMatrix