This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for a permutation function


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]