[Top][All Lists]

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

Re: [Help-gsl] vector views

From: Jonathan Taylor
Subject: Re: [Help-gsl] vector views
Date: Mon, 7 May 2012 09:10:53 +0100

>> 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.  I am 
>> using this because I am looking for the solution of a nonlinear system, and, 
>> to the best of my knowledge, the multidimensional root finding algorithms 
>> only take functions with gsl_vector arguments.
>> 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.e.,  I want
>> gsl_vector * z // Size 2*N
>> gsl_vector * a // Size N, a= Re z
>> gsl_vector * b// Size N, b= Im z
> Vector views are 1D subsets of matrices -- e.g. if you wanted to refer to a 
> given column of a matrix by a different, more convenient name. I'm working 
> from memory here, but I'm not certain there are any functions to create a 
> vector view with a subvector. I would have guessed you wanted a z = 2*N 
> matrix, then create vector views from each of the two rows or columns to hold 
> the real and imaginary channels in vector(like) structures. If you want to 
> handle the vector view (vv) as an actual vector, which appears to be the 
> case, you have use &vv.vector.

You can actually create vector views of subvectors:
and as John says you can use &vv.vector in all the same places you would use a 
gsl_vector*. I would have thought his suggestion of a 2xN matrix might make 
more logical sense for your problem, though. If you do prefer a vector, you 
might want to give a little thought to whether an interleaved or separated 
arrangement in your vector will be more efficient and/or cause you less hassle 
in the long run (i.e. whether you store Re(z1), Im(z1), Re(z2), Im(z2) or 
alternatively Re(z1), Re(z2)..., Im(z1), Im(z2)...)

reply via email to

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