About Computing sequence.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Guillaume
il 17 Mag 2019
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 Commenti
Stephen23
il 17 Mag 2019
Modificato: Stephen23
il 17 Mag 2019
"...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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!