skcuda.linalg.inv

skcuda.linalg.inv(a_gpu, overwrite=False, ipiv_gpu=None, lib='cusolver')[source]

Compute the inverse of a matrix.

Parameters:
  • a_gpu (pycuda.gpuarray.GPUArray) – Square (n, n) matrix to be inverted.
  • overwrite (bool (default: False)) – Discard data in a (may improve performance).
  • ipiv_gpu (pycuda.gpuarray.GPUArray (optional)) – Temporary array of size n, can be supplied to save allocations.
  • lib (str) – Library to use. May be either ‘cula’ or ‘cusolver’.
Returns:

ainv_gpu – Inverse of the matrix a.

Return type:

pycuda.gpuarray.GPUArray

Raises:
  • LinAlgError : – If a is singular.
  • ValueError : – * If a is not square, or not 2-dimensional. * If ipiv was not None but had the wrong dtype or shape.

Notes

When the CUSOLVER backend is selected, an extra copy will be performed if overwrite is set to transfer the result back into the input matrix.