Open michalkielan opened 7 years ago
@michal915 have a look at #39
Sorry about goto: :( But I am not sure about changing rows. Are you sure, that after changing rows output L, U would fit equation A = L * U ?
Only in this particular example, otherwise, no idea :) i think more general solution would be needed, don't care about goto at the moment
BTW, @michal915 have a look at page 8
@michal915 In my opinion, when det(A)
eqals zero or if submatrices' det equals zero we cannot perform LU decomposition. Have a look at my comment above.
7332dd7 shouldn't be merged, because changing rows makes input matrix different that output matrix. It's like: "Well, I cannot sell you a car, but here is a bike, it is O.K. for you?" And for some people it would be fine, but in general when someone wants a car, he won't buy a bike.
http://stackoverflow.com/a/38156436
If B is a matrix obtained by swapping two rows of A, then
det(B) = -det(A)
If you swap rows, flip the sign.
@michal915 So I did it in fcf4df0 but it failed. Do you know why?
EDIT: That's right approach. Here is your favourite 'octave test': click
@michal915 I've noticed that LU procedure failed even when input matrix can be decomposed using basing algorithm (without changing rows). 62c9a79
Current behaviour: the LU decomposition provided that all its leading submatrices have non-zero determinant, if any is equal to zero, exception is throwing as expected:
Output:
In this particular example we can change the second and third row of matrix A, to make them lu decomposition friendly.
Please have a look at the full implementation of this example: https://github.com/michal915/MatrixLibs/blob/lu_every_matrix_tests/tst/lu/lu.cpp#L90
Expected behaviour: make LU decomposition works for every kind matrices