Gauss Elimination for NxM matrix

后端 未结 3 476
半阙折子戏
半阙折子戏 2021-02-02 04:29
/* Program to demonstrate gaussian elimination
   on a set of linear simultaneous equations
 */

#include 

        
3条回答
  •  迷失自我
    2021-02-02 05:18

    You just cannot apply Gaussian elimination directly to an NxM problem. If you have more equations than unknowns, the your problem is over-determined and you have no solution, which means you need to use something like the least squares method. Say that you have A*x = b, then instead of having x = inv(A)*b (when N=M), then you have to do x = inv(A^T*A)*A^T*b.

    In the case where you have less equations then unknowns, then your problem is underdetermined and you have an infinity of solutions. In that case, you either pick one at random (e.g. setting some of the unknowns to an arbitrary value), or you need to use regularization, which means trying adding some extra constraints.

提交回复
热议问题