1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ArrayedCollection variableDoubleSubclass:#DoubleArray
|
1263
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Collections-Arrayed'
|
1
|
18 |
!
|
|
19 |
|
88
|
20 |
!DoubleArray class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
1
|
25 |
All Rights Reserved
|
|
26 |
|
88
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
1
|
35 |
|
88
|
36 |
documentation
|
|
37 |
"
|
362
|
38 |
DoubleArrays store doubleFloats values (and nothing else).
|
88
|
39 |
They have been added to support heavy duty number crunching somewhat
|
|
40 |
better than other smalltalks do.
|
362
|
41 |
Storing Floats & Doubles in these objects (instead of Arrays)
|
|
42 |
has some benefits:
|
1
|
43 |
|
88
|
44 |
1) since the values are stored directly (instead of pointers to them)
|
|
45 |
both access overhead and garbage collect overhead is minimized.
|
|
46 |
|
|
47 |
2) they can be much faster passed to c functions (such as graphics
|
|
48 |
libraries or heavy duty math packages), since the double values
|
|
49 |
come packed and can be used in C by using a (double *) or double[].
|
362
|
50 |
There is no need to loop over the array extracting doubles.
|
88
|
51 |
|
|
52 |
3) they could (in theory) be much more easily be processed by things like
|
|
53 |
vector and array processors
|
1
|
54 |
|
88
|
55 |
Be aware however, that Float- and DoubleArrays are not supported in other
|
|
56 |
smalltalks - your program will thus become somewhat less portable.
|
|
57 |
(since their protocol is the same as normal arrays filled with floats,
|
|
58 |
they can of course be easily simulated - a bit slower though)
|
1
|
59 |
|
2820
|
60 |
However, they could be simulated by a ByteArray, using doubleAt: and
|
92
|
61 |
doubleAtPut: messages to access the elements, but that seems a bit
|
|
62 |
clumsy and unelegant. Also, the stc-compiler may learn how to deal
|
|
63 |
with Float- and DoubleArrays, making accesses very fast in the future.
|
2820
|
64 |
Hint: if you use doubleArrays in your application and must port it
|
|
65 |
to some other smalltalk, define a DoubleArray class there, which is derived
|
|
66 |
from ByteArray, and add access methods.
|
1
|
67 |
|
2145
|
68 |
Of course, DoubleArray can be subclassed,
|
|
69 |
and named instance variables can be added there.
|
1
|
70 |
|
362
|
71 |
See example uses in the GLX interface and GLDemos.
|
1263
|
72 |
|
|
73 |
[See also:]
|
|
74 |
FloatArray Array
|
1290
|
75 |
|
|
76 |
[author:]
|
|
77 |
Claus Gittinger
|
88
|
78 |
"
|
627
|
79 |
! !
|
|
80 |
|
|
81 |
!DoubleArray class methodsFor:'documentation'!
|
565
|
82 |
|
|
83 |
version
|
2820
|
84 |
^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.17 1997-07-31 16:46:12 cg Exp $'
|
88
|
85 |
! !
|