Why does a'*b yield a (slightly) different result than dot(a,b)?

5 ビュー (過去 30 日間)
EQ
EQ 2017 年 11 月 28 日
回答済み: Walter Roberson 2017 年 11 月 28 日
I was working an building a matrix entry-wise and checking two different methods against each other and eventually found that dot(a,b) is giving me a different answer than a'*b, where a and b are both real 9948x1 column vectors. I can see that the implementation of dot uses conj(a)*b, but my vectors are real. In one example, dot(a,b) = -1.0351e-11 and a'*b = -8.6402e-12.
I think it's likely a floating point precision issue, but I'm curious about the implementation of the "*" operator and what might be leading to it. Can anyone shed some light on this?
  3 件のコメント
EQ
EQ 2017 年 11 月 28 日
I'm attaching two vectors a and b that show the issue. I'm using R2015b.
Guillaume
Guillaume 2017 年 11 月 28 日
Indeed with your inputs I get the same discrepancy in R2017b. No idea why.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 28 日
For sufficiently large arrays, a'*b is going to invoke the high performance libraries, which are going to calculate the multiplications in multiple threads, doing partial summations, before eventually doing a final summation. Because the summations could be done in a different order than sum(conj(a).*b), the round-off can be different.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by