skcuda.linalg.pinv¶
-
skcuda.linalg.
pinv
(a_gpu, rcond=1e-15, lib='cusolver')[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.
- lib (str) – Library to use. May be either ‘cula’ or ‘cusolver’.
Returns: a_inv_gpu – Pseudoinverse of input matrix.
Return type: 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 skcuda.linalg as 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
Notes
The CUSOLVER backend cannot be used with CUDA 7.0.