6

Why are the built-in functions in Matlab so much faster then the ones that you write yourself?

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
Aamir Abro
  • 838
  • 12
  • 24

3 Answers3

10

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.

Community
  • 1
  • 1
none
  • 11,793
  • 9
  • 51
  • 87
1

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.

slugonamission
  • 9,562
  • 1
  • 34
  • 41
1

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).

Lee Jacobs
  • 1,692
  • 3
  • 12
  • 21