robotology / osqp-eigen

Simple Eigen-C++ wrapper for OSQP library
https://robotology.github.io/osqp-eigen/
BSD 3-Clause "New" or "Revised" License
381 stars 112 forks source link

Resolved Compilation error when using float #123

Closed voldien closed 2 years ago

voldien commented 2 years ago

Resolves compilation error when c_float is set to float.

GiulioRomualdi commented 2 years ago

Hi @voldien thank you for your contribution! We really appreciate it. I will try review the PR before the end of this week

wxmerkt commented 2 years ago

This change will break compilation with double. Templating might be a solution, however I believe that casting in user-applications is the correct approach. @voldien, can you try ....getSolution().cast<c_float>() in your application without changing the osqp-eigen? Would this resolve your issues?

voldien commented 2 years ago

The compilation error is caused by changing the c_float inside osqp to float instead of double. Since i trying to increase performance for my application.

So the compilation error is not on my not on my side, since then I would just cast it as you mention. rather the compilation error is inside both OsqpEigen::Solver::getDualSolution() and OsqpEigen::Solver::getSolution(). Since it tries to pass a float pointer to VectorXd.

I thought the reason for it being a double for these two methods was just a miss, since the rest of variables and methods in the class are using the c_float.

wxmerkt commented 2 years ago

Right, I missed this - you're correct

GiulioRomualdi commented 2 years ago

Thank you very much @voldien! Merging!