Singular Value Decomposition.
Factors the matrix a into two unitary matrices, u and vh, and a 1-dimensional array of real, non-negative singular values, s, such that a == dot(u.T, dot(diag(s), vh.T)).
Parameters: | a : pycuda.gpuarray.GPUArray
jobu : {‘A’, ‘S’, ‘O’, ‘N’}
jobvt : {‘A’, ‘S’, ‘O’, ‘N’}
|
---|---|
Returns: | u : pycuda.gpuarray.GPUArray
s : pycuda.gpuarray.GPUArray
vh : pycuda.gpuarray.GPUArray
|
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 regardless of the values of jobu and jobvt.
Only one of jobu or jobvt may be set to O, and then only for a square matrix.
Examples
>>> import pycuda.gpuarray as gpuarray
>>> import pycuda.autoinit
>>> import numpy as np
>>> import linalg
>>> linalg.init()
>>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6)
>>> a = np.asarray(a, np.complex64)
>>> a_gpu = gpuarray.to_gpu(a)
>>> u_gpu, s_gpu, vh_gpu = linalg.svd(a_gpu, 'S', 'S')
>>> np.allclose(a, np.dot(u_gpu.get(), np.dot(np.diag(s_gpu.get()), vh_gpu.get())), 1e-4)
True