5
$\begingroup$

Possible an open-ended question, but I am wondering if most statistical packages and libraries, for instance, Stata, R, Python's NumPy and MATLAB rely on LAPACK algorithms to perform matrix operations, including inverting a matrix.

$\endgroup$

2 Answers 2

7
$\begingroup$

tl;dr Yes.

But your question doesn't make it clear that you understand what LAPACK is about. LAPACK is both a software as well as an interface. That is, the operations that LAPACK defines are standard enough that they can be replaced by other software, such as ATLAS, MKL, and so on. Another way of looking at this is that any software that does linear algebra implicitly uses an LAPACK-esque interface. Given this, you might also be asking how each of the languages/tools you name instantiates this interface.

Python

Description:

NumPy does not require any external linear algebra libraries to be installed. However, if these are available, NumPy’s setup script can detect them and use them for building. A number of different LAPACK library setups can be used, including optimized LAPACK libraries such as ATLAS, MKL or the Accelerate/vecLib framework on OS X. [link]

How to see your configuration: np.show_config()

R

Description:

The precompiled R distribution that is downloaded from CRAN makes use of the reference BLAS/LAPACK implementation for linear algebra operations, These implementations are built to be stable and cross platform compatible but are not optimized for performance. Most R programmers use these default libraries and are unaware that highly optimized libraries [with BLAS/LAPACK interfaces] are available and switching to these can have a significant perfomance improvement. [link]

How to see your configuration: sessionInfo()

Matlab (But why?)

Description:

In the year 2000, MATLAB migrated to using LAPACK, which is the modern replacement for LINPACK and EISPACK. It is a large, multi-author, Fortran library for numerical linear algebra. LAPACK was originally intended for use on supercomputers because of its ability to operate on several columns of a matrix at a time. The speed of LAPACK routines is closely connected to the speed of the Basic Linear Algebra Subroutines (BLAS). The BLAS version is typically hardware-specific and highly optimized. [link]

Another Description:

The three versions are:

Current (blue): The numerics library included with MATLAB version 5.3

Reference (green): A new numerics library based on LAPACK and machine-independent Fortran Reference BLAS

Optimized (red): A new numerics library based on LAPACK and BLAS optimized for each particular computer.

[link]

How to see you configuration: version -lapack

Stata

Who knows? I suggest using R.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks. What I meant is, for instance, the distinction between Python's 'scipy.linalg' and 'numpy.linalg' matrix inversion functions differences. From the scipy documentation: "scipy.linalg documecontains all the functions in numpy.linalg. plus some other more advanced ones not contained in numpy.linalg Another advantage of using scipy.linalg over numpy.linalg is that it is always compiled with BLAS/LAPACK support, while for numpy this is optional. Therefore, the scipy version might be faster depending on how numpy was installed." $\endgroup$ Commented Oct 15, 2019 at 16:23
2
$\begingroup$

To add to the above, Stata, in its matrix programming language Mata, uses BLAS and LAPACK. It includes the reference implementations on all platforms, as well as Intel's MKL implementations on platforms where it's available (x86 and amd64).

Source: Stata documentation

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.