What is the fastest way to perform x'Ay ?
Show older comments
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
on 8 Aug 2015
1 vote
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 Creating and Concatenating Matrices 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!