# Use of scipy.linalg.cython_lapack.dgbsv in cython script

I was working into accellerating a solver for baded matrix using cython. The base case is the following pure python code :

    import numpy as np
from scipy.linalg.lapack import dgbsv

# Define a banded matrix
n = 5
kl = 1  # number of subdiagonals
ku = 1  # number of superdiagonals

ldab = 2* kl + ku + 1
# Create a banded matrix
ab = np.zeros((ldab, n),dtype=np.double)
ab[kl+ku, :] = [1., 2., 3, 4, 5]  # main diagonal

# Define the right-hand side vector
b = np.array([1, 2, 3, 4, 5],dtype=np.double)

# Solve the system
lu, piv, x, info = dgbsv(kl, ku, ab, b)

print("Solution:", x)
print("Info:", info)


which gives the right (trivial) solution

    Solution: [1. 1. 1. 1. 1.]
Info: 0


if I try to go through cython

    import numpy as np
cimport numpy as np
from scipy.linalg.cython_lapack cimport dgbsv

DTYPE = np.float64
def solve(double[:, :] HV, double[:] F, int n, int kl, int ku):
cdef:
int nrhs = 1
int ldab = 2* kl + ku + 1
int ldb = n
int info = 0
int[:] IPIV = np.zeros(n, dtype=np.int32)

dgbsv(&n, &kl, &ku, &nrhs, &HV[0,0], &ldab, &IPIV[0], &F[0], &ldb, &info)

return np.asarray(F), info

    n = 5
kl = 1  # number of subdiagonals
ku = 1  # number of superdiagonals

ldab = 2* kl + ku + 1
# Create a banded matrix
ab = np.zeros((ldab, n),dtype=np.double)
ab[kl+ku, :] = [1., 2., 3, 4, 5]  # main diagonal

# Define the right-hand side vector
b = np.array([1, 2, 3, 4, 5],dtype=np.double)

# Solve the system
x, info = solve(ab, b,n,kl,ku)

print("Solution:", x)
print("Info:", info)



I get as output the following

    Solution: [1. 2. 3. 4. 5.]
Info: 1


Which means, that the element (1,1) of the U matrix is 0. I guess that the problem could be in the matrix ab; I played around a bit (wiht the placement of the diagonal) but I was not able to make it work.

Since the scipy function is also based on the lapack function I guessed that the two input should be the same, but I am probably wrong.

Any ideas ?