eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HalfFloatArray':

Home

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

Class: HalfFloatArray


Inheritance:

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

Package:
stx:libbasic2
Category:
Collections-Arrayed
Version:
rev: 1.36 date: 2023/06/12 08:54:24
user: cg
file: HalfFloatArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


HalfFloatArrays store half precision (16bit) floats (and nothing else).
These have been added to IEEE754 in 2008 as minifloat (s10e5 binary16 format).

These have a 5bit exponent and a very limited 10 bit mantissa.
Thus, they have a much smaller number range than single precision floats or bfloat16's, 
and a bit more precision than bfloat16s and less precision than single precision floats.

HalfFloats were traditionally seldom used, but seem to become more popular
these days, as machine learning algorithms, 3D graphics accelerators and game engines use them
for dense and compact storage of neuron data, texture and vertex data.
HalfFloats are used by nVidia graphics cards, the OpenEXR standard, and Pixar.

Notice, that HalfFloats are not supported as first class objects by the ST/X system;
i.e. outside of a HalfFloatArray, these values are represented as floats
or doubles. When accessing a HalfFloatArray's element via getters/setters,
shortFloat (i.e. single precision 32bit floats) are exchanged.

Be aware that the numeric range of a half-float is very very limited.

HalfFloatArrays can be used as literals i.e. you can enter HalfFloatArray-constants as: 
    #f16( element1 element2 .... elementN ) 
for example:
    #f16(1 2.0 3 4.0)

Aliased as Float16Array.

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

copyright

COPYRIGHT (c) 2014 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:

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

o  epsilon
return the maximum relative spacing of elements of mySelf
(i.e. the value-delta of the least significant bit)
according to ISO C standard;
Ada, C, C++ and Python language constants;
Mathematica, MATLAB and Octave; and various textbooks
see https://en.wikipedia.org/wiki/Machine_epsilon

Usage example(s):

     HalfFloatArray epsilon printStringScientific

o  fmax
return the largest value that instances of me can represent

o  fmin
return the smallest normalized non-zero value that instances of me can hold

o  literalTokenPrefix

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


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: aFloat
arrive here only in case of an error

queries
o  defaultElement



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 12:25:56 GMT