views:

22

answers:

0

A is an MxK matrix, B is a vector of size K, and C is a KxN matrix. What set of BLAS operators should I use to compute the matrix below?

M = A*diag(B)*C

One way to implement this would be using three for loops like below

for (int i=0; i<M; ++i)
    for (int j=0; j<N; ++j)
        for (int k=0; k<K; ++k)
            M(i,j) = A(i,k)*B(k)*C(k,j);

Is it actually worth implementing this in BLAS in order to gain better speed efficiency?