My program is trying to solve a system of linear equations. To do this, he collects the matrix coeff_matrix and vector value_vector and uses Eigen to solve them, for example:
Eigen::VectorXd sol_vector = coeff_matrix .colPivHouseholderQr().solve(value_vector);
The problem is that the system can be either overdetermined or underestimated. In the first case, Eigen either gives the right or the wrong solution, and I check the solution with coeff_matrix * sol_vector - value_vector .
However, consider the following system of equations:
a + b - c = 0 c - d = 0 c = 11 - c + d = 0
In this particular case, Eigen correctly solves the last three equations and also gives solutions for a and b .
What I would like to achieve is that only equations that have only one solution will be solved, and the rest (the first equation here) will be stored in the system.
In other words, I am looking for a method to find out which equations can be solved in a given system of equations at that time, and which cannot, because there will be more than one solution.
Could you suggest a good way to achieve this?
Edit: note that in most cases the matrix will not be square. I added another line here to note that redefinition can also occur.
source share