eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FloatArray':

Home

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

Class: FloatArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--AbstractNumberVector
                  |
                  +--UnboxedFloatArray
                     |
                     +--FloatArray

Package:
stx:libbasic
Category:
Collections-Arrayed
Version:
rev: 1.51 date: 2019/07/19 15:25:59
user: cg
file: FloatArray.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


FloatArrays store floats (and nothing else).
They have been added to support heavy duty number crunching and
data exchange with openGL frameworks and other mass data libraries.
See documentation in DoubleArray for more information.

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


Related information:

    DoubleArray
    Array

Class protocol:

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

o  epsilon
return the maximum relative spacing of my elements
(i.e. the value-delta of the least significant bit)

o  precision
answer the precision (the number of bits in the mantissa) of my elements (in bits)
This is an IEEE float, where only the fraction from the normalized mantissa is stored
and so there is a hidden bit and the mantissa is actually represented by 24 binary digits
(although only 23 are needed in the binary representation)


Instance protocol:

copying
o  clone
return a copy of the receiver

o  copyFrom: start to: stop
return a partial copy of the receiver

o  replaceFrom: start to: stop with: aCollection startingAt: replStart
arrive here only in case of an error

destructive arithmetic support
o  primAbs
destructive absolute value of each element;
does not check for immutability: only use internally after cloning

o  primAddArray: floatArray
add the vector argument into the receiver (destructive).
The argument must be another vector.
does not check for immutability: only use internally after cloning

o  primAddScalar: aScalar
add the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning

o  primDivArray: floatArray
divide the vector argument into the receiver (destructive).
The argument must be another vector.
does not check for immutability: only use internally after cloning

o  primDivScalar: aScalar
divide the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning

o  primMulArray: floatArray
multiply the vector argument into the receiver (destructive).
The argument must be another vector.
does not check for immutability: only use internally after cloning

o  primMulScalar: aScalar
multiply the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning

o  primNegated
destructive negative value of each element.
does not check for immutability: only use internally after cloning

o  primSubtractArray: floatArray
subtract the vector argument from the receiver (destructive).
The argument must be another vector.
does not check for immutability: only use internally after cloning

o  primSubtractScalar: aScalar
subtract the scalar argument from the receiver (destructive).
does not check for immutability: only use internally after cloning

queries
o  defaultElement

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

o  minMax
return a Tuple holding the smallest and largest element;
redefined for speed

o  numFloats

testing
o  isFloatArray
return true if the receiver has float elements.
These are Float, Double- and HalfFloat arrays

o  isUnboxedFloatArray
return true if the receiver has float elements.
These are Float, Double- and HalfFloat arrays

vector arithmetic
o  dot: aFloatVector
Return the dot product of the receiver and the argument.
Raises an error, if the argument is not of the same size as the receiver.

o  esum
Return the (double) sum of the elements.
Reduces accumulated rounding errors.
This is an experimental algorithm

usage example(s):

here, sum and esum both deliver the same result
    
     |v|
     v := #(2.0 2.0 1.0 1.0) asFloatArray.
     v sum.
     v esum.

     |v|
     v := #(1e38 1.0 -1e38 1.0) asFloatArray.
     v sum.
     v esum.

o  hornerMultiplyAndAdd: x
primitive support for horner's-method computation of polynomials.
The vector is interpreted as providing the factors for a polynomial,
an*x^n + (an-1)*x^(n-1) + ... + a2(x) + a1
where the ai are the elements of the Array.
The highest rank factor is at the first position, the 0-rank constant at last.
This is inlined c-code, which may get compiled to fast machine code,
using multiply-and-add or vector instructions, if the CPU/Compiler support them.

o  sum
Return the (double) sum of the elements.
May suffer from accumulated rounding error



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 24 Apr 2024 01:11:35 GMT