필터 지우기
필터 지우기

More efficient dot product function.

조회 수: 19 (최근 30일)
Andrew
Andrew 2013년 7월 1일
Hello,
I am just wondering if anyone knows a more efficient function than the dot from MATLAB. I am running a very robust simulator that needs to compute over 3 million dot products (and possibly even more for different cases) throughout the course of the simulation. This leads to the dot products taking up the second most amount of time out of the many functions called by the simulator. I suspect that a lot of the time spent in the dot function is being wasted checking to make sure the vectors are properly sized.
Thanks for your help!

채택된 답변

Hugo
Hugo 2013년 7월 1일
Are you using the function dot(x,y) ?
If that's so, better use
x'*y (assuming that x and y are column vectors)
In my computer, x'*y is twice faster than sum(x.*y) and twenty times faster than dot(x,y). Good luck.
  댓글 수: 1
Andrew
Andrew 2013년 7월 1일
Thanks, I was considering that but wasn't entirely sure about it!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Shashank Prasanna
Shashank Prasanna 2013년 7월 1일
BSXFUN is the most efficient way to do element wise dot operations:

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by