Construct a double-precision real Givens rotation matrix.
Constructs the double-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
a, b : numpy.float64
|
---|---|
Returns: | r : numpy.float64
c : numpy.float64
s : numpy.float64
|
Examples
>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> a = np.float64(np.random.rand())
>>> b = np.float64(np.random.rand())
>>> h = cublasCreate()
>>> r, c, s = cublasDrotg(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