How to avoid loops for the following matrix manipulcation

조회 수: 1 (최근 30일)
Chuangchuang Sun
Chuangchuang Sun 2018년 1월 25일
편집: Stephen23 2018년 1월 26일
I need to do the following operations on a series of matrix A1,A2,...,A_m\in\reals^{n\times n}, and two vectors c,x\in\reals^{n}.
  • H\in\reals^{n\times n} = \sum_{i=1}{m}(A_i*x)(A_i*x)^T,
  • b\in\reals^{n} = \sum_{i=1}{m}c_i*(A_i*x).
I guess no-loop implementation will be faster. However, I tried and failed. Any ideas, guys?
Appreciate your time in advance!
  댓글 수: 8
James Tursa
James Tursa 2018년 1월 25일
How large is n?
Stephen23
Stephen23 2018년 1월 26일
편집: Stephen23 2018년 1월 26일
Chuangchuang Sun's "Flag" moved here:
n is around 100

댓글을 달려면 로그인하십시오.

답변 (1개)

James Tursa
James Tursa 2018년 1월 25일
편집: James Tursa 2018년 1월 25일
Since the A_i are sparse, you are probably stuck with your loop. Consider storing them as A{i} instead of A_i, however, to make looping easier. And code it such that you do the A{i}*x calculation only once.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by