I use Eigen for most of my code but I would like to use Miser or Vegas monte-carlo integration from GSL. I need to convert Eigen’s vectors to c arrays of doubles
what would be the best way to do it?
Matrix<double,3,1> --> c_array []
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have worked with Eigen before…
Usually, for simple access to the internal array data, like mentioned by user janneb in this thread, you just want to invoke data():
If you wish to iterate the individual values to perform some operation, you want to iterate every line (.row(index)) and column (.col(index)), depending on the matrix order that you want to lay down in the destination vector.
In your specific example, you need only iterate the rows:
You would want to call .col(0). Should similar needs arise, the specific documentation is always helpful!
So you would end up with something like (assuming you wish to use a three-line single-column matrix):
Hope that helped.