About Computing sequence.
1 回表示 (過去 30 日間)
古いコメントを表示
If i Set a matrix A = (1, 23, 17; -2, 1, 94)
and if there is a matrix B = (0.5; 1.6; -0.3)
and if i want to multiply A and B then put the result in C( C = A * B).
Does the computing sequence occurs simultaneously or sequentially[(1, 23, 17)*(0.5; 1.6; -0.3) first occurs and then (-2, 1, 94)*(0.5; 1.6; -0.3) occurs so that computting time take 2 times compared to simultaneous computting]?
0 件のコメント
採用された回答
Guillaume
2019 年 5 月 17 日
matrices operations in matlab are very optimised, so it's likely that they are parallelised as much as possible. However, implementation details are not documented so you can't know for sure. In any case, whether or not the execution at the processor level occurs in parallel is going to depend on the version of matlab, the type of processor you have and probably the load on said processor.
Why do you care anyway?
2 件のコメント
Stephen23
2019 年 5 月 17 日
編集済み: Stephen23
2019 年 5 月 17 日
"...if my code is vectorized, i can run it faster than using for loop?"
Vectorized operations are generally highly optimized, so in many cases vectorized code may be faster than a loop... in other cases the loop is faster. It depends on the data, the algorithm, how the code was written, the sizes of intermediate arrays, the MATLAB version, etc. etc.
The only way to know for sure is to test it.
But you should be concentrating first on writing clear, simple, and understandable code (which will in turn be easier to check and have fewer bugs). Unless you have written your code very carefully and used the profiler to determine that this particular operation is causing a major bottleneck and your code is going to run millions/billions/trillions/... of iterations, then there is likely little point in premature optimization of your code.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!