eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AbstractNumberVector':

Home

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

Class: AbstractNumberVector


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--AbstractNumberVector
                  |
                  +--ComplexDoubleArray
                  |
                  +--ComplexFloatArray
                  |
                  +--UnboxedFloatArray
                  |
                  +--UnboxedIntegerArray

Package:
stx:libbasic
Category:
Collections-Arrayed
Version:
rev: 1.20 date: 2023/05/12 07:41:45
user: cg
file: AbstractNumberVector.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


abstract superclass for all direct storing number vector classes
(float, double, integer arrays)

Mostly to share double dispatch code.

copyright

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

class initialization
o  initialize
aliases

instance creation
o  fromBytes: aByteArray
return new instance which is a copy of aByteArray

Usage example(s):

      DoubleArray fromBytes:#[0 0 0 0 0 0 0 0   1 2 3 4 5 6 7 8]
      FloatArray fromBytes:#[0 0 0 0  0 0 0 0   1 2 3 4  5 6 7 8]

queries
o  elementByteSize
Return the size of my elements in bytes.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.

o  maxVal
the maximum value which can be stored in instances of me

** This method must be redefined in concrete classes (subclassResponsibility) **

o  minVal
the minimum value which can be stored in instances of me

** This method must be redefined in concrete classes (subclassResponsibility) **


Instance protocol:

arithmetic
o  * anObject
return the product of the receiver and the argument.
The argument may either be a scalar or another vector

Usage example(s):

     #(1 2 3 4) asFloatArray * 3
     #(1 2 3 4) asFloatArray * #(1 2 3 4) asFloatArray

o  + anObject
return the sum of the receiver and the argument.
The argument may either be a scalar or another vector

Usage example(s):

     #(1 2 3 4) asFloatArray + 3
     #(1 2 3 4) asFloatArray + #(1 2 3 4) asFloatArray

o  - anObject
return the difference of the receiver and the argument.
The argument may either be a scalar or another vector

Usage example(s):

     #(1 2 3 4) asFloatArray - 3
     #(1 2 3 4) asFloatArray - #(1 2 3 4) asFloatArray

o  / anObject
return the division of the receiver and the argument.
The argument may either be a scalar or another vector

Usage example(s):

     #(1 2 3 4) asFloatArray / 3
     #(1 2 3 4) asFloatArray / #(1 2 3 4) asFloatArray

o  abs
return a new vector containing absolute values.
The receiver is unchanged

Usage example(s):

     #( -1 2 -3 4 -5 6 -7 8) abs.
     #( -1 2 -3 4 -5 6 -7 8) asFloatArray abs. 

o  negated
return a new vector containing negated values.
The receiver is unchanged

Usage example(s):

     #( -1 2 -3 4 -5 6 -7 8) negated.     
     #( -1 2 -3 4 -5 6 -7 8) asFloatArray negated. 

arithmetic destructive
o  *= anObject
multiply the argument into the receiver (destructive).
The argument may either be a scalar or another vector

Usage example(s):

     |f|

     f := #(1 2 3 4) asFloatArray.
     f *= 3.
     f

Usage example(s):

     |f|

     f := #f32(1 2 3 4) copy.
     f *= 3.
     f   

Usage example(s):

     |f|

     f := #(1 2 3 4) asFloatArray.
     f *= #(1 2 3 4) asFloatArray.
     f

o  += anObject
add the argument into the receiver (destructive).
The argument may either be a scalar or another vector

Usage example(s):

     |f|

     f := #(1 2 3 4) asFloatArray.
     f += 3.
     f

Usage example(s):

     |f|

     f := #(1 2 3 4) asFloatArray.
     f += #(1 2 3 4) asFloatArray.
     f

o  -= anObject
subtract the argument from the receiver (destructive).
The argument may either be a scalar or another vector

Usage example(s):

     |f|

     f := #(1 2 3 4) asFloatArray.
     f -= 3.
     f

o  /= anObject
divide the argument into the receiver (destructive).
The argument may either be a scalar or another vector

destructive arithmetic support
o  primAbs
low performance fall back: destructive replace each element by its absolute value.
May be redefined in subclasses to use vector instructions

o  primAddArray: anArray
low performance fallback: destructively add the vector argument into the receiver.
The argument must be another vector.
May be redefined in subclasses to use vector instructions

o  primAddScalar: aScalar
low performance fallback: destructively add the scalar argument into the receiver.
May be redefined in subclasses to use vector instructions

o  primDivideArray: floatArray
low performance fallback: destructively divide the vector argument into the receiver.
The argument must be another vector.
May be redefined in subclasses to use vector instructions

o  primDivideScalar: aScalar
low performance fallback: destructively divide the scalar argument into the receiver.
May be redefined in subclasses to use vector instructions

o  primMulArray: floatArray
low performance fallback: destructively multiply the vector argument into the receiver.
The argument must be another vector.
May be redefined in subclasses to use vector instructions

o  primMulScalar: aScalar
low performace fallback: destructively multiply each element of the receiver
by the scalar argument.
May be redefined in subclasses to use vector instructions

o  primNegated
low performance fallback: destructively negative value of each element.
May be redefined in subclasses to use vector instructions

o  primSubtractArray: floatArray
low performance fallback: destructively subtract the vector argument into the receiver.
The argument must be another vector.
May be redefined in subclasses to use vector instructions

inspecting
o  inspector2GraphTabUseful
( an extension from the stx:libtool package )
(comment from inherited method)
is a graph tab useful (in general for this type of collection)?

queries
o  absMax
return the largest absolute value

Usage example(s):

     |f1|

     f1 := (1 to:1000) asFloatArray.
     Time millisecondsToRun:[ 1000 timesRepeat:[ f1 absMax ] ]

Usage example(s):

     |f1|

     f1 := FloatArray withAll:#(1 2 3 4 5).
     f1 absMax

Usage example(s):

     |f1|

     f1 := FloatArray withAll:#(5 4 3 2 1).
     f1 absMax

Usage example(s):

     |f1|

     f1 := FloatArray withAll:#(5 -4 3 2 1).
     f1 absMax

Usage example(s):

     |f1|

     f1 := FloatArray withAll:#(5 -5 3 2 1).
     f1 absMax

Usage example(s):

     |f1|

     f1 := FloatArray withAll:#(5 -6 3 2 1).
     f1 absMax

testing
o  isSingleByteCollection
(comment from inherited method)
return true, if the receiver has access methods for bytes;
i.e. #at: and #at:put: accesses a byte and are equivalent to #byteAt: and byteAt:put:
and #replaceFrom:to: is equivalent to #replaceBytesFrom:to:.
This is different from 'self class isBytes',
true is returned here - the method is redefined from Object.

vector arithmetic
o  length
Return the length of the receiver interpreted as vector
(that is the length of the vector from 0.0 @ 0.0 @ ... @ 0.0
to the point in the n-dimensional space represented by the receiver).
Obsolete: the name 'length' may lead to confusion.
therefore renamed to vectorLength

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  squaredLength
Return the squared length of the receiver interpreted as vector.
Obsolete: the name 'squaredLength' may lead to confusion.
therefore renamed to squaredVectorLength

** This is an obsolete interface - do not use it (it may vanish in future versions) **



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 04:14:36 GMT