Skip to content

Matrix multiplication

$ Matrix Multiply, mmu

Matrix multiply, dot product

x mmu y    mmu[x;y]
x$y        $[x;y]

Where x and y are both float vectors or matrixes, returns their matrix- or dot-product.

count y must match

  • count x where x is a vector
  • count first x where x is a matrix
q)a:2 4#2 4 8 3 5 6 0 7f
q)b:4 3#"f"$til 12
q)a mmu b
87 104 121
81 99  117

q)c:3 3#2 4 8 3 5 6 0 7 1f
q)1=c mmu inv c
100b
010b
001b

q)(1 2 3f;4 5 6f)$(7 8f;9 10f;11 12f)
58  64
139 154

q)1 2 3f$4 5 6f  /dot product of two vectors
32f

Working in parallel

Use secondary threads via peach.

q)mmu[;b]peach a
87 104 121
81 99  117

Overloads of $
Mathematics
Matrix multiplication