62 #(1 2 3 4) asFloatArray * 3 |
62 #(1 2 3 4) asFloatArray * 3 |
63 #(1 2 3 4) asFloatArray * #(1 2 3 4) asFloatArray |
63 #(1 2 3 4) asFloatArray * #(1 2 3 4) asFloatArray |
64 " |
64 " |
65 ! |
65 ! |
66 |
66 |
67 *= anObject |
|
68 "multiply the argument into the receiver (destructive). |
|
69 The argument may either be a scalar or another vector" |
|
70 |
|
71 ^ anObject isNumber |
|
72 ifTrue:[self primMulScalar: anObject asFloat] |
|
73 ifFalse:[self primMulArray: anObject] |
|
74 |
|
75 " |
|
76 |f| |
|
77 |
|
78 f := #(1 2 3 4) asFloatArray. |
|
79 f *= 3. |
|
80 f |
|
81 " |
|
82 " |
|
83 |f| |
|
84 |
|
85 f := #(1 2 3 4) asFloatArray. |
|
86 f *= #(1 2 3 4) asFloatArray. |
|
87 f |
|
88 " |
|
89 ! |
|
90 |
|
91 + anObject |
67 + anObject |
92 "return the sum of the receiver and the argument. |
68 "return the sum of the receiver and the argument. |
93 The argument may either be a scalar or another vector" |
69 The argument may either be a scalar or another vector" |
94 |
70 |
95 ^ self clone += anObject |
71 ^ self clone += anObject |
98 #(1 2 3 4) asFloatArray + 3 |
74 #(1 2 3 4) asFloatArray + 3 |
99 #(1 2 3 4) asFloatArray + #(1 2 3 4) asFloatArray |
75 #(1 2 3 4) asFloatArray + #(1 2 3 4) asFloatArray |
100 " |
76 " |
101 ! |
77 ! |
102 |
78 |
103 += anObject |
|
104 "add the argument into the receiver (destructive). |
|
105 The argument may either be a scalar or another vector" |
|
106 |
|
107 ^ anObject isNumber |
|
108 ifTrue:[self primAddScalar: anObject asFloat] |
|
109 ifFalse:[self primAddArray: anObject] |
|
110 |
|
111 " |
|
112 |f| |
|
113 |
|
114 f := #(1 2 3 4) asFloatArray. |
|
115 f += 3. |
|
116 f |
|
117 " |
|
118 " |
|
119 |f| |
|
120 |
|
121 f := #(1 2 3 4) asFloatArray. |
|
122 f += #(1 2 3 4) asFloatArray. |
|
123 f |
|
124 " |
|
125 ! |
|
126 |
|
127 - anObject |
79 - anObject |
128 "return the difference of the receiver and the argument. |
80 "return the difference of the receiver and the argument. |
129 The argument may either be a scalar or another vector" |
81 The argument may either be a scalar or another vector" |
130 |
82 |
131 ^ self clone -= anObject |
83 ^ self clone -= anObject |
136 " |
88 " |
137 |
89 |
138 "Created: / 30-05-2007 / 17:41:46 / cg" |
90 "Created: / 30-05-2007 / 17:41:46 / cg" |
139 ! |
91 ! |
140 |
92 |
141 -= anObject |
|
142 "subtract the argument from the receiver (destructive). |
|
143 The argument may either be a scalar or another vector" |
|
144 |
|
145 ^ anObject isNumber |
|
146 ifTrue:[self primSubtractScalar: anObject asFloat] |
|
147 ifFalse:[self primSubtractArray: anObject] |
|
148 |
|
149 " |
|
150 |f| |
|
151 |
|
152 f := #(1 2 3 4) asFloatArray. |
|
153 f -= 3. |
|
154 f |
|
155 " |
|
156 " |
|
157 |f| |
|
158 |
|
159 f := #(1 2 3 4) asFloatArray. |
|
160 f += #(1 2 3 4) asFloatArray. |
|
161 f |
|
162 " |
|
163 |
|
164 "Created: / 30-05-2007 / 17:42:13 / cg" |
|
165 ! |
|
166 |
|
167 / anObject |
93 / anObject |
168 "return the division of the receiver and the argument. |
94 "return the division of the receiver and the argument. |
169 The argument may either be a scalar or another vector" |
95 The argument may either be a scalar or another vector" |
170 |
96 |
171 ^ self clone /= anObject |
97 ^ self clone /= anObject |
174 #(1 2 3 4) asFloatArray / 3 |
100 #(1 2 3 4) asFloatArray / 3 |
175 #(1 2 3 4) asFloatArray / #(1 2 3 4) asFloatArray |
101 #(1 2 3 4) asFloatArray / #(1 2 3 4) asFloatArray |
176 " |
102 " |
177 |
103 |
178 "Created: / 30-05-2007 / 17:46:05 / cg" |
104 "Created: / 30-05-2007 / 17:46:05 / cg" |
179 ! |
|
180 |
|
181 /= anObject |
|
182 "divide the argument into the receiver (destructive). |
|
183 The argument may either be a scalar or another vector" |
|
184 |
|
185 ^ anObject isNumber |
|
186 ifTrue:[self primDivScalar: anObject asFloat] |
|
187 ifFalse:[self primDivArray: anObject] |
|
188 |
|
189 "Modified: / 30-05-2007 / 17:45:46 / cg" |
|
190 ! |
105 ! |
191 |
106 |
192 abs |
107 abs |
193 ^ self clone primAbs |
108 ^ self clone primAbs |
194 |
109 |
577 f1 -= 2. |
492 f1 -= 2. |
578 Transcript showCR:f1. |
493 Transcript showCR:f1. |
579 " |
494 " |
580 |
495 |
581 "Created: / 30-05-2007 / 17:43:06 / cg" |
496 "Created: / 30-05-2007 / 17:43:06 / cg" |
|
497 ! ! |
|
498 |
|
499 !FloatArray methodsFor:'arithmetic destructive'! |
|
500 |
|
501 *= anObject |
|
502 "multiply the argument into the receiver (destructive). |
|
503 The argument may either be a scalar or another vector" |
|
504 |
|
505 ^ anObject isNumber |
|
506 ifTrue:[self primMulScalar: anObject asFloat] |
|
507 ifFalse:[self primMulArray: anObject] |
|
508 |
|
509 " |
|
510 |f| |
|
511 |
|
512 f := #(1 2 3 4) asFloatArray. |
|
513 f *= 3. |
|
514 f |
|
515 " |
|
516 " |
|
517 |f| |
|
518 |
|
519 f := #(1 2 3 4) asFloatArray. |
|
520 f *= #(1 2 3 4) asFloatArray. |
|
521 f |
|
522 " |
|
523 ! |
|
524 |
|
525 += anObject |
|
526 "add the argument into the receiver (destructive). |
|
527 The argument may either be a scalar or another vector" |
|
528 |
|
529 ^ anObject isNumber |
|
530 ifTrue:[self primAddScalar: anObject asFloat] |
|
531 ifFalse:[self primAddArray: anObject] |
|
532 |
|
533 " |
|
534 |f| |
|
535 |
|
536 f := #(1 2 3 4) asFloatArray. |
|
537 f += 3. |
|
538 f |
|
539 " |
|
540 " |
|
541 |f| |
|
542 |
|
543 f := #(1 2 3 4) asFloatArray. |
|
544 f += #(1 2 3 4) asFloatArray. |
|
545 f |
|
546 " |
|
547 ! |
|
548 |
|
549 -= anObject |
|
550 "subtract the argument from the receiver (destructive). |
|
551 The argument may either be a scalar or another vector" |
|
552 |
|
553 ^ anObject isNumber |
|
554 ifTrue:[self primSubtractScalar: anObject asFloat] |
|
555 ifFalse:[self primSubtractArray: anObject] |
|
556 |
|
557 " |
|
558 |f| |
|
559 |
|
560 f := #(1 2 3 4) asFloatArray. |
|
561 f -= 3. |
|
562 f |
|
563 " |
|
564 " |
|
565 |f| |
|
566 |
|
567 f := #(1 2 3 4) asFloatArray. |
|
568 f += #(1 2 3 4) asFloatArray. |
|
569 f |
|
570 " |
|
571 |
|
572 "Created: / 30-05-2007 / 17:42:13 / cg" |
|
573 ! |
|
574 |
|
575 /= anObject |
|
576 "divide the argument into the receiver (destructive). |
|
577 The argument may either be a scalar or another vector" |
|
578 |
|
579 ^ anObject isNumber |
|
580 ifTrue:[self primDivScalar: anObject asFloat] |
|
581 ifFalse:[self primDivArray: anObject] |
|
582 |
|
583 "Modified: / 30-05-2007 / 17:45:46 / cg" |
582 ! ! |
584 ! ! |
583 |
585 |
584 !FloatArray methodsFor:'copying'! |
586 !FloatArray methodsFor:'copying'! |
585 |
587 |
586 clone |
588 clone |