skcuda.cublas.cublasSrotg¶
-
skcuda.cublas.
cublasSrotg
(handle, a, b)[source]¶ Construct a single precision real Givens rotation matrix.
Constructs the single precision real Givens rotation matrix G = [[c, s], [-s.conj(), c]] such that dot(G, [[a], [b]] == [[r], [0]], where c**2+s**2 == 1 and r == a**2+b**2 for real numbers and c**2+(conj(s)*s) == 1 and r == (a/abs(a))*sqrt(abs(a)**2+abs(b)**2) for a != 0 and r == b for a == 0.
Parameters: - handle (int) – CUBLAS context.
- b (a,) – Entries of vector whose second entry should be zeroed out by the rotation.
Returns: - r (numpy.float32) – Defined above.
- c (numpy.float32) – Cosine component of rotation matrix.
- s (numpy.float32) – Sine component of rotation matrix.
Examples
>>> import pycuda.autoinit >>> import pycuda.gpuarray as gpuarray >>> import numpy as np >>> a = np.float32(np.random.rand()) >>> b = np.float32(np.random.rand()) >>> h = cublasCreate() >>> r, c, s = cublasSrotg(h, a, b) >>> cublasDestroy(h) >>> np.allclose(np.dot(np.array([[c, s], [-np.conj(s), c]]), np.array([[a], [b]])), np.array([[r], [0.0]]), atol=1e-6) True
References