skcuda.cublas.cublasDrotg

skcuda.cublas.cublasDrotg(handle, a, b)[source]

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) – CUBLAS context.
  • b (a,) – Entries of vector whose second entry should be zeroed out by the rotation.
Returns:

  • r (numpy.float64) – Defined above.
  • c (numpy.float64) – Cosine component of rotation matrix.
  • s (numpy.float64) – Sine component of rotation matrix.

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

References

cublas<t>rotg