guile-user
[Top][All Lists]
Advanced

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

Re: SRFI-4 in Guile 1.7


From: Marius Vollmer
Subject: Re: SRFI-4 in Guile 1.7
Date: Wed, 23 Mar 2005 12:21:52 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

address@hidden (Ludovic Courtès) writes:

> Can one expect the increment returned by `scm_TAGvector_elements ()' to
> always be 1 when TAG is `u8', 2 when TAG is `u16', and so on?

No, you can't.  The increment gives the number of _elements_ between
the real elements of the vector in memory, not the number of _bytes_.
Very nearly all vectors will have an increment of 1, but not all.  See
"Shared Arrays" in the manual: shared arrays of rank one are vectors,
but they don't need to be stored contiguously in memory.

For example, the diagonal of a 3x3 matrix is a vector, and to go from
one element of this vector to the next, you need to skip 4 elements in
memory (one full row of the matrix plus one more).  Such a vector has
an increment of 4.

The size of an element in a uniform numeric vector can be retrieved
with scm_array_handle_uniform_element_size, if you need it.

> I have this impression, although I couldn't find proofs in the
> source code.

Maybe we could improve the manual.  Do you have a suggestion?

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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