next up previous contents
Next: # for Vectors Up: Array operations Previous: Default array operations   Contents

Matrix multiplication

This will probably be very confusing. It may be best to just refer back to this when you come across the # and ## commands.

## operator does matrix multiplication. It computes array elements by multiplying the rows of the first array by the columns of the second array. The resulting array has the same number of rows as the first array and the same number of columns as the second array. The second array must have the same number of rows as the first array has columns. E.g.

(a b c)##  (g h)  =   (ag+bi+ck     ah+bj+cl)  
(d e f)    (i j)      (dg+ei+fk     dh+ej+fl)
           (k l)
3columns, 2 rows ## 2 columns, 3 rows = 2columns, 2 rows

The # operator computes array elements by multiplying the columns of the first array by the rows of the second array. The resulting array has the same number of columns as the first array and the same number of rows as the second array. The second array must have the same number of columns as the first array has rows. E.g.

(a b c)#   (g h)  =   (ag+dh bg+ch cg+fh)  
(d e f)    (i j)      (ai+dj bi+ej ci+fj)
           (k l)      (cg+fh ci+fj ck+fl)
3columns, 2 rows # 2 columns, 3 rows = 3columns, 3 rows

BUT when Multiplying Vectors it's different!


next up previous contents
Next: # for Vectors Up: Array operations Previous: Default array operations   Contents
John Marsham 2009-12-07