FloatArray.st
changeset 12577 a3224998ea6c
parent 11212 8a6590cc1f4a
child 13707 a8f395adfac2
--- a/FloatArray.st	Tue Dec 01 23:08:29 2009 +0100
+++ b/FloatArray.st	Tue Dec 01 23:11:19 2009 +0100
@@ -64,30 +64,6 @@
     "
 !
 
-*= anObject
-    "multiply the argument into the receiver (destructive).
-     The argument may either be a scalar or another vector"
-
-    ^ anObject isNumber
-                ifTrue:[self primMulScalar: anObject asFloat]
-                ifFalse:[self primMulArray: anObject]
-
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f *= 3.
-     f         
-    "
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f *= #(1 2 3 4) asFloatArray.
-     f     
-    "
-!
-
 + anObject
     "return the sum of the receiver and the argument.
      The argument may either be a scalar or another vector"
@@ -100,30 +76,6 @@
     "
 !
 
-+= anObject
-    "add the argument into the receiver (destructive).
-     The argument may either be a scalar or another vector"
-
-    ^ anObject isNumber
-            ifTrue:[self primAddScalar: anObject asFloat]
-            ifFalse:[self primAddArray: anObject]
-
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f += 3.
-     f         
-    "
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f += #(1 2 3 4) asFloatArray.
-     f      
-    "
-!
-
 - anObject
     "return the difference of the receiver and the argument.
      The argument may either be a scalar or another vector"
@@ -138,32 +90,6 @@
     "Created: / 30-05-2007 / 17:41:46 / cg"
 !
 
--= anObject
-    "subtract the argument from the receiver (destructive).
-     The argument may either be a scalar or another vector"
-
-    ^ anObject isNumber
-            ifTrue:[self primSubtractScalar: anObject asFloat]
-            ifFalse:[self primSubtractArray: anObject]
-
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f -= 3.
-     f         
-    "
-    "
-     |f|
-
-     f := #(1 2 3 4) asFloatArray.
-     f += #(1 2 3 4) asFloatArray.
-     f      
-    "
-
-    "Created: / 30-05-2007 / 17:42:13 / cg"
-!
-
 / anObject
     "return the division of the receiver and the argument.
      The argument may either be a scalar or another vector"
@@ -178,17 +104,6 @@
     "Created: / 30-05-2007 / 17:46:05 / cg"
 !
 
-/= anObject
-    "divide the argument into the receiver (destructive).
-     The argument may either be a scalar or another vector"
-
-    ^ anObject isNumber
-        ifTrue:[self primDivScalar: anObject asFloat]
-        ifFalse:[self primDivArray: anObject]
-
-    "Modified: / 30-05-2007 / 17:45:46 / cg"
-!
-
 abs
     ^ self clone primAbs
 
@@ -581,6 +496,93 @@
     "Created: / 30-05-2007 / 17:43:06 / cg"
 ! !
 
+!FloatArray methodsFor:'arithmetic destructive'!
+
+*= anObject
+    "multiply the argument into the receiver (destructive).
+     The argument may either be a scalar or another vector"
+
+    ^ anObject isNumber
+            ifTrue:[self primMulScalar: anObject asFloat]
+            ifFalse:[self primMulArray: anObject]
+
+    "
+     |f|
+
+     f := #(1 2 3 4) asFloatArray.
+     f *= 3.
+     f         
+    "
+    "
+     |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"
+
+    ^ anObject isNumber
+            ifTrue:[self primAddScalar: anObject asFloat]
+            ifFalse:[self primAddArray: anObject]
+
+    "
+     |f|
+
+     f := #(1 2 3 4) asFloatArray.
+     f += 3.
+     f         
+    "
+    "
+     |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"
+
+    ^ anObject isNumber
+            ifTrue:[self primSubtractScalar: anObject asFloat]
+            ifFalse:[self primSubtractArray: anObject]
+
+    "
+     |f|
+
+     f := #(1 2 3 4) asFloatArray.
+     f -= 3.
+     f         
+    "
+    "
+     |f|
+
+     f := #(1 2 3 4) asFloatArray.
+     f += #(1 2 3 4) asFloatArray.
+     f      
+    "
+
+    "Created: / 30-05-2007 / 17:42:13 / cg"
+!
+
+/= anObject
+    "divide the argument into the receiver (destructive).
+     The argument may either be a scalar or another vector"
+
+    ^ anObject isNumber
+            ifTrue:[self primDivScalar: anObject asFloat]
+            ifFalse:[self primDivArray: anObject]
+
+    "Modified: / 30-05-2007 / 17:45:46 / cg"
+! !
+
 !FloatArray methodsFor:'copying'!
 
 clone
@@ -697,6 +699,8 @@
     "
 ! !
 
+
+
 !FloatArray methodsFor:'queries'!
 
 absMax
@@ -751,8 +755,8 @@
 !
 
 length
-    "Return the length of the receiver 
-     (that is the length of teh vector from 0.0 @ 0.0 @ ... @ 0.0
+    "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
@@ -929,8 +933,12 @@
     "
 !
 
+numFloats
+    ^ self size
+!
+
 squaredLength
-    "Return the squared length of the receiver"
+    "Return the squared length of the receiver interpreted as vector"
 
     ^ self dot: self
 ! !
@@ -986,5 +994,9 @@
 !FloatArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.25 2008-10-14 08:01:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.26 2009-12-01 22:11:19 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.26 2009-12-01 22:11:19 cg Exp $'
 ! !