author | Merge Script |
Mon, 08 Jun 2015 06:58:54 +0200 | |
branch | jv |
changeset 18461 | bc3d3101c493 |
parent 18120 | e3a375d5f6a8 |
child 19035 | 06aeb1259ba6 |
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). |
16639 | 40 |
They have been added to support heavy duty number crunching and |
41 |
data exchange with openGL frameworks and other mass data libraries |
|
42 |
somewhat 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 |
||
16850
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
86 |
|
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
87 |
|
13708
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
88 |
!DoubleArray class methodsFor:'queries'! |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
89 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
90 |
elementByteSize |
16850
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
91 |
"for bit-like containers, return the number of bytes stored per element. |
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
92 |
Here, 8 is returned" |
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
93 |
|
13708
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
94 |
^ 8 |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
95 |
|
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
96 |
"Created: / 15-09-2011 / 14:12:46 / cg" |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
97 |
! ! |
079c1e1c7594
faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents:
7220
diff
changeset
|
98 |
|
16850
4011fc651793
comment/format in: #elementByteSize
Claus Gittinger <cg@exept.de>
parents:
16639
diff
changeset
|
99 |
|
16853 | 100 |
|
7220 | 101 |
!DoubleArray methodsFor:'queries'! |
102 |
||
103 |
defaultElement |
|
104 |
^ Float zero |
|
105 |
! ! |
|
106 |
||
627 | 107 |
!DoubleArray class methodsFor:'documentation'! |
565 | 108 |
|
109 |
version |
|
16853 | 110 |
^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.24 2014-09-23 20:24:21 cg Exp $' |
111 |
! |
|
112 |
||
113 |
version_CVS |
|
114 |
^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.24 2014-09-23 20:24:21 cg Exp $' |
|
88 | 115 |
! ! |
16639 | 116 |