[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] vector views
From: |
Rhys Ulerich |
Subject: |
Re: [Help-gsl] vector views |
Date: |
Mon, 7 May 2012 08:48:44 -0500 |
> Just wondering if someone can help me out with using vector views.
> I have a set of N complex numbers which I am storing in a 2*N size gsl_vector.
> ...
> So here's my question, does anyone have any tips on how to set up vector
> views so that I have pointers available that logically map to the real and
> imaginary
> portions of the vector?
I'd create a complex-valued vector of length N using
gsl_vector_complex_alloc (say "z"), then use gsl_vector_view to create
a real-valued view of length 2N from the data (say "zd"), then use
gsl_vector_subvector_with_stride to create strided views for the real
and imaginary parts. As you'd expect the real-valued offset will be
zero with stride two and the imaginary-valued offset is one with
stride two. The views are documented well at
http://www.gnu.org/software/gsl/manual/html_node/Vector-views.html.
The complex-valued vector details are analogous and are declared
within <gsl/gsl_vector_complex_double.h> in a readable fashion.
You could, of course, skip my suggestion to start with a
complex-valued vector and simply start with the 2*N gsl_vector. I'm
guessing having a complex-valued vector will be handy for other
reasons in your code.
Hope that helps,
Rhys