This "Supercomputer Toolkit" looks pretty cool! I skimmed over the article, and 
will read it completely later on. Am I understanding that this uses integer 
arithmetic? It said that it supported quad-precision 128-bit integers (four 
32-bit integers concatenated).

One of the cool things about Forth is that it uses "mixed-precision" integer 
arithmetic. For example, this is the famous star-slash scalar:
*/    ( n1 n2 n3 -- (n1*n2)/n3 )

The clever thing here is that the intermediate value (n1*n2) is 
double-precision, although all of the inputs and the output are 
single-precision.
We also have some that mix single-precision and double-precision inputs and 
outputs. For example, here are a few:
m*    ( n1 n2 -- d ) This multiplies two single-precision and returns a 
double-precision, all signed.
um*    ( u1 u2 -- ud ) This multiplies two single-precision and returns a 
double-precision, all unsigned.
um/mod    ( ud u1 -- urem uquot ) This divides a double-precision by a 
single--precision, and returns the remainder and quotient as single-precision, 
all unsigned.
fm/mod    ( d n1 -- nrem nquot ) This divides a double--precision by a 
single-precision, and returns the remainder and quotient as single-precision, 
all signed, with a floored division.
sm/rem    ( d n1 -- nrem nquot ) This divides a double--precision by a 
single-precision, and returns the remainder and quotient as single-precision, 
all signed, with a symmetric division.
m*/    ( d n1 n2 -- (d*n1)/n2 )  This is like */ except that it multiplies a 
double-precision by a single precision to get a triple-precision intermediate 
value, then divides that by n2 (which has to be positive) to return a 
double-precision quotient, all signed.


I've heard of extension libraries being provided for Forth that allow for 
mixed-precision arithmetic of double-precision and quad-precision, although 
that is non-standard. Weirdly enough, ANS-Forth doesn't provide d/ ( d1 d2 -- 
dquot ). I complained about this to the Forth-200x committee but they wouldn't 
listen to me (it is rare that anybody ever does). I ended up providing this 
myself in my novice package, although this is written in Forth so as to be 
ANS-Forth compliant rather than in assembly-language for speed (this is one of 
the few parts of the novice package that I didn't write myself, as I got this 
code from somebody else). My own language that I'm inventing, which I call 
Straight Forth, will have separate stacks for single-precision and 
double-precision integers --- this will help to clean up the code a lot 
compared to ANS-Forth, in which single-precision and double-precision integers 
are mingled together on the same parameter stack --- I will
 also provide more numerical functions, including d/, that are missing from 
ANS-Forth.

I'm not saying that numerical programming is impossible in Scheme. I'm just 
saying that Forth has always been oriented toward numerical programming of 
integers, and within the last couple decades of floating-point too. I would use 
Forth for any numerical program, especially one that also involves a DSL. That 
is me though --- Dmitry seems to be pretty committed to Racket, so I'll wish 
him luck at that --- Forth is pretty off-topic for the Racket mailing list, so 
I won't discuss it any further. I will mention, though, that when I discussed 
Forth's mixed-precision integer arithmetic on the Factor mailing list, Slava 
Pestov responded by upgrading Factor to support some of Forth's capability in 
this regard (this is one of the few cases in which anybody has listened to me 
and changed their language at my request) --- this was back in 2009 when I was 
still programming in Factor --- I have since dropped Factor because my own 
education wasn't sufficient for
 understanding the concepts, and I switched to Scheme which has more 
educational documentation available (such as SICP).

regards --- Hugh



________________________________
 From: Joe Marshall <jmarsh...@alum.mit.edu>
To: Hugh Aguilar <hughaguila...@yahoo.com> 
Cc: "users@racket-lang.org" <users@racket-lang.org> 
Sent: Wednesday, November 14, 2012 5:48 PM
Subject: Re: [racket] 80-bit precision in Racket
 




On Tue, Nov 13, 2012 at 10:43 PM, Hugh Aguilar <hughaguila...@yahoo.com> wrote:

> We are doing numerical integration of celestial bodies over large periods of 
>time (100 years is a norm).
>
>
>I'm new to Scheme, so I may be totally wrong about this --- but, isn't a 
>numerical program like this exactly what Scheme is *not* designed for?

The Supercomputer Toolkit 
( http://www.hpl.hp.com/techreports/94/HPL-94-30.html ) was
designed for doing numerical integration of celestial bodies over large periods 
of time.  

"The Toolkit's compiler uses a novel strategy based upon partial evaluation [7, 
9]. This exploits the data-independence of typical numerical
algorithms to generate exceptionally efficient object code from source programs 
that are expressed in terms of highly abstract components written in
the Scheme dialect of Lisp [14]."

"The integrator and the force law were written as high level Scheme programs. 
The accumulation of position was implemented in
quad precision (128 bits), and the required quad precision operators were
written in Scheme."

"In hindsight, the use of quad precision appears to have been overly 
conservative for this
problem"
-- 
~jrm
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to