|
Class: FloatArray
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
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)
DoubleArray
Array
queries
-
elementByteSize
-
for bit-like containers, return the number of bytes stored per element.
Here, 4 is returned
-
epsilon
-
return the maximum relative spacing of my elements
(i.e. the value-delta of the least significant bit)
-
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)
copying
-
clone
-
return a copy of the receiver
-
copyFrom: start to: stop
-
return a partial copy of the receiver
-
replaceFrom: start to: stop with: aCollection startingAt: replStart
-
arrive here only in case of an error
destructive arithmetic support
-
primAbs
-
destructive absolute value of each element;
does not check for immutability: only use internally after cloning
-
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
-
primAddScalar: aScalar
-
add the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning
-
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
-
primDivScalar: aScalar
-
divide the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning
-
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
-
primMulScalar: aScalar
-
multiply the scalar argument into the receiver (destructive).
does not check for immutability: only use internally after cloning
-
primNegated
-
destructive negative value of each element.
does not check for immutability: only use internally after cloning
-
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
-
primSubtractScalar: aScalar
-
subtract the scalar argument from the receiver (destructive).
does not check for immutability: only use internally after cloning
queries
-
defaultElement
-
-
isValidElement: anObject
-
return true, if I can hold this kind of object
-
minMax
-
return a Tuple holding the smallest and largest element;
redefined for speed
-
numFloats
-
testing
-
isFloatArray
-
return true if the receiver has float elements.
These are Float, Double- and HalfFloat arrays
-
isUnboxedFloatArray
-
return true if the receiver has float elements.
These are Float, Double- and HalfFloat arrays
vector arithmetic
-
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.
-
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.
|
-
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.
-
sum
-
Return the (double) sum of the elements.
May suffer from accumulated rounding error
|