[Top][All Lists]

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

Re: Copying C array to a GSL vector

From: Marek Nečada
Subject: Re: Copying C array to a GSL vector
Date: Fri, 11 Jun 2021 16:48:15 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0

Hi Fritz,

you are mixing float and double types. gsl_vector (and gsl_vector_view) takes doubles. You need to use the types and "constructors" with the "_float" suffix if you really want to use single-precision floats. You should be able to find the correct names in gsl/gsl_vector_float.h.

Best regards,

Fritz Sonnichsen kirjoitti 11.6.2021 klo 16.41:
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


On Fri, Jun 11, 2021 at 12:06 AM Patrick Alken <> 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
creates a vector (1x1024) and I want to convert this to a gsl_vector
(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?


reply via email to

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