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" );
        AlterVector(v1);
        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) );  */

}


_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to