|Description||This function solves the system MA * X = B of simultaneous linear equations, using LU decomposition. It works well in all cases where there is one unique solution. If successful, it returns FALSE (0).
If, on the other hand, the system is ill-determined, which happens in all cases where one or more of the equations are linear combinations of other equations of the same system, the resulting matrix becomes singular and the function fails with an error message.
To avoid outright failure in an application where ill-determined matrices might occur, you can define a minimum pivot for the decomposition. If you wish to do so for all calls to MF_LUdecompose and to the functions based upon it, namely MF_inv and MF_solve, you can do so by calling MF_LUDsetEdit. However, as this method is not thread-safe, you cannot use it in order to set different thresholds for different calls to the functions mentioned. Instead of defining a default editing threshold then, use their "wEdit" variants, i.e. MF_LUdecomposewEdit, MF_invwEdit or MF_solvewEdit. They take the desired threshold as the additional argument thresh. Note that thresh is always real, also in the complex versions.
The return value of MF_solve and MF_solvewEdit indicates if the linear system could successfully be solved:
|0||Matrix MA is regular; linear system successfully solved|
|1||Under-determined system; matrix MA is singular; result X contains no useful information|
|2||Under-determined system; matrix MA is (nearly) singular; solution was achieved only by pivot editing. It depends on the specific application, iff the result is useful.|
To check if MF_solve was successful, in single-thread programs, you may also call MF_LUDresult, whose return value will be FALSE (0), if the system could be solved without problems (and without pivot editing), and TRUE (1) for singular MA. In multi-thread programs, on the other hand, it would not be clear wich instance of MF_solve the call to MF_LUDresult would refer to. So, here, inspection of the return value of MF_solve is the only option.
As an often preferrable alternative to pivot editing, you might switch to MF_safeSolve or MF_solveBySVD.