giaf / blasfeo

Basic linear algebra subroutines for embedded optimization
Other
322 stars 88 forks source link

Problem with blasfeo_drowpe? #143

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello,

If I understood the functioning of the function blasfeo_drowpe right, I think there is an algoritmic error in the code.

Example lets say we want to use the permutation vector (1,2,0). The algorithm would proceed as follows: 1) swap row 0<->1 2) swap row 1<->2 3) swap row 2<->0

if we would apply this to the matrix 0 1 2

we would end up with -> 1 0 2 -> 1 2 0 -> 0 2 1 instead of 1 2 0

Kind regards, Lander

giaf commented 3 years ago

Hi Lander,

thank you for your bug report. Could you specify some more information about your build (e.g. TARGET, LA, MF), such that I can identify the issue?

I just tried out with Haswell target, high-performance LA and panel major matrix format, and the output of the permutation you propose is correctly 0 2 1. Notice that kmax should be set to 3 in this case (i.e. 3 permutations are applied), if you set it to 2 you would get the output of the first two permutations, i.e. 1 2 0.

ghost commented 3 years ago

Hello Gianluca,

Thank you for the feedback. To avoid confusion: the output I obtain is 0 2 1 as well, so the same as you. I however expect to get 1 2 0 as the correct result. If 0 2 1 is the expected output, could you clarify what the function is exactly supposed to do?

Thank you, Lander

giaf commented 3 years ago

Hi Lander,

the routine uses the encoding of a permutation vector ipiv that is found e.g. in the standard LAPACK routine dgetrf for LU factorization (with the only difference that in LAPACK the indexes start from 1, while in BLASFEO I preferred to use the C standard array indexing of starting from 0, so it is exactly the standard LAPACK encoding minus one).

ipiv = [1, 2, 0] means (if applied to a vector):

ghost commented 3 years ago

Dear Gianluca,

Thanks a lot for the explanation. I misunderstood the purpose of the function.

Kind regards, Lander