bug-gsl
[Top][All Lists]
Advanced

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

[Bug-gsl]bug in permutation/canonical.c ? (corrected mail)


From: Mario Pernici
Subject: [Bug-gsl]bug in permutation/canonical.c ? (corrected mail)
Date: Tue, 11 Feb 2003 13:20:22 +0100 (CET)

gsl version: 1.3
Red Hat 7.3
gcc version 2.96

Dear Sirs,
I find that
int gsl_permutation_canonical_to_linear (gsl_permutation * p,
                                     const gsl_permutation * q)
stores the linear permutation in q, not in p.
Please see the attached examples es1a.c and es1.c .

In es1a.c, after obtaining a linear permutation p with
gsl_ran_shuffle (r, p->data, N, sizeof(size_t));
->p:  1 0 2
  I converted it to canonical form with
gsl_permutation_linear_to_canonical(q1,p);
->q1:  2 0 1
 then I tried to convert q1 back to linear
 gsl_permutation_canonical_to_linear(q2,q1);
the linear permutation should be stored in q2, while
q1 should be unchanged, as the prototype

int
gsl_permutation_canonical_to_linear (gsl_permutation * p,
                                     const gsl_permutation * q)
indicates (and it is reported in gsl documentation)
however I get
->q1:  0 1 2
->q2:  0 0 0
none of which is correct.

In es1.c I tried to convert q1 back to linear exchanging the
two arguments q1 and q2:
gsl_permutation_canonical_to_linear(q1,q2);
->q1: 2 0 1
->q2: 1 0 2
which is correct.
I checked that gsl_permutation_canonical_to_linear
behaves consistently in this way for all the  permutations of 10 elements
(using Ruby bindings).

Best Regards
 Mario Pernici


Attachment: es1.c
Description: Text document

Attachment: es1a.c
Description: Text document


reply via email to

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