DoubleArray.st
author Merge Script
Mon, 08 Jun 2015 06:58:54 +0200
branchjv
changeset 18461 bc3d3101c493
parent 18120 e3a375d5f6a8
child 19035 06aeb1259ba6
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    12
"{ Package: 'stx:libbasic' }"
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    13
13825
a80eb51765c0 class definition
Claus Gittinger <cg@exept.de>
parents: 13708
diff changeset
    14
AbstractNumberVector variableDoubleSubclass:#DoubleArray
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    15
	instanceVariableNames:''
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    16
	classVariableNames:''
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    17
	poolDictionaries:''
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    18
	category:'Collections-Arrayed'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    21
!DoubleArray class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    22
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
	      All Rights Reserved
a27a279701f8 Initial revision
claus
parents:
diff changeset
    27
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    35
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    36
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    37
documentation
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    38
"
13825
a80eb51765c0 class definition
Claus Gittinger <cg@exept.de>
parents: 13708
diff changeset
    39
    DoubleArrays store doubleFloat values (and nothing else).
16639
d9417b0b93a1 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 13825
diff changeset
    40
    They have been added to support heavy duty number crunching and
d9417b0b93a1 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 13825
diff changeset
    41
    data exchange with openGL frameworks and other mass data libraries
d9417b0b93a1 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 13825
diff changeset
    42
    somewhat better than other smalltalks do. 
362
claus
parents: 155
diff changeset
    43
    Storing Floats & Doubles in these objects (instead of Arrays)
claus
parents: 155
diff changeset
    44
    has some benefits:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    45
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    46
    1) since the values are stored directly (instead of pointers to them)
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    47
       both access overhead and garbage collect overhead is minimized.
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    48
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    49
    2) they can be much faster passed to c functions (such as graphics 
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    50
       libraries or heavy duty math packages), since the double values
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    51
       come packed and can be used in C by using a (double *) or double[].
362
claus
parents: 155
diff changeset
    52
       There is no need to loop over the array extracting doubles.      
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    53
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    54
    3) they could (in theory) be much more easily be processed by things like
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    55
       vector and array processors
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    56
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    57
    Be aware however, that Float- and DoubleArrays are not supported in other
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    58
    smalltalks - your program will thus become somewhat less portable.
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    59
    (since their protocol is the same as normal arrays filled with floats,
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    60
     they can of course be easily simulated - a bit slower though)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    61
2820
a128d890def3 comment
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
    62
    However, they could be simulated by a ByteArray, using doubleAt: and 
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    63
    doubleAtPut: messages to access the elements, but that seems a bit
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    64
    clumsy and unelegant. Also, the stc-compiler may learn how to deal
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    65
    with Float- and DoubleArrays, making accesses very fast in the future.
2820
a128d890def3 comment
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
    66
    Hint: if you use doubleArrays in your application and must port it
a128d890def3 comment
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
    67
    to some other smalltalk, define a DoubleArray class there, which is derived
a128d890def3 comment
Claus Gittinger <cg@exept.de>
parents: 2145
diff changeset
    68
    from ByteArray, and add access methods.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    69
2145
d243ffafeae3 more docu
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    70
    Of course, DoubleArray can be subclassed,
d243ffafeae3 more docu
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    71
    and named instance variables can be added there.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    72
362
claus
parents: 155
diff changeset
    73
    See example uses in the GLX interface and GLDemos.
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    74
4062
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 2820
diff changeset
    75
    [memory requirements:]
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 2820
diff changeset
    76
        OBJ-HEADER + (size * double-size)
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 2820
diff changeset
    77
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    78
    [See also:]
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    79
        FloatArray Array
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    80
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    81
    [author:]
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    82
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    83
"
627
0a9e18feab08 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
    84
! !
0a9e18feab08 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
    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
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   100
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   101
!DoubleArray methodsFor:'queries'!
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   102
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   103
defaultElement
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   104
    ^ Float zero
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   105
! !
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   106
627
0a9e18feab08 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   107
!DoubleArray class methodsFor:'documentation'!
565
4f64b1faa6e2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   108
4f64b1faa6e2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   109
version
16853
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   110
    ^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.24 2014-09-23 20:24:21 cg Exp $'
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   111
!
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   112
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   113
version_CVS
e3e062d68503 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 16850
diff changeset
   114
    ^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.24 2014-09-23 20:24:21 cg Exp $'
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
   115
! !
16639
d9417b0b93a1 class: DoubleArray
Claus Gittinger <cg@exept.de>
parents: 13825
diff changeset
   116