eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ComplexFloatArray':

Home

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

Class: ComplexFloatArray


Inheritance:

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

Package:
stx:libbasic2
Category:
Collections-Arrayed
Version:
rev: 1.9 date: 2021/12/19 08:05:16
user: cg
file: ComplexFloatArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


ComplexFloatArrays store complex numbers (in single precision) 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 or FFT), since the float values
   come packed and can be used in C by using a (float *) or float[].
   There is no need to loop over the array extracting float.      

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

Be aware however, that ComplexFloatArrays 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 floatAt: and 
floatAtPut: messages to access the elements, but that seems a bit
clumsy and unelegant. Also, the stc-compiler may learn how to deal
with such special, making accesses very fast in the future.
Hint: if you use complexFloatArrays in your application and must port it
to some other Smalltalk, define a ComplexFloatArray class there, which is derived
from ByteArray, and add access methods.

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

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

[complexity:]
    see Array

copyright

COPYRIGHT (c) 2018 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  new: size
(comment from inherited method)
return an instance of myself with anInteger indexed variables

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

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

o  literalTokenPrefix


Instance protocol:

accessing
o  at: index
(comment from inherited method)
return the indexed instance variable with index, anInteger;
this method can be redefined in subclasses.

o  at: index put: aComplex
(comment from inherited method)
store the 2nd arg, anObject as indexed instvar with index, anInteger.
this method can be redefined in subclasses. Returns anObject (sigh)

o  at: index put: realPart i: imaginaryPart

o  imaginaryAt: index

o  realAt: index

queries
o  defaultElement

o  size
(comment from inherited method)
redefined to re-enable size->basicSize forwarding
(it is caught in SequencableCollection)


Examples:


    |vec|

    vec := ComplexFloatArray 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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:33:18 GMT