-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change template function definition to support Visual Studio #22
Comments
Hi @MonkeyDied, first of all, thanks for using |
@GiulioRomualdi The following are the definitions of the functions that cause the issue. osqp-eigen/include/OsqpEigen/Data.hpp Lines 93 to 94 in a74f46f
osqp-eigen/include/OsqpEigen/Data.hpp Lines 104 to 118 in a74f46f
osqp-eigen/include/OsqpEigen/Solver.hpp Lines 125 to 157 in a74f46f
|
Hi @MonkeyDied, I was referring to your code 😃 |
Hi @GiulioRomualdi , I encounter the problem when compiling the MPCExample using Visual Studio 2013 in Win10. The Eigen version is 3.3.5. osqp version is 0.5.0. The following codes produce a compile time fatal error C1001 as described in the first post. osqp-eigen/example/src/MPCExample.cpp Lines 261 to 264 in a74f46f
osqp-eigen/example/src/MPCExample.cpp Line 293 in a74f46f
|
Can you try to edit the lines in the following way? if(!solver.data()->setGradient<Eigen::Dynamic>(gradient)) return 1;
if(!solver.data()->setLinearConstraintsMatrix(linearMatrix)) return 1;
if(!solver.data()->setLowerBound<Eigen::Dynamic>(lowerBound)) return 1;
if(!solver.data()->setUpperBound<Eigen::Dynamic>(upperBound)) return 1; and if(!solver.updateBounds<Eigen::Dynamic>(lowerBound, upperBound)) return 1; |
Hi @GiulioRomualdi , that seems to solve the problem. |
Nice! I'll fix it! |
Hi @MonkeyDied this PR (#24 ) should solve your problem. Let me know if you have still problems. |
Fixed in #24 |
When compiling the mpc example using VS2013 on Win10, the following error occurred.
After some testing I found that it seems to be a problem with the template parsing for functions of the following form.
template<int n> ret_type some_function(Eigen::Matrix<c_float, n, 1>& arg)
This could be remedied by changing the definition to the following.
template<class T, int n> ret_type some_function(Eigen::Matrix<T, n, 1>& arg)
For example, in Data.hpp & Data.tpp, there is a function called setGradient. The current version and the suggested revised version are as follows.
/*current*/ template<int n> bool Data::setGradient(Eigen::Matrix<c_float, n, 1>& gradient)
/*suggest*/ template<class T, int n> bool Data::setGradient(Eigen::Matrix<T, n, 1>& gradient)
Below are all the functions I found to have the same problems.
For Data.hpp & Data.tpp
template<int n> bool Data::setGradient(Eigen::Matrix<c_float, n, 1>& gradientVector);
template<int m> bool setLowerBound(Eigen::Matrix<c_float, m, 1>& lowerBoundVector);
template<int m> bool setUpperBound(Eigen::Matrix<c_float, m, 1>& upperBoundVector);
For Solver.hpp & Solver.tpp
template<int n> bool updateGradient(Eigen::Matrix<c_float, n, 1>& gradient);
template<int m> bool updateLowerBound(Eigen::Matrix<c_float, m, 1>& lowerBound);
template<int m> bool updateUpperBound(Eigen::Matrix<c_float, m, 1>& upperBound);
template<int m> bool updateBounds(Eigen::Matrix<c_float, m, 1>& lowerBound, Eigen::Matrix<c_float, m, 1>& upperBound);
It would be nice if someone could help fix all the definitions.
Thx~
The text was updated successfully, but these errors were encountered: