Skip to content
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

Resolved Compilation error when using float #123

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/OsqpEigen/Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace OsqpEigen
std::unique_ptr<OsqpEigen::Data> m_data; /**< Pointer to Data class. */
Eigen::Matrix<c_float, Eigen::Dynamic ,1> m_primalVariables;
Eigen::Matrix<c_float, Eigen::Dynamic ,1> m_dualVariables;
Eigen::VectorXd m_solution;
Eigen::VectorXd m_dualSolution;
Eigen::Matrix<c_float, -1, 1> m_solution;
Eigen::Matrix<c_float, -1, 1> m_dualSolution;

std::vector<c_int> m_hessianNewIndices;
std::vector<c_float> m_hessianNewValues;
Expand Down Expand Up @@ -135,13 +135,13 @@ namespace OsqpEigen
* Get the optimization problem solution.
* @return an Eigen::Vector contating the optimization result.
*/
const Eigen::VectorXd &getSolution();
const Eigen::Matrix<c_float, -1, 1> &getSolution();

/**
* Get the dual optimization problem solution.
* @return an Eigen::Vector contating the optimization result.
*/
const Eigen::VectorXd &getDualSolution();
const Eigen::Matrix<c_float, -1, 1> &getDualSolution();

/**
* Update the linear part of the cost function (Gradient).
Expand Down
8 changes: 4 additions & 4 deletions src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@ OsqpEigen::ErrorExitFlag OsqpEigen::Solver::solveProblem()
return static_cast<OsqpEigen::ErrorExitFlag>(osqp_solve(m_workspace.get()));
}

const Eigen::VectorXd &OsqpEigen::Solver::getSolution()
const Eigen::Matrix<c_float, -1, 1> &OsqpEigen::Solver::getSolution()
{
// copy data from an array to Eigen vector
c_float* solution = m_workspace->solution->x;
m_solution = Eigen::Map<Eigen::VectorXd>(solution, m_workspace->data->n, 1);
m_solution = Eigen::Map<Eigen::Matrix<c_float, -1, 1>>(solution, m_workspace->data->n, 1);

return m_solution;
}

const Eigen::VectorXd &OsqpEigen::Solver::getDualSolution()
const Eigen::Matrix<c_float, -1, 1> &OsqpEigen::Solver::getDualSolution()
{
// copy data from an array to Eigen vector
c_float* solution = m_workspace->solution->y;
m_dualSolution = Eigen::Map<Eigen::VectorXd>(solution, m_workspace->data->m, 1);
m_dualSolution = Eigen::Map< Eigen::Matrix<c_float, -1, 1>>(solution, m_workspace->data->m, 1);

return m_dualSolution;
}
Expand Down