Next: , Previous: , Up: Internal Routines   [Contents][Index]


15.5.384 mproduct

mproduct(m1, m2 [, /inner, /outer])

Returns the matrix product of two- or more-dimensional real-valued column-major matrices m1 and m2. The matrix product is calculated across the first two dimensions only. The 1st (column) dimension of m1 must equal the 2nd (row) dimension of m2.

If m1 or m2 have more than two dimensions, then they can be multiplied in “inner” or “outer” fashion, selected by /inner (the default) or /outer, respectively.

By default, or if /inner is selected, then dimensions beyond the first two must be equal in both arguments, and one matrix product of the first two dimensions is calculated for each element of m1 beyond the first two dimension and for the corresponding element of m2.

For example, if x = indgen(dblarr(2,3,4)) and y = indgen(dblarr(5,2,4)), then z = mproduct(x,y) or z = mproduct(x,y,/inner) gets dimensions 5, 3, 4, and z(*,*,i) is equal to mproduct(x(*,*,i),y(*,*,i)).

If /outer is selected, then dimensions beyond the first two do not need to be equal in both arguments, and one matrix product of the first two dimensions is calculated for each possible combination of one element of m1 beyond the first two dimensions and one element of m2 beyond the first two dimensions.

For example, if x = indgen(dblarr(2,3,4) and y = indgen(dblarr(5,2,4), then z = mproduct(x,y,/outer) gets dimensions 5, 3, 4, 4, and z(*,*,i,j) is equal to mproduct(x(*,*,i),y(*,*,j)).

This functions gets called when the # operator is used. x # y is equivalent to mproduct(x,y).

See also: decomp, dsolve, svd