skcuda.linalg.add_diag

skcuda.linalg.add_diag(d_gpu, a_gpu, overwrite=False, handle=None)[source]

Adds a vector to the diagonal of an array.

This is the same as A + diag(D), but faster.

Parameters:
  • d_gpu (pycuda.gpuarray.GPUArray) – Array of length N corresponding to the vector to be added to the diagonal.
  • a_gpu (pycuda.gpuarray.GPUArray) – Summand array with shape (N, N).
  • overwrite (bool (default: False)) – If true, save the result in a_gpu.
  • handle (int) – CUBLAS context. If no context is specified, the default handle from skcuda.misc._global_cublas_handle is used.
Returns:

r_gpu – The computed sum product.

Return type:

pycuda.gpuarray.GPUArray

Notes

d_gpu and a_gpu must have the same precision data type.