Why are the built-in functions in Matlab so much faster then the ones that you write yourself?
3 Answers
yes, matlab
alikes usually use wrapper functions for linear algebra library routines written in a low level language (usually Fortran
) such as BLAS
,ATLAS
or LAPACK
.
you can read more about this in here
also see this question if you're curious how much overhead does function wrapping costs (basically none). results are for C++
, python
and numpy
but I believe they are applied to matlab as well.
In short, because they will be written in native code (C/C++), so that allows the developers access to assembler optimisations on the data, and also the ability to use SSE and similar to try and parallelise the operations within the CPU.

- 9,562
- 1
- 34
- 41
Yes, in all likelihood those matrix functions are written in C, C++ or even assembly. The C and C++ code can even be taking advantage of SIMD (single instruction multiple data) processes like SSE (from intel).

- 1,692
- 3
- 12
- 21