help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] permute vector


From: oliver . gruenewald
Subject: [Help-gsl] permute vector
Date: Mon, 10 Mar 2008 19:19:44 +0100
User-agent: freenetMail

Hi!
I am new to GSL and trying to permute a vector using the function 
gsl_permute_vector. But I get gsl_permute_vector is not defined for this scope. 

Could you please help me? I think it is rather easy but I am stuck.

Plus, why is the return value of the function int? (There are other functions 
in the library with return int but if  used in the code examples they are used 
like return void.
My code is below.  Thanks for any suggestions! 

// permute_vector.cc

#include <stdio.h>
#include <gsl/gsl_permutation.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include<gsl/gsl_rng.h>
#include<gsl/gsl_randist.h>
#include <iostream>
    using namespace std;

int main (void)
{
    gsl_permutation * p = gsl_permutation_alloc (3);
  gsl_permutation_init (p);
    
    int i;
    gsl_vector * v = gsl_vector_alloc (3);
    for (i = 0; i < 3; i++)
    {
        gsl_vector_set (v, i, 1.23 + i);
    }
    
    
    for (i = 0; i < 3; i++) 
    {
        printf ("v_%d = %g\n", i, gsl_vector_get (v, i));
    }
    
    cout << "Permute vector: " << endl;
    gsl_permute_vector(p,v);
    
    for (i = 0; i < 3; i++) 
    {
        printf ("v_%d = %g\n", i, gsl_vector_get (v, i));
    }

    gsl_vector_free (v);
    return 0;
}

BTW, is there a web page with more examples using the GSL? Web search didn't 
find much...

Kind regards
  Oliver

Unbegrenzter Speicher, Top-Spamschutz, 120 SMS und eigene E-MailDomain inkl.
http://office.freenet.de/dienste/emailoffice/produktuebersicht/power/mail/index.html



reply via email to

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