scikits.cuda.linalg.pinv

scikits.cuda.linalg.pinv(a_gpu, rcond=1e-15)[source]

Moore-Penrose pseudoinverse.

Compute the Moore-Penrose pseudoinverse of the specified matrix.

Parameters:

a_gpu : pycuda.gpuarray.GPUArray

Input matrix of shape (m, n).

rcond : float

Singular values smaller than rcond`*max(singular_values) are set to zero.

Returns:

a_inv_gpu : pycuda.gpuarray.GPUArray

Pseudoinverse of input matrix.

Notes

Double precision is only supported if the standard version of the CULA Dense toolkit is installed.

This function destroys the contents of the input matrix.

If the input matrix is square, the pseudoinverse uses less memory.

Examples

>>> import pycuda.driver as drv
>>> import pycuda.gpuarray as gpuarray
>>> import pycuda.autoinit
>>> import numpy as np
>>> import linalg
>>> linalg.init()
>>> a = np.asarray(np.random.rand(8, 4), np.float32)
>>> a_gpu = gpuarray.to_gpu(a)
>>> a_inv_gpu = linalg.pinv(a_gpu)
>>> np.allclose(np.linalg.pinv(a), a_inv_gpu.get(), 1e-4)
True
>>> b = np.asarray(np.random.rand(8, 4)+1j*np.random.rand(8, 4), np.complex64)
>>> b_gpu = gpuarray.to_gpu(b)
>>> b_inv_gpu = linalg.pinv(b_gpu)
>>> np.allclose(np.linalg.pinv(b), b_inv_gpu.get(), 1e-4)
True