This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Patch for a permutation function
- From: Nicolas Darnis <ndarnis at cvf dot fr>
- To: "gsl-discuss at sources dot redhat dot com" <gsl-discuss at sources dot redhat dot com>
- Date: Wed, 26 Jun 2002 11:31:22 +0200
- Subject: Patch for a permutation function
- Organization: CVF R&D
Hi,
the gsl_permutation_canonical_cycles (const gsl_permutation * p)
function
is erroenous, this is the correct one:
size_t
gsl_permutation_canonical_cycles (const gsl_permutation * p)
{
size_t i;
size_t count = 1;
size_t min = p->data[0];
for (i = 0; i < p->size; i++)
{
if (p->data[i] >= min)
{
min = p->data[i];
count++;
}
}
return count;
}
The if (p->data[i] < min) was the error.
Enjoy,
--
Nicolas Darnis
mailto:ndarnis@cvf.fr
work phone: (+33) 05 56 01 98 34
GPG 0x6B794D9E: 051F 3035 0183 A6DD 2701 A773 EE05 821E 6B79 4D9E