next up previous contents
Next: Matrix multiplication Up: Array operations Previous: Array operations   Contents

Default array operations

Array + scalar ; Adds scalar value to all elements. E.g.
IDL> print,[2,1,3]+2
       4       3       5
Array * scalar ; Multiplies all elements by scalar. E.g.
IDL> print,[2,1,3]*2
       4       2       6
Array * Array ; Multiplies each element in the first array by the corresponding element in the second array. Eg.
IDL> print,[[1,2,3],[4,5,6]]*[[1,2,3],[4,5,6]]
       1       4       9
      16      25      36 ; OR 
IDL> print,[[1,2,3],[4,5,6]]*[1,2,3]
       1       4       9
because the output is just the size of the smaller array i.e. matrix multiplication is NOT the default



John Marsham 2009-12-07