フィルターのクリア

What exactly is vectorization doing

2 ビュー (過去 30 日間)
Jiayun Liu
Jiayun Liu 2022 年 10 月 13 日
コメント済み: Jiayun Liu 2022 年 10 月 13 日
I am curious why does vectorization reduces computational time? Is matlab using multiple cores when I vectorize? If that is the case, does it mean that vectorized codes will always run faster the more cores you have?

採用された回答

Steven Lord
Steven Lord 2022 年 10 月 13 日
When you go grocery shopping do you go from your house to the store, pick up one item, go from the store to your house, and repeat that process for each item?
Or do you make a list, go from your house to the store, pick up all the items on the list in one trip, and go from the store to your house?
Avoiding the overhead of repeated trips between your house and the store is a good thing. But if the "one item" you're going to the store to pick up is a large piece of furniture, it may make sense to make multiple trips because fitting the item and anything else in your car would be difficult. That would represent a case where vectorization could be slower than non-vectorized code because of memory or other resource constraints.
Many functions in MATLAB are multithreaded if the inputs are "large enough" (and no, I'm not going to quantify what that means. It can be different for different functions and can change from release to release.)
  1 件のコメント
Jiayun Liu
Jiayun Liu 2022 年 10 月 13 日
I see. Thank you very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by