title: numpy's QR appears faster than scipy's - why?
body: <p>For some reason, numpy's QR decomposition is always faster than scipy's which seems strange because scipy is supposed to include all of numpy plus more advanced features. Any idea why?</p>
  
  <pre><code>import numpy.linalg as nla
  import scipy.linalg as la
  A = np.random.randn(4000,4000)
  
  %timeit -n 3 -r 3 Q,R = nla.qr(A)
  %timeit -n 3 -r 3 Q,R = la.qr(A)
  %timeit -n 3 -r 3 Q,R = nla.qr(A)
  %timeit -n 3 -r 3 Q,R = la.qr(A)
  </code></pre>
  
  <blockquote>
    <p>3 loops, best of 3: 1.17 s per loop</p>
    
    <p>3 loops, best of 3: 1.21 s per loop</p>
    
    <p>3 loops, best of 3: 1.05 s per loop</p>
    
    <p>3 loops, best of 3: 1.21 s per loop</p>
  </blockquote>
  
  <p>The difference is more noticeable with mode="raw".</p>
  
  <pre><code>%timeit -n 3 -r 3 Q = nla.qr(A, mode='raw')
  %timeit -n 3 -r 3 Q = la.qr(A, mode='raw')
  %timeit -n 3 -r 3 Q = nla.qr(A, mode='raw')
  %timeit -n 3 -r 3 Q = la.qr(A, mode='raw')
  </code></pre>
  
  <blockquote>
    <p>3 loops, best of 3: 440 ms per loop</p>
    
    <p>3 loops, best of 3: 612 ms per loop</p>
    
    <p>3 loops, best of 3: 436 ms per loop</p>
    
    <p>3 loops, best of 3: 758 ms per loop</p>
  </blockquote>
  
  <p>I'm using Intel MKL for both, and I have the latest dev versions</p>
  
  <p>numpy version: 1.11.0.dev0+90a1a9f</p>
  
  <p>scipy version: 0.17.0.dev0+8003fab</p>
  
  <pre><code>NumPy config:
  blas_opt_info:
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      libraries = ['mkl_rt', 'pthread']
  mkl_info:
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      libraries = ['mkl_rt', 'pthread']
  lapack_opt_info:
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      libraries = ['mkl_rt', 'pthread']
  openblas_lapack_info:
    NOT AVAILABLE
  lapack_mkl_info:
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      libraries = ['mkl_rt', 'pthread']
  blas_mkl_info:
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      libraries = ['mkl_rt', 'pthread']
  
  SciPy config:
  blas_opt_info:
      libraries = ['mkl_rt', 'pthread']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
  mkl_info:
      libraries = ['mkl_rt', 'pthread']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
  blas_mkl_info:
      libraries = ['mkl_rt', 'pthread']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
  openblas_lapack_info:
    NOT AVAILABLE
  lapack_mkl_info:
      libraries = ['mkl_rt', 'pthread']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
  lapack_opt_info:
      libraries = ['mkl_rt', 'pthread']
      include_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/include']
      define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
      library_dirs = ['/opt/intel/compilers_and_libraries_2016/linux/mkl/lib/intel64']
  </code></pre>