This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: gsl_vector_alloc_from_vector
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: Sebastian Tannert <tannert at physik dot hu-berlin dot de>
- Cc: gsl-discuss at sources dot redhat dot com
- Date: Tue, 10 Feb 2004 11:48:35 +0000
- Subject: Re: gsl_vector_alloc_from_vector
- References: <16423.51069.274096.66384@debian.local><Pine.LNX.3.96.1040209194316.2194B-100000@pbp15.physik.hu-berlin.de>
Sebastian Tannert writes:
> Hm, but as far as I've seen the vector view concept
> just covers the same stuff inside a new struct.
> Is there any advantage beside having two distinct data types?
>
> In a first look it only seems to make using vector views
> more complicated and to take more time for another
> step in accessing the data from memory.
The advantage of views is that they make clear which objects own the
underlying memory of the vector data and are responsible for
deallocating it. Vectors always have ownership of the data, views
never do.
In the previous method, where there was only the vector type, it was
not possible to distinguish between the two cases so easily (that was
a long time ago though).
I don't think views any significant performance disadvantage. Since
they are allocated on the stack they can be more efficient than some
of the old vector-style usage of malloc that was originally needed.
--
Brian Gough