What is the fastest way to perform x'Ay ?

2 views (last 30 days)
Pierson
Pierson on 8 Aug 2015
Answered: James Tursa on 8 Aug 2015
In my code I have a bottleneck when I try to perform the following calculation: Given a square matrix A and vectors of equal length x,y (assume all dimensions are compatible), compute
result = x'*A*y
Is there a way that speeds this up that is simple to implement?

Answers (1)

James Tursa
James Tursa on 8 Aug 2015
I don't know that there is anything faster than what you have written. A matrix multiply followed by an inner product using BLAS routines in the background. How large are your variables? Is this calculation in a loop where everything changes at each iteration, or do some of the variables remain constant during the loop?

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!