Element-wise multiplication where 'elements' are matrices and vectors

4 ビュー (過去 30 日間)
Daniel Lyddy
Daniel Lyddy 2011 年 2 月 20 日
I have a 'stack' of K n-by-1 vectors x that I would like to multiply by a 'stack' of K n-by-n vectors A, to form a 'stack' of K n-by-1 output vectors y such that
y((k-1)*n+1:k*n) = A((k-1)*n+1:k*n, 1:n) * x((k-1)*n+1:k*n)
where k runs from 1 to K.
I would like to do this without looping through k. I thought of using the 'blockproc' function, but it only seems to be able to blockify one argument, and I need to blockify two (both A and x). I thought of trying to turn A into a Kn-by-Kn block diagonal matrix, then multiplying it directly by x (which is Kn-by-1), but K could be quite large and there does not seem to be a sparse version of blkdiag. Finally, bsxfun does not seem to fit this problem.
Any ideas?

回答 (1 件)

Bruno Luong
Bruno Luong 2011 年 2 月 20 日

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by