[Top][All Lists]

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

Re: [Help-gsl] Questions about using gsl permutation

From: John D Lamb
Subject: Re: [Help-gsl] Questions about using gsl permutation
Date: Sun, 16 Feb 2014 08:38:41 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 15/02/14 22:38, Yi-Ping Huang wrote:
I am trying to use gsl permutation. And I have a hard time to pass the
information to the functions in permutation.

The manual could make it clearer that most functions, like gsl_permutation_swap(), gsl_permutation_next(), and gsl_permute(), work with the permutation in linear form. The canonical form is less usual. I mainly us it if I want t print the permutation in canonical form.

For example, I would like to evaluate the number of cycles of a specific
permutation [1023456789].
If I store this integer series in the array a. How should I transform the
information into gsl_permutation_linear_cycles?

int i, cycles;
gsl_permutation *p;

p = gsl_permutation_alloc( 10 );

for( i = 0; i < gsl_permutation_size( p ); ++i )
  gsl_permutation_data( p )[i] = a[i];

cycles = gsl_permutation_linear_cycles( p );

ought to do it. I would write a small test program and see that it gives the result I expect before using this.

John D Lamb

reply via email to

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