# [Scipy-tickets] [SciPy] #1458: lu_factor gives different results, depending on whether the input is C or Fortran contiguous (also affects lu_solve)

SciPy Trac scipy-tickets@scipy....
Thu Jun 9 14:39:58 CDT 2011

```#1458: lu_factor gives different results, depending on whether the input is C or
Fortran contiguous (also affects lu_solve)
--------------------------+-------------------------------------------------
Reporter:  mike.wimmer   |       Owner:  somebody
Type:  defect        |      Status:  new
Priority:  normal        |   Milestone:
Component:  scipy.linalg  |     Version:  0.9.0
Keywords:                |
--------------------------+-------------------------------------------------

Comment(by mike.wimmer):

I think I traced the problem down a bit: In the end, lu_factor contains
only code to figure out the LAPACK types and functions. Calling the Lapack
functions from the Fortran and C Lapack interface respectively shows
exactly the problem:

{{{
>>> import scipy.linalg as la
>>> import numpy as np
>>> A = np.array([[2,1],[0,1]])
>>> la.flapack.dgetrf(A)
(array([[ 2.,  1.],
[ 0.,  1.]]), array([0, 1], dtype=int32), 0)
>>> la.flapack.dgetrf(np.asfortranarray(A))
(array([[ 2.,  1.],
[ 0.,  1.]]), array([0, 1], dtype=int32), 0)
>>> la.clapack.dgetrf(A)
(array([[ 2. ,  0.5],
[ 0. ,  1. ]]), array([0, 1], dtype=int32), 0)
>>> la.clapack.dgetrf(np.asfortranarray(A))
(array([[ 2. ,  0.5],
[ 0. ,  1. ]]), array([0, 1], dtype=int32), 0)

}}}

If lu_factor takes a C contiguous array, it calls clapack if available, if
it gets a Fortran contiguous array, flapack.

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1458#comment:6>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```