help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] permutation matrix with lu decomposition problem


From: Elias Posoukidis
Subject: [Help-gsl] permutation matrix with lu decomposition problem
Date: Sat, 1 Jun 2019 08:39:45 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

Hi everyone,

i have the following problem with the permutation matrix after a lu -decomposition. The following code

//----------------------------------------------

       double a_data[] = { 25, 5, 1, 64, 8, 1, 144, 12, 1 };

        gsl_matrix_view m = gsl_matrix_view_array(a_data, 3, 3);

        int s;

        gsl_permutation *p = gsl_permutation_alloc(3);

        gsl_linalg_LU_decomp(&m.matrix, p, &s);

        for (size_t i = 0; i < 3; i++) {
            for (size_t j = 0; j < 3; j++) {
                printf("%3.2f,", gsl_matrix_get(&m.matrix, i, j));
            }
            printf("\n");
        }

        gsl_permutation_fprintf(stdout, p, " %u");
        printf("\n");
        gsl_permutation_free(p);

//----------------------------------------------

gives for the lu-matrix

144.00,12.00,1.00,
0.17,2.92,0.83,
0.44,0.91,-0.20,

which is the correct result, but for the permutation vector the following  {2 0 1}, which means that

the permutation matrix is

0,1,0

0,0,1

1,0,0

but the correct permutation matrix should be

0,0,1

1,0,0

0,1,0

What am i doing wrong?

kind regards,

eliasp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]