eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ComplexDoubleArray':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ComplexDoubleArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--AbstractNumberVector
                  |
                  +--ComplexDoubleArray

Package:
stx:libbasic2
Category:
Collections-Arrayed
Version:
rev: 1.2 date: 2018/05/06 01:19:57
user: cg
file: ComplexDoubleArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


ComplexDoubleArrays store complex numbers (in double prevision) and nothing else.
They have been added to support heavy duty number crunching and
data exchange with openGL frameworks and other mass data libraries
somewhat better than other smalltalks do. 
Storing Complex numbers in these objects (instead of Arrays)
has some benefits:

1) since the values are stored directly (instead of pointers to them)
   both access overhead and garbage collect overhead is minimized.

2) they can be much faster passed to c functions (such as graphics 
   libraries or heavy duty math packages), since the double values
   come packed and can be used in C by using a (double *) or double[].
   There is no need to loop over the array extracting doubles.      

3) they could (in theory) be much more easily be processed by things like
   vector and array processors

Be aware however, that ComplexDoubleArrays are not supported in other
smalltalks - your program will thus become somewhat less portable.
(since their protocol is the same as normal arrays filled with floats,
 they can of course be easily simulated - a bit slower though)

However, they could be simulated by a ByteArray, using doubleAt: and 
doubleAtPut: messages to access the elements, but that seems a bit
clumsy and unelegant. Also, the stc-compiler may learn how to deal
with Float- and DoubleArrays, making accesses very fast in the future.
Hint: if you use doubleArrays in your application and must port it
to some other smalltalk, define a DoubleArray class there, which is derived
from ByteArray, and add access methods.

Of course, ComplexDoubleArrays can be subclassed,
and named instance variables can be added there.

[memory requirements:]
    OBJ-HEADER + (size * double-size * 2)


Related information:

    ComplexFloatArray
    DoubleArray
    FloatArray
    Array

Class protocol:

instance creation
o  new: size

queries
o  elementByteSize
for bit-like containers, return the number of bytes stored per element.
Here, 2*8 is returned


Instance protocol:

accessing
o  at: index

o  at: index put: aComplex

o  at: index put: realPart i: imaginaryPart

o  imaginaryAt: index

o  realAt: index

queries
o  defaultElement

o  isValidElement: anObject
return true, if I can hold this kind of object

o  size


Examples:


    |vec|

    vec := ComplexDoubleArray new:4.
    vec size.
    vec at:1.
    vec at:2.
    vec at:3.
    vec at:4.
    vec at:1 put:(1 + 4i).
    vec at:2 put:(2 + 4i).
    vec at:4 put:(4 + 4i).
    vec


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 13:55:32 GMT