SkillAgentSearch skills...

LCPSolve

LCP solver based on Lemke's method.

Install / Use

/learn @Tom-Forsyth/LCPSolve

README

LCPSolve

An LCP solver based on Lemke's method.

Problem Statement.

Given a matrix $M$ and a vector $q$, solve the LCP below for $z$ and $w$.

$Mz + q = w$

$0 \leq z \perp w \geq 0$

Example Code

Eigen::Matrix<double, 2, 2> M {
    {1, -5},
    {2, 1}
};
Eigen::Vector<double, 2> q {-4, 3};
LCP sol = LCPSolve(M, q);

Output

sol.z = [4 0]
sol.w = [0 11]
sol.exitCond = 0

Exit Conditions

0 - Valid solution found.
1 - Secondary ray termination (approximate solution).
2 - Incorrect input dimensions.
3 - Exceeded maximum iterations.
4 - Numerical overflow/underflow.
View on GitHub
GitHub Stars13
CategoryDevelopment
Updated2mo ago
Forks0

Languages

C++

Security Score

95/100

Audited on Jan 28, 2026

No findings