I am using eigs function from scipy.sparse.linalg module and found some inconsistent results. Running twice the same code gives different results, ie, the output of np.allclose is False. Can anyone explain why is that?
from scipy.sparse.linalg import eigs
from scipy.sparse import spdiags
import numpy as np
n1 = 100
x, dx = linspace(0, 2, n1, retstep=True)
e1 = ones(n1)
A = 1./(dx**2)*spdiags([e1, -2*e1, e1], [-1,0,1], n1, n1)
np.allclose(eigs(A, 90)[0], eigs(A, 90)[0])
The example in IPython can be seen here (Sorry don't know how to post IPython output)
Edit 1:
It is not a matter of sorting the eigenvalues as suggested by @Kh40tiK. See here.
Edit 2:
After trying different versions of Scipy and running the script posted by @Kh40tiK with an additional call to scipy.show_config(), it seems that the SciPy version compiled with MKL is the one at fault.
With MKL:
2.7.6 |Anaconda 1.9.1 (64-bit)| (default, Jan 17 2014, 10:13:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]
('numpy:', '1.8.1')
('scipy:', '0.13.3')
umfpack_info:
NOT AVAILABLE
lapack_opt_info:
libraries = ['mkl_lapack95_lp64', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/home/jpsilva/anaconda/lib']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/home/jpsilva/anaconda/include']
blas_opt_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/home/jpsilva/anaconda/lib']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/home/jpsilva/anaconda/include']
openblas_info:
NOT AVAILABLE
lapack_mkl_info:
libraries = ['mkl_lapack95_lp64', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/home/jpsilva/anaconda/lib']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/home/jpsilva/anaconda/include']
blas_mkl_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/home/jpsilva/anaconda/lib']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/home/jpsilva/anaconda/include']
mkl_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/home/jpsilva/anaconda/lib']
efine_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/home/jpsilva/anaconda/include']
False
False
False
False
False
False
False
False
Without MKL:
2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1]
('numpy:', '1.8.1')
('scipy:', '0.13.3')
umfpack_info:
NOT AVAILABLE
atlas_threads_info:
NOT AVAILABLE
blas_opt_info:
libraries = ['f77blas', 'cblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base']
define_macros = [('ATLAS_INFO', '"\\"3.10.1\\""')]
language = c
include_dirs = ['/usr/include/atlas']
atlas_blas_threads_info:
NOT AVAILABLE
openblas_info:
NOT AVAILABLE
lapack_opt_info:
libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base/atlas', '/usr/lib/atlas-base']
define_macros = [('ATLAS_INFO', '"\\"3.10.1\\""')]
language = f77
include_dirs = ['/usr/include/atlas']
atlas_info:
libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base/atlas', '/usr/lib/atlas-base']
define_macros = [('ATLAS_INFO', '"\\"3.10.1\\""')]
language = f77
include_dirs = ['/usr/include/atlas']
lapack_mkl_info:
NOT AVAILABLE
blas_mkl_info:
NOT AVAILABLE
atlas_blas_info:
libraries = ['f77blas', 'cblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base']
define_macros = [('ATLAS_INFO', '"\\"3.10.1\\""')]
language = c
include_dirs = ['/usr/include/atlas']
mkl_info:
NOT AVAILABLE
True
False
True
False
True
False
True
False