I was looking at the MatrixMath library, looking for an outer product function (multiply two vectors to form a matrix). I realised that I could use
MatrixMath::Multiply(mtx_type* A, mtx_type* B, int m, int p, int n, mtx_type* C)
with p set to 1 (1 column in A and 2 row in B), but I find it easier to understand to have an explicit OuterProduct function, which I think is this:
// Outer product
// C = A*B
void OuterProduct(mtx_type* A, mtx_type* B, int m, int n, mtx_type* C)
{
int ra, cb; // ra= Row in vector A and, cb=Column in vector B
for (ra = 0; ra < m; ra++) {
for(cb = 0; cb < n; cb++)
{
// In real money....
// C[ra][cb] = C[ra][cb] + (A[ra] * B[cb]);
C[n * ra + cb] = A[ra] * B[cb];
}
}
}
It would be good to add this to MatrixMath I think, if it is correct, but how is that done officially?