Use LU factorization rather than inv