Pointer vs Reference difference when passing Eigen objects as arguments
问题 If a have a function that takes a Eigen matrix as an argument, what would be the difference between: void foo(Eigen::MatrixXd& container){ for(i=0;i<container.rows();i++){ for(j=0;j<container.cols();j++){ container(i,j)=47; } } } and void foo(Eigen::MatrixXd* container){ for(i=0;i<container->rows();i++){ for(j=0;j<container->cols();j++){ container->coeffRef(i,j)=47; } } } In Eigen documentation, they only present the first method - does that mean that there are any advantages to that approach