objarray : scale

objarray scale <obj> <factor> ?<index>?

Multiply by $factor all array items.

<obj> the objarray to be modified

<factor> a real value to multiply all values of the array

<index> optional integer (starting from 0) to multiply only this component of the array

The array doesn't change its type, e.g. an array of integers multiplied by a real factor will truncate the result again as integer.

Warning: the values of <obj> itself are modified, without creating another copy of the object

e.g.

set obj [objarray new doublearray -values {3.5 2.1 0.3 3.5 2.6 0.3}]
-> 3.5 2.1 0.3 3.5 2.6 0.3
objarray scale $obj 2.5
-> 8.75 5.25 0.75 8.75 6.5 0.75