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

[QP Solver] In-place LDLT decomposition of KKT matrix #15

Open
msplr opened this issue Jul 7, 2019 · 2 comments
Open

[QP Solver] In-place LDLT decomposition of KKT matrix #15

msplr opened this issue Jul 7, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@msplr
Copy link

msplr commented Jul 7, 2019

The most significant memory cost of the dense QP solver come form storing the KKT matrix and its decomposition.
Eigen allows for in-place LDLT decomposition that reuses the coefficient matrix and to save memory.
The in-place decomposition requires a reference to the coefficient matrix at construction, which is not available at that point.
However, construction can be delayed using a placement new, which is illustrated below.

using linear_solver_t = Eigen::LDLT<Eigen::Ref<kkt_mat_t>>;
char linear_solver_buf[sizeof(linear_solver_t)]; // enforce some alignment somehow?
linear_solver_t* linear_solver;
//...
p = (void*) linear_solver_buf;
linear_solver = new(p) linear_solver_t(kkt_mat);

Note: Another option would be to construct the linear solver as a local object on the stack.

@msplr msplr added the enhancement New feature or request label Jul 7, 2019
@petlist
Copy link
Collaborator

petlist commented Jul 8, 2019

std::shared_pointer<linear_solver_t> linear_solver; linear_solver = make_shared<linear_solver_t>(kit_mat)

?

@petlist
Copy link
Collaborator

petlist commented Jul 8, 2019

I need to learn how to properly insert the code. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants