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