eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'DoubleArray':

Home

everywhere
www.exept.de
for:
[back]

Class: DoubleArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--DoubleArray

Package:
stx:libbasic
Category:
Collections-Arrayed
Version:
rev: 1.19 date: 2003/04/22 09:39:34
user: cg
file: DoubleArray.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


DoubleArrays store doubleFloats values (and nothing else).
They have been added to support heavy duty number crunching somewhat
better than other smalltalks do. 
Storing Floats & Doubles in these objects (instead of Arrays)
has some benefits:

1) since the values are stored directly (instead of pointers to them)
   both access overhead and garbage collect overhead is minimized.

2) they can be much faster passed to c functions (such as graphics 
   libraries or heavy duty math packages), since the double values
   come packed and can be used in C by using a (double *) or double[].
   There is no need to loop over the array extracting doubles.      

3) they could (in theory) be much more easily be processed by things like
   vector and array processors

Be aware however, that Float- and DoubleArrays are not supported in other
smalltalks - your program will thus become somewhat less portable.
(since their protocol is the same as normal arrays filled with floats,
 they can of course be easily simulated - a bit slower though)

However, they could be simulated by a ByteArray, using doubleAt: and 
doubleAtPut: messages to access the elements, but that seems a bit
clumsy and unelegant. Also, the stc-compiler may learn how to deal
with Float- and DoubleArrays, making accesses very fast in the future.
Hint: if you use doubleArrays in your application and must port it
to some other smalltalk, define a DoubleArray class there, which is derived
from ByteArray, and add access methods.

Of course, DoubleArray can be subclassed,
and named instance variables can be added there.

See example uses in the GLX interface and GLDemos.

[memory requirements:]
    OBJ-HEADER + (size * double-size)


Related information:

    FloatArray
    Array

Instance protocol:

queries
o  defaultElement



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 08:56:42 GMT