guile-user
[Top][All Lists]
Advanced

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

Re: vector typing


From: Dave Griffiths
Subject: Re: vector typing
Date: Fri, 5 May 2006 10:28:56 +0100 (BST)
User-agent: SquirrelMail/1.4.6

> Hi Dave,
>
> On Thu, 2006-05-04 at 17:57 +0100, Dave Griffiths wrote:
>> I admit I am confused about the typing of vectors - is there a quick way
>> to create generalised vectors other than using scm_make_vector and
>> adding
>> each element individually with scm_vector_set_x?
>
> According to the docs, uniform numeric vectors are generalized vectors,
> and can be accessed via the americanly-spelled generalized-vector-ref
> function. See:
> http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Generalized-Vectors.html#Generalized-Vectors
>> Speed is an issue, as this is a graphics application
>> (http://www.pawfal.org/fluxus) and I'm doing a lot of things with
>> vectors.
>> Are f32 better for speed reasons anyway?
>
> 1) uniform numeric vectors use less memory (32 bits versus a pointer to
> a double-cell (2*sizeof(void*)) on the heap)
>
> 2) therefore, from C you don't need to be dereferencing pointers and
> checking types in inner loops
>
> 3) also, you can get the contiguous array of f32 values, which you can't
> do with a normal vector
>
> So yes, for speed a uniform vector is a big win. If you can refactor
> algorithms to deal in uniform vectors, with the actual operations
> implemented in C, you can approach the speed of a C-only solution I
> think.

Thanks Andy, I suppose my main confusion is why you can't use the normal
vector-ref commands with uniform vectors any more.

But yup - I've been using guile for the sort of things you should really
use a gpu for these days (texture coordinate manipulation for reflection
mapping, toon shading etc) in realtime - and it copes surprisingly well.
http://www.pawfal.org/nebogeo/images/fluxref2.png

cheers,

dave





reply via email to

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