[SciPy-user] linalg.qr factorization so slow...

Travis Vaught travis at enthought.com
Fri Aug 24 16:43:24 EDT 2007


On Aug 24, 2007, at 11:58 AM, Stefan van der Walt wrote:

> On Fri, Aug 24, 2007 at 08:19:28AM -0400, Jose Unpingco wrote:
>> I have a 1000  x 1000  matrix. To apply a QR factorization in  
>> Matlab takes less
>> than three seconds. however, when I do scipy.linalg.qr on the same  
>> matrix, it
>> takes 25+ minutes.
>>
>> Why is this? I thought they were running the same LAPACK/ATLAS/ 
>> BLAS libraries
>> underneath.
>
> It is because Enthought's install is not linked to your ATLAS.  You
> may have to compile SciPy yourself.
>
> Cheers
> Stéfan

I think Stefan's on to something--although ATLAS should be  
distributed with the Enthought Edition, I believe.  On Windows XP:

In [14]: import time

In [15]: def time_qr(size=1000):
    ....:     """ time qr for array of shape (size,size) """
    ....:     from numpy import random
    ....:     from scipy.linalg import qr
    ....:     a = random.random((size,size))
    ....:     t1 = time.time()
    ....:     b, c = qr(a, mode='qr')
    ....:     print "size: %s, time: %s" % (size, time.time()-t1)
    ....:

In [16]: time_qr()
size: 1000, time: 1.83299994469

In [17]: time_qr(2000)
size: 2000, time: 12.0770001411

In [18]: time_qr(100)
size: 100, time: 0.00999999046326

In [19]: time_qr(500)
size: 500, time: 0.380999803543

In [20]: time_qr(1000)
size: 1000, time: 1.74199986458

In [21]: time_qr(1500)
size: 1500, time: 5.24699997902

In [22]: import scipy

In [23]: scipy.__version__
Out[23]: '0.5.3.dev3173'

In [24]: import numpy

In [25]: numpy.__version__
Out[25]: '1.0.3'

...snip. some looking for the right config call... just try this one...

In [27]: numpy.__config__.show()
atlas_threads_info:
     libraries = ['lapack', 'lapack', 'f77blas', 'cblas', 'atlas']
     library_dirs = ['d:\\test_atlas']
     language = f77

blas_opt_info:
     libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
     library_dirs = ['d:\\test_atlas']
     define_macros = [('ATLAS_INFO', '"\\"3.6.0\\""')]
     language = c

atlas_blas_threads_info:
     libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
     library_dirs = ['d:\\test_atlas']
     language = c

lapack_opt_info:
     libraries = ['lapack', 'lapack', 'f77blas', 'cblas', 'atlas']
     library_dirs = ['d:\\test_atlas']
     define_macros = [('ATLAS_INFO', '"\\"3.6.0\\""')]
     language = f77

lapack_mkl_info:
   NOT AVAILABLE

blas_mkl_info:
   NOT AVAILABLE

mkl_info:
   NOT AVAILABLE


In [28]:


More information about the SciPy-User mailing list