Numba-accelerated QR decomposition giving non-contiguous array

I encounter a strange warning when performing matrix multiplication after QR decomposition in a Numba-accelerated function. For example:

# Python 3.10

import numpy as np
from numba import jit

@jit
def qr_check(x):
    q,r = np.linalg.qr(x)
    return q @ r

x = np.random.rand(3,3)
qr_check(x)

Running the above code, I get the following NumbaPerformanceWarning:

'@' is faster on contiguous arrays, called on (array(float64, 2d, A), array(float64, 2d, F))

I’m not sure what’s going wrong here. I know F is for Fortran, so array r is Fortran-contiguous, but what’s wrong with q? If I include the line print(q.flags.f_contiguous) in the function, I’m told that q is Fortran-contiguous, so I don’t know why I’m getting this warning.

Answered on Stack Overflow: …/questions/73805180/numpy-arrays-from-numba-accelerated-qr-decomposition-are-not-contiguous

Stack Overflow link