How to avoid loops for the following matrix manipulcation

1 Ansicht (letzte 30 Tage)
Chuangchuang Sun
Chuangchuang Sun am 25 Jan. 2018
Bearbeitet: Stephen23 am 26 Jan. 2018
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 Kommentare
Stephen23
Stephen23 am 26 Jan. 2018
Bearbeitet: Stephen23 am 26 Jan. 2018
Chuangchuang Sun's "Flag" moved here:
n is around 100

Melden Sie sich an, um zu kommentieren.

Antworten (1)

James Tursa
James Tursa am 25 Jan. 2018
Bearbeitet: James Tursa am 25 Jan. 2018
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.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by