Fast celllarray by matrix multiplication

67 views Asked by At

I have a long (~7000) cellarray containing each a 3x3 matrix. I would like to premultiply and post-multiply each of those matrices by the same 3-dimensional vector a. This operation could be expressed as:

[a1 a2 a3]'*M*[a1 a2 a3] , 

where a = [a1 a2 a3]

My question is: How can I implement this in a fast way? I have tried with a simple for loop and it results to be much faster than using cellfun after reshaping the vector a in as many 3x3 matrices we have and converting it to a cell array. Any idea?

EDIT: maybe the cell array containing the 3x3 matrices could be expressed in another form so it is possible to compute the operation in a fully vectorized way.

0

There are 0 answers