author | Claus Gittinger <cg@exept.de> |
Thu, 13 Dec 2012 16:13:56 +0100 | |
changeset 14585 | 186421233efa |
parent 13825 | a80eb51765c0 |
child 16639 | d9417b0b93a1 |
child 18011 | deb0c3355881 |
permissions | -rw-r--r-- |
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 |
||
13825 | 14 |
AbstractNumberVector 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 |
" |
|
13825 | 39 |
DoubleArrays store doubleFloat 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 |
||
13708
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
85 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
86 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
87 |
!DoubleArray class methodsFor:'queries'! |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
88 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
89 |
elementByteSize |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
90 |
^ 8 |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
91 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
92 |
"Created: / 15-09-2011 / 14:12:46 / cg" |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
93 |
! ! |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
94 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
95 |
|
7220 | 96 |
!DoubleArray methodsFor:'queries'! |
97 |
||
98 |
defaultElement |
|
99 |
^ Float zero |
|
100 |
! ! |
|
101 |
||
627 | 102 |
!DoubleArray class methodsFor:'documentation'! |
565 | 103 |
|
104 |
version |
|
13825 | 105 |
^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.21 2011-11-25 15:38:12 cg Exp $' |
88 | 106 |
! ! |