[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Copying C array to a GSL vector
From: |
Fritz Sonnichsen |
Subject: |
Re: Copying C array to a GSL vector |
Date: |
Fri, 11 Jun 2021 09:41:10 -0400 |
This does not seem to work: Here are the errors:
float specwav[1023];
gsl_vector_view v = gsl_vector_view_array(specwav, 1023);
>>> warning: passing argument 1 of ‘gsl_vector_view_array’ from
incompatible pointer type
If I look at the gsl_vector_view function it looks like it wants a
gsl_vector type, not a 'C' type array.
gsl_vector_view gsl_vector_subvector(gsl_vector *v, size_t offset,
size_t n);
using the pointer for my array does not work either:
gsl_vector_view v =
gsl_vector_view_array(*specwav, 1023);
>>> warning: passing argument 1 of ‘gsl_vector_view_array’ from
incompatible pointer type
Fritz
On Fri, Jun 11, 2021 at 12:06 AM Patrick Alken <alken@colorado.edu> wrote:
> First you need to make a "vector view" of your array, and then you can
> treat it as a vector. Example:
>
> gsl_vector_view v = gsl_vector_view_array(my_array, n);
>
> gsl_vector_memcpy(dest, &v.vector);
>
> On 6/10/21 11:48 PM, Fritz Sonnichsen wrote:
> > I am about to use some filtering routines and I am new to GSL. My C
> routine
> > creates a vector (1x1024) and I want to convert this to a gsl_vector
> type.
> > (In particular I want to use the /int gsl_vector_memcpy(gsl_vector *dest,
> > constgsl_vector *src) function.
> >
> > I see copying routines in your document for copying gsl_vector types
> > (for example int gsl_vector_memcpy(gsl_vector *dest, constgsl_vector
> > *src) )
> > but I do not see one to copy my C vector to the gsl type for further
> > processing. Is there such a routine?
> >
> > Thanks
> > Fritz
>
>