guile-user
[Top][All Lists]
Advanced

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

Re: Floating Point?


From: Betoes
Subject: Re: Floating Point?
Date: Mon, 8 Sep 2003 11:43:59 -0300
User-agent: Mutt/1.3.28i

On Sat, Sep 06, 2003 at 01:10:21PM -0500, Peter S. Christopher wrote:
> Hi there listers,
> 
>       I've been thinking about how to make my floating point
> calculations go faster. I thought that my FP calculations where so slow

I have doubt about the speed of floating point calculations too, but
because of arbitrary precision of guile floating point
arthmetics... Does it have a way to turn off this feature? Does it
really have influence on speedy calculations?

Redefinitions of math functions would be woth, but an expensive way to
increase such speed...

Any idea?

> because of excessive allocation. i.e. if a and b are floats then 
> (+ a b) will return a *NEW* float with the value a+b in it. Is this
> true? If this where true I thought that I could speed up my calculations
> by replacing the normal operands (+,-,*,/) by versions that don't allocate
> new cells (a-la (reg+, reg-, reg*, reg/)). Something like
> 
> (reg+ temp_1 a b) 
> 
> would evaluate to 
> 
> SCM_REAL_VALUE(temp_1) =      
>     scm_num2dbl(a, FUNC_NAME)+scm_num2dbl(b, FUNC_NAME);
> 
> in some C extension function. This would prevent the allocation of the
> additional doubles. The real advantage, of course, would be in expressions
> like
> 
> (let ((register-1 0.0))
>    (do ((i 0 (+ i 1))
>        ((> i big-huge-number))
>      (set-my-double-array i
>        (reg+ register-1 5.7 (reg* register-1 3.1 i))))))
> 
> where this loop sets element i of my-double-array to 3.1*i+5.7. By my
> reasoning (which may be suspect) this would save me many-many cell
> allocations (2*big-huge-number to be exact).
> 
>       So how far off base am I? And, does anyone have other ideas on how
> to improve my floating point performance (within the guile world that is).
> 
> Thanks for any help,
> Pete Christopher




reply via email to

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