|
Class: AbstractNumberVector
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
abstract superclass for all direct storing number vector classes
(float, double, integer arrays)
Mostly to share double dispatch code.
copyrightCOPYRIGHT (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 initialization
-
initialize
-
aliases
instance creation
-
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
-
elementByteSize
-
Return the size of my elements in bytes.
** This method must be redefined in concrete classes (subclassResponsibility) **
-
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.
-
maxVal
-
the maximum value which can be stored in instances of me
** This method must be redefined in concrete classes (subclassResponsibility) **
-
minVal
-
the minimum value which can be stored in instances of me
** This method must be redefined in concrete classes (subclassResponsibility) **
arithmetic
-
* 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
|
-
+ 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
|
-
- 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
|
-
/ 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
|
-
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.
|
-
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
-
*= 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
|
-
+= 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
|
-
-= 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
|
-
/= anObject
-
divide the argument into the receiver (destructive).
The argument may either be a scalar or another vector
destructive arithmetic support
-
primAbs
-
low performance fall back: destructive replace each element by its absolute value.
May be redefined in subclasses to use vector instructions
-
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
-
primAddScalar: aScalar
-
low performance fallback: destructively add the scalar argument into the receiver.
May be redefined in subclasses to use vector instructions
-
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
-
primDivideScalar: aScalar
-
low performance fallback: destructively divide the scalar argument into the receiver.
May be redefined in subclasses to use vector instructions
-
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
-
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
-
primNegated
-
low performance fallback: destructively negative value of each element.
May be redefined in subclasses to use vector instructions
-
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
-
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
-
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
-
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
-
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) **
-
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) **
|