Why are the built-in functions in Matlab so much faster then the ones that you write yourself?
MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming.
MATLAB: The MATLAB programming language is part of the commercial MATLAB software [2] that is often employed in research and industry and is an example of a high-level “scripting” or “4th generation” language.
The MATLAB application is built around the MATLAB programming language. Common usage of the MATLAB application involves using the "Command Window" as an interactive mathematical shell or executing text files containing MATLAB code.
In MATLAB classes, there is no equivalent to C++ templates or Java generics. However, MATLAB is weakly typed and it is possible to write functions and classes that work with different types of data. MATLAB classes do not support overloading functions using different signatures for the same function name.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With