--- a/FloatArray.st Wed Jan 23 10:08:55 2013 +0000
+++ b/FloatArray.st Mon Jan 28 21:53:19 2013 +0000
@@ -40,13 +40,13 @@
See documentation in DoubleArray for more information.
[memory requirements:]
- OBJ-HEADER + (size * float-size)
+ OBJ-HEADER + (size * float-size)
[See also:]
- DoubleArray Array
+ DoubleArray Array
[author:]
- Claus Gittinger
+ Claus Gittinger
"
! !
@@ -70,7 +70,7 @@
^ self clone *= anObject
"
- #(1 2 3 4) asFloatArray * 3
+ #(1 2 3 4) asFloatArray * 3
#(1 2 3 4) asFloatArray * #(1 2 3 4) asFloatArray
"
!
@@ -82,8 +82,8 @@
^ self clone += anObject
"
- #(1 2 3 4) asFloatArray + 3
- #(1 2 3 4) asFloatArray + #(1 2 3 4) asFloatArray
+ #(1 2 3 4) asFloatArray + 3
+ #(1 2 3 4) asFloatArray + #(1 2 3 4) asFloatArray
"
!
@@ -94,8 +94,8 @@
^ self clone -= anObject
"
- #(1 2 3 4) asFloatArray - 3
- #(1 2 3 4) asFloatArray - #(1 2 3 4) asFloatArray
+ #(1 2 3 4) asFloatArray - 3
+ #(1 2 3 4) asFloatArray - #(1 2 3 4) asFloatArray
"
"Created: / 30-05-2007 / 17:41:46 / cg"
@@ -108,8 +108,8 @@
^ self clone /= anObject
"
- #(1 2 3 4) asFloatArray / 3
- #(1 2 3 4) asFloatArray / #(1 2 3 4) asFloatArray
+ #(1 2 3 4) asFloatArray / 3
+ #(1 2 3 4) asFloatArray / #(1 2 3 4) asFloatArray
"
"Created: / 30-05-2007 / 17:46:05 / cg"
@@ -132,28 +132,28 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
- int i;
- float *_p = __FloatArrayInstPtr(self)->f_element;
+ INT _sz = __floatArraySize(self);
+ INT i;
+ float *_p = __FloatArrayInstPtr(self)->f_element;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz; i++) {
- float f = _p[i];
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz; i++) {
+ float f = _p[i];
- if (f < 0) {
- _p[i] = -f;
- }
- }
- RETURN (self);
+ if (f < 0) {
+ _p[i] = -f;
+ }
+ }
+ RETURN (self);
}
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) abs].
"
|f|
f := FloatArray withAll:#(-1 2 -3 4 -5).
- f abs.
+ f abs.
f
"
@@ -168,21 +168,21 @@
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& __isFloats(floatArray)
&& (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
- int _sz1 = __floatArraySize(self);
- int _sz2 = __floatArraySize(floatArray);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
+ INT _sz1 = __floatArraySize(self);
+ INT _sz2 = __floatArraySize(floatArray);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
- if (_sz2 >= _sz1) {
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] += _p2[i];
- }
- }
- RETURN (self);
+ if (_sz2 >= _sz1) {
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] += _p2[i];
+ }
+ }
+ RETURN (self);
}
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) + (floatArray at: i)].
"
@@ -191,7 +191,7 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f2 := FloatArray withAll:#(2 2 2 3 3).
f1 += f2.
- f1
+ f1
"
!
@@ -200,28 +200,28 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz1 = __floatArraySize(self);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float v;
+ INT _sz1 = __floatArraySize(self);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float v;
- if (__isFloat(aScalar)) {
- v = (float)(__floatVal(aScalar));
- } else if (__isShortFloat(aScalar)) {
- v = __shortFloatVal(aScalar);
- } else if (__isSmallInteger(aScalar)) {
- v = (float)(__intVal(aScalar));
- } else
- goto badArg;
+ if (__isFloat(aScalar)) {
+ v = (float)(__floatVal(aScalar));
+ } else if (__isShortFloat(aScalar)) {
+ v = __shortFloatVal(aScalar);
+ } else if (__isSmallInteger(aScalar)) {
+ v = (float)(__intVal(aScalar));
+ } else
+ goto badArg;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] += v;
- }
- RETURN (self);
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] += v;
+ }
+ RETURN (self);
}
badArg: ;
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) + aScalar].
"
@@ -229,11 +229,11 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f1 += 2.0.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 += 2.0 asShortFloat.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 += 2.
- Transcript showCR:f1.
+ Transcript showCR:f1.
"
!
@@ -245,19 +245,19 @@
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& __isFloats(floatArray)
&& (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
- int _sz1 = __floatArraySize(self);
- int _sz2 = __floatArraySize(floatArray);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
+ INT _sz1 = __floatArraySize(self);
+ INT _sz2 = __floatArraySize(floatArray);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
- if (_sz2 >= _sz1) {
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] /= _p2[i];
- }
- }
- RETURN (self);
+ if (_sz2 >= _sz1) {
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] /= _p2[i];
+ }
+ }
+ RETURN (self);
}
%}.
1 to: self size do:[:i| self at: i put: (self at: i) / (floatArray at: i)].
@@ -268,7 +268,7 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f2 := FloatArray withAll:#(2 2 2 3 3).
f1 /= f2.
- f1
+ f1
"
"Modified: / 29-05-2007 / 16:01:34 / cg"
@@ -279,25 +279,25 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz1 = __floatArraySize(self);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float v;
+ INT _sz1 = __floatArraySize(self);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float v;
- if (__isFloat(aScalar)) {
- v = (float)(__floatVal(aScalar));
- } else if (__isShortFloat(aScalar)) {
- v = __shortFloatVal(aScalar);
- } else if (__isSmallInteger(aScalar)) {
- v = (float)(__intVal(aScalar));
- } else
- goto badArg;
+ if (__isFloat(aScalar)) {
+ v = (float)(__floatVal(aScalar));
+ } else if (__isShortFloat(aScalar)) {
+ v = __shortFloatVal(aScalar);
+ } else if (__isSmallInteger(aScalar)) {
+ v = (float)(__intVal(aScalar));
+ } else
+ goto badArg;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] /= v;
- }
- RETURN (self);
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] /= v;
+ }
+ RETURN (self);
}
badArg: ;
%}.
@@ -308,11 +308,11 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f1 /= 2.0.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 /= 2.0 asShortFloat.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 /= 2.
- Transcript showCR:f1.
+ Transcript showCR:f1.
"
"Modified: / 29-05-2007 / 16:01:39 / cg"
@@ -326,19 +326,19 @@
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& __isFloats(floatArray)
&& (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
- int _sz1 = __floatArraySize(self);
- int _sz2 = __floatArraySize(floatArray);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
+ INT _sz1 = __floatArraySize(self);
+ INT _sz2 = __floatArraySize(floatArray);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
- if (_sz2 >= _sz1) {
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] *= _p2[i];
- }
- }
- RETURN (self);
+ if (_sz2 >= _sz1) {
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] *= _p2[i];
+ }
+ }
+ RETURN (self);
}
%}.
1 to: self size do:[:i| self at: i put: (self at: i) * (floatArray at: i)].
@@ -349,7 +349,7 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f2 := FloatArray withAll:#(2 2 2 3 3).
f1 *= f2.
- f1
+ f1
"
!
@@ -358,25 +358,25 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz1 = __floatArraySize(self);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float v;
+ INT _sz1 = __floatArraySize(self);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float v;
- if (__isFloat(aScalar)) {
- v = (float)(__floatVal(aScalar));
- } else if (__isShortFloat(aScalar)) {
- v = __shortFloatVal(aScalar);
- } else if (__isSmallInteger(aScalar)) {
- v = (float)(__intVal(aScalar));
- } else
- goto badArg;
+ if (__isFloat(aScalar)) {
+ v = (float)(__floatVal(aScalar));
+ } else if (__isShortFloat(aScalar)) {
+ v = __shortFloatVal(aScalar);
+ } else if (__isSmallInteger(aScalar)) {
+ v = (float)(__intVal(aScalar));
+ } else
+ goto badArg;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] *= v;
- }
- RETURN (self);
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] *= v;
+ }
+ RETURN (self);
}
badArg: ;
%}.
@@ -387,11 +387,11 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f1 *= 2.0.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 *= 2.0 asShortFloat.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 *= 2.
- Transcript showCR:f1.
+ Transcript showCR:f1.
"
!
@@ -400,27 +400,27 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
- int i;
- float *_p = __FloatArrayInstPtr(self)->f_element;
+ INT _sz = __floatArraySize(self);
+ INT i;
+ float *_p = __FloatArrayInstPtr(self)->f_element;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz; i++) {
- float f = _p[i];
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz; i++) {
+ float f = _p[i];
- _p[i] = -f;
- }
- RETURN (self);
+ _p[i] = -f;
+ }
+ RETURN (self);
}
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) negated].
"
|f|
f := FloatArray withAll:#(-1 2 -3 4 -5).
- f negated.
- f
+ f negated.
+ f
"
"Created: / 30-05-2007 / 17:51:29 / cg"
@@ -434,21 +434,21 @@
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& __isFloats(floatArray)
&& (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
- int _sz1 = __floatArraySize(self);
- int _sz2 = __floatArraySize(floatArray);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
+ INT _sz1 = __floatArraySize(self);
+ INT _sz2 = __floatArraySize(floatArray);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
- if (_sz2 >= _sz1) {
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] -= _p2[i];
- }
- }
- RETURN (self);
+ if (_sz2 >= _sz1) {
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] -= _p2[i];
+ }
+ }
+ RETURN (self);
}
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) - (floatArray at: i)].
"
@@ -457,7 +457,7 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f2 := FloatArray withAll:#(2 2 2 3 3).
f1 -= f2.
- f1
+ f1
"
"Created: / 30-05-2007 / 17:42:41 / cg"
@@ -468,28 +468,28 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz1 = __floatArraySize(self);
- int i;
- float *_p1 = __FloatArrayInstPtr(self)->f_element;
- float v;
+ INT _sz1 = __floatArraySize(self);
+ INT i;
+ float *_p1 = __FloatArrayInstPtr(self)->f_element;
+ float v;
- if (__isFloat(aScalar)) {
- v = (float)(__floatVal(aScalar));
- } else if (__isShortFloat(aScalar)) {
- v = __shortFloatVal(aScalar);
- } else if (__isSmallInteger(aScalar)) {
- v = (float)(__intVal(aScalar));
- } else
- goto badArg;
+ if (__isFloat(aScalar)) {
+ v = (float)(__floatVal(aScalar));
+ } else if (__isShortFloat(aScalar)) {
+ v = __shortFloatVal(aScalar);
+ } else if (__isSmallInteger(aScalar)) {
+ v = (float)(__intVal(aScalar));
+ } else
+ goto badArg;
- /* how about inline-mmx-asm for this ... */
- for (i=0; i<_sz1; i++) {
- _p1[i] -= v;
- }
- RETURN (self);
+ /* how about inline-mmx-asm for this ... */
+ for (i=0; i<_sz1; i++) {
+ _p1[i] -= v;
+ }
+ RETURN (self);
}
badArg: ;
-%}.
+%}.
1 to: self size do:[:i| self at: i put: (self at: i) - aScalar].
"
@@ -497,11 +497,11 @@
f1 := FloatArray withAll:#(1 2 3 4 5).
f1 -= 2.0.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 -= 2.0 asShortFloat.
- Transcript showCR:f1.
+ Transcript showCR:f1.
f1 -= 2.
- Transcript showCR:f1.
+ Transcript showCR:f1.
"
"Created: / 30-05-2007 / 17:43:06 / cg"
@@ -514,22 +514,22 @@
The argument may either be a scalar or another vector"
^ anObject isNumber
- ifTrue:[self primMulScalar: anObject asFloat]
- ifFalse:[self primMulArray: anObject]
+ ifTrue:[self primMulScalar: anObject asFloat]
+ ifFalse:[self primMulArray: anObject]
"
|f|
f := #(1 2 3 4) asFloatArray.
f *= 3.
- f
+ f
"
"
|f|
f := #(1 2 3 4) asFloatArray.
f *= #(1 2 3 4) asFloatArray.
- f
+ f
"
!
@@ -538,22 +538,22 @@
The argument may either be a scalar or another vector"
^ anObject isNumber
- ifTrue:[self primAddScalar: anObject asFloat]
- ifFalse:[self primAddArray: anObject]
+ ifTrue:[self primAddScalar: anObject asFloat]
+ ifFalse:[self primAddArray: anObject]
"
|f|
f := #(1 2 3 4) asFloatArray.
f += 3.
- f
+ f
"
"
|f|
f := #(1 2 3 4) asFloatArray.
f += #(1 2 3 4) asFloatArray.
- f
+ f
"
!
@@ -562,22 +562,22 @@
The argument may either be a scalar or another vector"
^ anObject isNumber
- ifTrue:[self primSubtractScalar: anObject asFloat]
- ifFalse:[self primSubtractArray: anObject]
+ ifTrue:[self primSubtractScalar: anObject asFloat]
+ ifFalse:[self primSubtractArray: anObject]
"
|f|
f := #(1 2 3 4) asFloatArray.
f -= 3.
- f
+ f
"
"
|f|
f := #(1 2 3 4) asFloatArray.
f += #(1 2 3 4) asFloatArray.
- f
+ f
"
"Created: / 30-05-2007 / 17:42:13 / cg"
@@ -588,8 +588,8 @@
The argument may either be a scalar or another vector"
^ anObject isNumber
- ifTrue:[self primDivScalar: anObject asFloat]
- ifFalse:[self primDivArray: anObject]
+ ifTrue:[self primDivScalar: anObject asFloat]
+ ifFalse:[self primDivArray: anObject]
"Modified: / 30-05-2007 / 17:45:46 / cg"
! !
@@ -604,13 +604,13 @@
newArr := self class new:(self size).
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
+ INT _sz = __floatArraySize(self);
- bcopy(__FloatArrayInstPtr(self)->f_element,
- __FloatArrayInstPtr(newArr)->f_element,
- sizeof(float) * _sz);
+ bcopy(__FloatArrayInstPtr(self)->f_element,
+ __FloatArrayInstPtr(newArr)->f_element,
+ sizeof(float) * _sz);
- RETURN (newArr);
+ RETURN (newArr);
}
%}.
newArr replaceFrom:1 to:self size with:self startingAt:1.
@@ -620,7 +620,7 @@
|f1 f2|
f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 clone
+ f1 clone
"
!
@@ -629,40 +629,40 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- if (__bothSmallInteger(start, stop)) {
- int __start = __intVal(start) - 1;
- int __stop = __intVal(stop) - 1 ;
+ if (__bothSmallInteger(start, stop)) {
+ INT __start = __intVal(start) - 1;
+ INT __stop = __intVal(stop) - 1 ;
- if (__stop >= __start) {
- int __sz = __floatArraySize(self);
+ if (__stop >= __start) {
+ INT __sz = __floatArraySize(self);
- if (((unsigned)__start < __sz)
- && ((unsigned)__stop < __sz)) {
- int __n = __stop - __start + 1;
- OBJ __nObj;
+ if (((unsigned INT)__start < __sz)
+ && ((unsigned INT)__stop < __sz)) {
+ INT __n = __stop - __start + 1;
+ OBJ __nObj;
- __nObj = __STX___new(sizeof(struct __FloatArray) + (__n - 1) * sizeof(float));
- if (__nObj != nil) {
- __objPtr(__nObj)->o_class = __qClass(self);
- __STORE(__nObj, __qClass(self));
- bcopy(__FloatArrayInstPtr(self)->f_element + __start,
- __FloatArrayInstPtr(__nObj)->f_element,
- sizeof(float) * __n);
- RETURN(__nObj);
- }
- }
- }
- }
+ __nObj = __STX___new(sizeof(struct __FloatArray) + (__n - 1) * sizeof(float));
+ if (__nObj != nil) {
+ __objPtr(__nObj)->o_class = __qClass(self);
+ __STORE(__nObj, __qClass(self));
+ bcopy(__FloatArrayInstPtr(self)->f_element + __start,
+ __FloatArrayInstPtr(__nObj)->f_element,
+ sizeof(float) * __n);
+ RETURN(__nObj);
+ }
+ }
+ }
+ }
}
-%}.
+%}.
^ super copyFrom:start to:stop
"
|f1 f2|
f1 := FloatArray withAll:#(1 2 3 4 5 6).
- f2 := f1 copyFrom:2 to:4.
- f2
+ f2 := f1 copyFrom:2 to:4.
+ f2
"
!
@@ -671,32 +671,32 @@
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& __isFloats(aCollection)
&& (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __mkSmallInteger(0))) {
- if (__bothSmallInteger(start, stop)
- && __isSmallInteger(replStart)) {
- int __start = __intVal(start) - 1;
- int __stop = __intVal(stop) - 1 ;
- int __replStart = __intVal(replStart) - 1 ;
+ if (__bothSmallInteger(start, stop)
+ && __isSmallInteger(replStart)) {
+ INT __start = __intVal(start) - 1;
+ INT __stop = __intVal(stop) - 1 ;
+ INT __replStart = __intVal(replStart) - 1 ;
- if (__stop >= __start) {
- int __sz = __floatArraySize(self);
- int __otherSz = __floatArraySize(aCollection);
- int __replStop = __replStart + (__stop-__start);
+ if (__stop >= __start) {
+ INT __sz = __floatArraySize(self);
+ INT __otherSz = __floatArraySize(aCollection);
+ INT __replStop = __replStart + (__stop-__start);
- if (((unsigned)__start < __sz)
- && ((unsigned)__stop < __sz)
- && ((unsigned)__replStart < __otherSz)
- && ((unsigned)__replStop < __otherSz)) {
- int __n = __stop - __start + 1;
+ if (((unsigned INT)__start < __sz)
+ && ((unsigned INT)__stop < __sz)
+ && ((unsigned INT)__replStart < __otherSz)
+ && ((unsigned INT)__replStop < __otherSz)) {
+ INT __n = __stop - __start + 1;
- if (aCollection != self) {
- bcopy(&(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
- &(__FloatArrayInstPtr(self)->f_element[__start]),
- sizeof(float) * __n);
- RETURN(self);
- }
- }
- }
- }
+ if (aCollection != self) {
+ bcopy(&(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
+ &(__FloatArrayInstPtr(self)->f_element[__start]),
+ sizeof(float) * __n);
+ RETURN(self);
+ }
+ }
+ }
+ }
}
%}.
^ super replaceFrom:start to:stop with:aCollection startingAt:replStart
@@ -706,7 +706,7 @@
f1 := (1 to:5) asFloatArray.
f2 := #(10 9 8 7 6) asFloatArray.
- f1 replaceFrom:1 to:3 with:f2 startingAt:3
+ f1 replaceFrom:1 to:3 with:f2 startingAt:3
"
! !
@@ -731,31 +731,31 @@
|f1|
f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 absMax
+ f1 absMax
"
"
|f1|
f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 absMax
+ f1 absMax
"
"
|f1|
f1 := FloatArray withAll:#(5 -4 3 2 1).
- f1 absMax
+ f1 absMax
"
"
|f1|
f1 := FloatArray withAll:#(5 -5 3 2 1).
- f1 absMax
+ f1 absMax
"
"
|f1|
f1 := FloatArray withAll:#(5 -6 3 2 1).
- f1 absMax
+ f1 absMax
"
!
@@ -764,15 +764,15 @@
!
length
- "Return the length of the receiver interpreted as vector
+ "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)"
^ self squaredLength sqrt
"
- #(10.0 10.0) asFloatArray length
- #(10.0 10.0 10.0) asFloatArray length
+ #(10.0 10.0) asFloatArray length
+ #(10.0 10.0 10.0) asFloatArray length
"
!
@@ -781,28 +781,28 @@
redefined for speed"
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
+ INT _sz = __floatArraySize(self);
- if (_sz > 0) {
- float *_p = __FloatArrayInstPtr(self)->f_element;
- float _max;
+ if (_sz > 0) {
+ float *_p = __FloatArrayInstPtr(self)->f_element;
+ float _max;
- _max = _p[0];
- if (_sz > 1) {
- int _i;
- float _prev, _this;
+ _max = _p[0];
+ if (_sz > 1) {
+ INT _i;
+ float _prev, _this;
- /* how about inline-mmx-asm for this ... */
- _this = _p[1];
- for (_i=2; _i<_sz; _i++) {
- _prev = _this;
- _this = _p[_i];
- if (_prev > _max) _max = _prev;
- }
- if (_this > _max) _max = _this;
- }
- RETURN (__MKFLOAT(_max));
- }
+ /* how about inline-mmx-asm for this ... */
+ _this = _p[1];
+ for (_i=2; _i<_sz; _i++) {
+ _prev = _this;
+ _this = _p[_i];
+ if (_prev > _max) _max = _prev;
+ }
+ if (_this > _max) _max = _this;
+ }
+ RETURN (__MKFLOAT(_max));
+ }
}
%}.
^ super max
@@ -817,13 +817,13 @@
|f1|
f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 max
+ f1 max
"
"
|f1|
f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 max
+ f1 max
"
!
@@ -832,28 +832,28 @@
redefined for speed"
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
+ INT _sz = __floatArraySize(self);
- if (_sz > 0) {
- float *_p = __FloatArrayInstPtr(self)->f_element;
- float _min;
+ if (_sz > 0) {
+ float *_p = __FloatArrayInstPtr(self)->f_element;
+ float _min;
- _min = _p[0];
- if (_sz > 1) {
- int _i;
- float _prev, _this;
+ _min = _p[0];
+ if (_sz > 1) {
+ INT _i;
+ float _prev, _this;
- /* how about inline-mmx-asm for this ... */
- _this = _p[1];
- for (_i=2; _i<_sz; _i++) {
- _prev = _this;
- _this = _p[_i];
- if (_prev < _min) _min = _prev;
- }
- if (_this < _min) _min = _this;
- }
- RETURN (__MKFLOAT(_min));
- }
+ /* how about inline-mmx-asm for this ... */
+ _this = _p[1];
+ for (_i=2; _i<_sz; _i++) {
+ _prev = _this;
+ _this = _p[_i];
+ if (_prev < _min) _min = _prev;
+ }
+ if (_this < _min) _min = _this;
+ }
+ RETURN (__MKFLOAT(_min));
+ }
}
%}.
^ super min
@@ -868,13 +868,13 @@
|f1|
f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 min
+ f1 min
"
"
|f1|
f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 min
+ f1 min
"
!
@@ -886,51 +886,51 @@
%{
if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
- int _sz = __floatArraySize(self);
- if (_sz > 0) {
- int _i;
- float *_p = __FloatArrayInstPtr(self)->f_element;
- float _min, _max;
+ INT _sz = __floatArraySize(self);
+ if (_sz > 0) {
+ INT _i;
+ float *_p = __FloatArrayInstPtr(self)->f_element;
+ float _min, _max;
- _min = _max = _p[0];
+ _min = _max = _p[0];
#ifdef PRE_4_OCT_2011
- if (_sz > 1) {
- float _this = _p[1];
- float _prev;
+ if (_sz > 1) {
+ float _this = _p[1];
+ float _prev;
- /* how about inline-mmx-asm for this ... */
- for (_i=2; _i<_sz; _i++) {
- _prev = _this;
- _this = _p[_i];
- if (_prev < _min) {
- _min = _prev;
- } else if (_prev > _max) {
- _max = _prev;
- }
- }
- if (_this < _min) {
- _min = _this;
- } else if (_this > _max) {
- _max = _this;
- }
- }
+ /* how about inline-mmx-asm for this ... */
+ for (_i=2; _i<_sz; _i++) {
+ _prev = _this;
+ _this = _p[_i];
+ if (_prev < _min) {
+ _min = _prev;
+ } else if (_prev > _max) {
+ _max = _prev;
+ }
+ }
+ if (_this < _min) {
+ _min = _this;
+ } else if (_this > _max) {
+ _max = _this;
+ }
+ }
#else
- for (_i=_sz-1; _i>0; _i-=2) {
- float _v1 = _p[_i];
- float _v2 = _p[_i-1];
- if (_v1 < _v2) {
- if (_v1 < _min) _min = _v1;
- if (_v2 > _max) _max = _v2;
- } else {
- if (_v2 < _min) _min = _v2;
- if (_v1 > _max) _max = _v1;
- }
- }
+ for (_i=_sz-1; _i>0; _i-=2) {
+ float _v1 = _p[_i];
+ float _v2 = _p[_i-1];
+ if (_v1 < _v2) {
+ if (_v1 < _min) _min = _v1;
+ if (_v2 > _max) _max = _v2;
+ } else {
+ if (_v2 < _min) _min = _v2;
+ if (_v1 > _max) _max = _v1;
+ }
+ }
#endif
- min = __MKFLOAT(_min);
- max = __MKFLOAT(_max);
- RETURN (__ARRAY_WITH2(min, max));
- }
+ min = __MKFLOAT(_min);
+ max = __MKFLOAT(_max);
+ RETURN (__ARRAY_WITH2(min, max));
+ }
}
%}.
^ Array with:(super min) with:(super max)
@@ -939,19 +939,19 @@
|f1|
f1 := (1 to:10000) asFloatArray.
- Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
+ Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
"
"
|f1|
f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 minMax
+ f1 minMax
"
"
|f1|
f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 minMax
+ f1 minMax
"
"Modified (comment): / 07-10-2011 / 13:03:30 / cg"
@@ -980,20 +980,20 @@
if (__isFloats(aFloatVector)
&& (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
&& (__ClassInstPtr(__qClass(aFloatVector))->c_ninstvars == __mkSmallInteger(0))) {
- int __mySize = __floatArraySize(self);
- int __otherSize = __floatArraySize(aFloatVector);
- if (__mySize == __otherSize) {
- float *__p1 = __FloatArrayInstPtr(self)->f_element;
- float *__p2 = __FloatArrayInstPtr(aFloatVector)->f_element;
- float __result = 0.0;
- int __i;
+ INT __mySize = __floatArraySize(self);
+ INT __otherSize = __floatArraySize(aFloatVector);
+ if (__mySize == __otherSize) {
+ float *__p1 = __FloatArrayInstPtr(self)->f_element;
+ float *__p2 = __FloatArrayInstPtr(aFloatVector)->f_element;
+ float __result = 0.0;
+ INT __i;
- /* how about inline-mmx-asm for this ... */
- for (__i=0; __i<__mySize; __i++) {
- __result = __result + (__p1[__i] * __p2[__i]);
- }
- RETURN (__MKFLOAT(__result));
- }
+ /* how about inline-mmx-asm for this ... */
+ for (__i=0; __i<__mySize; __i++) {
+ __result = __result + (__p1[__i] * __p2[__i]);
+ }
+ RETURN (__MKFLOAT(__result));
+ }
}
%}.
@@ -1001,7 +1001,7 @@
mySize = aFloatVector size ifFalse:[^self error:'Must be of equal size'].
result := 0.0.
1 to: mySize do:[:i|
- result := result + ((self at: i) * (aFloatVector at: i)).
+ result := result + ((self at: i) * (aFloatVector at: i)).
].
^result
@@ -1009,7 +1009,7 @@
|v|
v := #(2.0 2.0 1.0) asFloatArray.
- v dot:v.
+ v dot:v.
"
"Created: / 29-05-2007 / 13:13:39 / cg"
@@ -1018,9 +1018,9 @@
!FloatArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.30 2011-11-25 15:38:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.31 2013-01-23 18:03:01 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.30 2011-11-25 15:38:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.31 2013-01-23 18:03:01 cg Exp $'
! !