i like this post (click again to cancel)
0
i dont like this post (click again to cancel) remove favorite mark from this question (click again to restore mark)

Why do both numpy.linalg and scipy.linalg exist? What is the difference? Where is there a difference?

flag offensive community wiki
add comment
1 Answers:
i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

scipy.linalg is a more complete wrapping of Fortran LAPACK using f2py, but both NumPy and SciPy may be using the underlying LAPACK available on your platform if you have installed it along with the header files (-dev or -devel packages on most Linux distributions). One of the design goals of NumPy was to make it buildable without a Fortran compiler, and if you don't have LAPACK available NumPy will use its own implementation. SciPy requires a Fortran compiler to be built, and heavily depends on wrapped Fortran code.

You can check the underlying detected implementation for both of these with show_config:

import numpy as np
import scipy as sc
print np.show_config()
print sc.show_config()

The linalg modules in NumPy and SciPy have some common functions but with different help lines. scipy.linalg contains more, such as functions related to LU decomposition and the Schur decomposition, multiple ways of calculating the pseudoinverse, and matrix transcendentals like the matrix logarithm. Some functions that exist in both have augmented functionality in scipy.linalg; for example scipy.linalg.eig() can take a second matrix argument for solving generalized eigenvalue problems.

Using numpy.linalg (if you can) will likely make your code more portable, since NumPy is easier to install and necessary for using NumPy arrays in the first place. If numpy.linalg can't do what you're looking for, however, try scipy.linalg.

permanent link | flag offensive
asked 2009-08-22 14:42:06
dwf's gravatar image
81
add comment
Your answer:
You are now not logged in but you can answer first and then login
toggle preview

Made with Django.