0

I have a matrix S(n x m) and a vector Sigma(n), and I would like to multiply each row S(i) by Sigma(i).

I have thought of 3 things : -> Convert Sigma to a square diagonal matrix and compute S = Sigma * S, but it seems the functions exist only for general or triangular matrix... -> Multiply each line by a scalar Sigma[i] using a DSCAL, in a loop -> mkl_ddiamm, but it seems kinda obscure to me.

Any advices on how I should implement that ? Thank you !

  • Your questions is similar to [this question](http://stackoverflow.com/questions/29472362/how-to-perform-vector-matrix-multiplication-with-blas). – Timothy Brown May 27 '16 at 20:30
  • Hello, I'd still like to have the S matrix as output, so I can't just multiply S and Sigma, or am I wrong ? More formally, I'd like to multiply S with a Diagonal matrix of eigenvalues Sigma[0...n-1]. – user3821901 May 27 '16 at 20:39

1 Answers1

2

It is a very simple operation that MKL/BLAS does not provide a function for it. You could implement it by yourself with for loops.

for(int i=0; i<nrow; ++i) {
  for(int j=0; j<ncols; ++j) {
    s[i][j] += sigma[i];
  }
}
kangshiyin
  • 9,681
  • 1
  • 17
  • 29