--- a/DoubleArray.st Tue Apr 22 11:38:04 2003 +0200
+++ b/DoubleArray.st Tue Apr 22 11:39:34 2003 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
ArrayedCollection variableDoubleSubclass:#DoubleArray
instanceVariableNames:''
classVariableNames:''
@@ -81,8 +83,14 @@
"
! !
+!DoubleArray methodsFor:'queries'!
+
+defaultElement
+ ^ Float zero
+! !
+
!DoubleArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.18 1999-03-19 20:42:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/DoubleArray.st,v 1.19 2003-04-22 09:39:34 cg Exp $'
! !
--- a/FloatArray.st Tue Apr 22 11:38:04 2003 +0200
+++ b/FloatArray.st Tue Apr 22 11:39:34 2003 +0200
@@ -443,106 +443,110 @@
"
!
+defaultElement
+ ^ ShortFloat zero
+!
+
max
"return the largest element;
redefined for speed"
%{
- if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
- int _sz = __floatArraySize(self);
+ if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
+ 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;
+ /* 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;
}
- RETURN (__MKFLOAT(_max));
+ if (_this > _max) _max = _this;
}
+ RETURN (__MKFLOAT(_max));
}
+ }
%}.
- ^ super max
+ ^ super max
- "
- |f1|
+ "
+ |f1|
- f1 := (1 to:1000) asFloatArray.
- Time millisecondsToRun:[ 1000 timesRepeat:[ f1 max ] ]
- "
- "
- |f1|
+ f1 := (1 to:1000) asFloatArray.
+ Time millisecondsToRun:[ 1000 timesRepeat:[ f1 max ] ]
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 max
- "
- "
- |f1|
+ f1 := FloatArray withAll:#(1 2 3 4 5).
+ f1 max
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 max
- "
+ f1 := FloatArray withAll:#(5 4 3 2 1).
+ f1 max
+ "
!
min
"return the largest element;
redefined for speed"
%{
- if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
- int _sz = __floatArraySize(self);
+ if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
+ 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;
+ /* 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;
}
- RETURN (__MKFLOAT(_min));
+ if (_this < _min) _min = _this;
}
+ RETURN (__MKFLOAT(_min));
}
+ }
%}.
- ^ super min
+ ^ super min
- "
- |f1|
+ "
+ |f1|
- f1 := (1 to:1000) asFloatArray.
- Time millisecondsToRun:[ 1000 timesRepeat:[ f1 min ] ]
- "
- "
- |f1|
+ f1 := (1 to:1000) asFloatArray.
+ Time millisecondsToRun:[ 1000 timesRepeat:[ f1 min ] ]
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 min
- "
- "
- |f1|
+ f1 := FloatArray withAll:#(1 2 3 4 5).
+ f1 min
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 min
- "
+ f1 := FloatArray withAll:#(5 4 3 2 1).
+ f1 min
+ "
!
minMax
@@ -552,65 +556,65 @@
|min max|
%{
- if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
- int _sz = __floatArraySize(self);
- if (_sz > 0) {
- int _i;
- float *_p = __FloatArrayInstPtr(self)->f_element;
- float _min, _max;
+ if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
+ int _sz = __floatArraySize(self);
+ if (_sz > 0) {
+ int _i;
+ float *_p = __FloatArrayInstPtr(self)->f_element;
+ float _min, _max;
- _min = _max = _p[0];
-
- if (_sz > 1) {
- float _this = _p[1];
- float _prev;
+ _min = _max = _p[0];
- /* 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;
+ 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;
}
}
- min = __MKFLOAT(_min);
- max = __MKFLOAT(_max);
- RETURN (__ARRAY_WITH2(min, max));
+ if (_this < _min) {
+ _min = _this;
+ } else if (_this > _max) {
+ _max = _this;
+ }
}
+ min = __MKFLOAT(_min);
+ max = __MKFLOAT(_max);
+ RETURN (__ARRAY_WITH2(min, max));
}
+ }
%}.
- ^ Array with:super min with:super max
-
- "
- |f1|
+ ^ Array with:(super min) with:(super max)
- f1 := (1 to:1000) asFloatArray.
- Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
- "
- "
- |f1|
+ "
+ |f1|
+
+ f1 := (1 to:1000) asFloatArray.
+ Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(1 2 3 4 5).
- f1 minMax
- "
- "
- |f1|
+ f1 := FloatArray withAll:#(1 2 3 4 5).
+ f1 minMax
+ "
+ "
+ |f1|
- f1 := FloatArray withAll:#(5 4 3 2 1).
- f1 minMax
- "
+ f1 := FloatArray withAll:#(5 4 3 2 1).
+ f1 minMax
+ "
! !
!FloatArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.18 2001-02-28 13:14:13 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.19 2003-04-22 09:39:26 cg Exp $'
! !