Using vectorization to replace for-loops may increase Matlab programs’ speed significantly. Is it because the vectorized codes are runned in parallel?
Is vectorization also beneficial for program using NumPy or uBLAS?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“Vectorized” code is usually faster in interpreted environments like Matlab and numpy because the vectorized versions often (but not always) run pre-compiled and optimized code written in C or FORTRAN. Parallel execution may, or may not, play a role in this.
Use vectorization in numpy usually results in performance improvement for this reason – often the routines are compiled C or FORTRAN which run much faster than native python code which must be run on the interpreter. Also numpy, being written largely in C, can sidestep the python global interpreter lock, which can greatly improve responsiveness in python code which uses threads.