[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Octave-like indexing with the GSL
From: |
James Bergstra |
Subject: |
Re: [Help-gsl] Octave-like indexing with the GSL |
Date: |
Sat, 11 Nov 2006 23:09:09 -0500 |
User-agent: |
Mutt/1.4.2.1i |
On Sat, Nov 11, 2006 at 06:01:25PM -0500, Jordi Gutierrez Hermoso wrote:
> Hello everyone.
>
> I'm writing some simple C++ wrappers for the GSL for personal use, and
> I've already hit a bit of a stump at an early stage. I want to able to
> index my wrapper class with Octave-like syntax. E.g. if A is a 4x4
> matrix, then A(2,2,4, 2,2,4) (corresponding to Octave syntax A(2:2:4,
> 2:2:4) ) should give me the elements with indices
>
> (2,2) (2,4)
> (4,2) (4,4),
>
> as both an rvalue or lvalue depending on context, but I don't
> understand how to do this efficiently and cleanly (i.e. "vectorised"
> or valarray-like) in GSL with its gsl_matrix structure. I was
> expecting to find just such a method as a matrix view with a clever
> little hack with the matrix's tda, but I cannot figure out how to do
> this. Should I just use a number of for-loops with row or column
A good point. The gsl_vector type is for a variable number of regularly-spaced
array elements, and the gsl_matrix type is for a variable number of
fixed-length, regularly-spaced arrays. The data layout you are describing is
more complicated than a single gsl_vector or gsl_matrix, so no tda trick will
save the day :(
James
--
http://www-etud.iro.umontreal.ca/~bergstrj