[Top][All Lists]

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

[Help-gsl] extern vector

From: George Kyriakou
Subject: [Help-gsl] extern vector
Date: Thu, 17 Mar 2005 16:59:59 +0200

Hello all,

it may be a simple question:

1. In the code below (that compiles cleanly) I pass two variables by
value in a function that takes pointers as arguments, and I still get
the desired results. Is this normal?
2. How could I access vector v2 within AlterVector ? The commented
line produces "Undefined symbols: _v2".

Any help on understanding what is going on would be valuable. Thanks.

-- G.

--- file main.c:

#include <stdio.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_math.h>
int main (int argc, const char * argv[])
        int j; int n=5;
        gsl_vector *v1 = gsl_vector_alloc(n);
        gsl_vector *v2 = gsl_vector_alloc(n);
        for (j=0; j<=n-1; j++) {
                gsl_vector_set(v1, j, 1+pow(j,3) );
                gsl_vector_set(v2, j, 2*pow(j,3) );
        printf("Original Vector: \n--------\n");
        gsl_vector_fprintf(stdout, v1, "%2.2f" );
        printf("Altered Vector: \n--------\n");
        gsl_vector_fprintf(stdout, v1, "%2.2f" );
        return 0;

--- file sec.c:

#include <gsl/gsl_vector.h>
extern gsl_vector *v2;
void AlterVector(gsl_vector *v1)
        int j;
        for (j=0; j<=v1->size-1; j++)
                gsl_vector_set(v1, j, 1+j);
/*              gsl_vector_set(v2, j, 2*gsl_vector_get(v1,j) );  */


reply via email to

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