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?
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.