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
Simple LDL^T solve interface #2915
base: develop
Are you sure you want to change the base?
Conversation
@jaeandersson what's your opinion? |
Yes, you're right. I think we should reserve template<typename Scalar>
Matrix<Scalar> Matrix<Scalar>::
solve(const Matrix<Scalar>& a, const Matrix<Scalar>& b,
const std::string& lsolver, const Dict& dict) {
casadi_error("'solve' with plugin not defined for " + type_name());
return Matrix<Scalar>();
} Just make a if-else to cover template<typename Scalar>
Matrix<Scalar> Matrix<Scalar>::
solve(const Matrix<Scalar>& a, const Matrix<Scalar>& b,
const std::string& lsolver, const Dict& dict) {
if (lsolver == "qr") {
...
} else if (lsolver == "ldl") {
...
} else {
casadi_error("'solve' with plugin not defined for " + type_name());
return Matrix<Scalar>();
}
} |
…ve in one all" This reverts commit db703ce.
Okay sorry for the delay. Is it correct to use Also, is |
What?
Simplify the interface to solving a linear system via LDL^T factorization (https://en.wikipedia.org/wiki/Cholesky_decomposition).
I overloaded the preexisting "ldl_solve" function to accept just "A" and "b" and return the solution to the linear system "Ax=b".
Why?
Allow user to write less when using the "ldl_solve" function. Currently, one must write code like this:
casadi::SX D, LT;
std::vector<casadi_int> p;
ldl(A, D, LT, p, false);
auto x = ldl_solve(b, D, LT, p);
The Eigen library has a more concise interface (https://eigen.tuxfamily.org/dox/group__TutorialLinearAlgebra.html):
auto x = A.ldlt().solve(b)
This pull request will allow a user to call "ldl_solve" like this:
auto x = ldl_solve(A, b);