Transform dolfin::Matrix into Eigen::Matrix

2019-06-02 04:23发布

问题:

I am coding in C++ and use Fenics for finite element discretization. Now I would like to transform a dolfin::Matrix into a Eigen::Matrix. How can I do that?

I have done something similar for vectors: I have given c_vec which has the type:

std::shared_ptr<dolfin::Vector>

Then I have used

std::vector<double> c_vec_new;
c_vec->gather_on_zero(c_vec_new);

(I am computing parallel). And then I could create a Eigen::Vector by

Eigen::Map<Eigen::VectorXd> c_vec_eigen(c_vec_new.data(),c_vec_new.size());

Is there an easier way? How do I transform a dolfin::Matrix into an Eigen::Matrix?

I would be very grateful for help! Moerni

标签: c++ eigen