Can I make this one line of matrix multiplication and addition code more efficient?

80 views Asked by At

This one line of code is currently taking ~50% of the processing time. Is there a more efficient way of processing this line?

o = o + sum(sum(im.*p))*p/sum(sum(p)));

The variables (im,p & o) are all 2D matrices of size 1000x1000 (ish).

  • 'im' is a fixed matrix that has constant values
  • 'p' is a sparse matrix that changes on each iteration
  • 'o' is a matrix that increases on each iteration that is reset after 1000(ish) iterations of the code block.

Let me know if you need more information, or I need to clarify anything I've said. Thank you for your answers/feedback in advance.

0

There are 0 answers