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