2

Whats the difference between JAMA: Matrix.times() vs Matrix.arrayTimes() in JAMA (a java library for matrix calculations)

If I have a d dimension vector x and a k dimension vector z and I want to get the xz^T (x into z transpose) should I use Matrix.times or Matrix.arrayTimes?

How can I calculate this multiplication using JAMA?

user77005
  • 1,769
  • 4
  • 18
  • 26

1 Answers1

1

arrayTimes is simply element by element multiplication

C[i][j] = A[i][j] * B[i][j];

(treated as corresponding individual numbers)

while times is the matrix multiplication where each element of the product is the sum of the products of corresponding row-columns.

The dimensions must match as per what you want to achieve.

Given your problem of x z^T the only viable solution is to turn these into dx1 and kx1 matrices respectively and perform x.times(z.transpose()). The result will be a matrix of d x k dimensions.

gpasch
  • 2,672
  • 3
  • 10
  • 12