skcuda.cublas.cublasDnrm2

skcuda.cublas.cublasDnrm2(handle, n, x, incx)[source]

Euclidean norm (2-norm) of real vector.

Computes the Euclidean norm of a double precision real vector.

Parameters:
  • handle (int) – CUBLAS context.
  • n (int) – Number of elements in input vectors.
  • x (ctypes.c_void_p) – Pointer to double precision real input vector.
  • incx (int) – Storage spacing between elements of x.
Returns:

nrm – Euclidean norm of x.

Return type:

numpy.float64

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> x = np.float64(np.random.rand(5))
>>> x_gpu = gpuarray.to_gpu(x)
>>> h = cublasCreate()
>>> nrm = cublasDnrm2(h, x.size, x_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(nrm, np.linalg.norm(x))
True

References

cublas<t>nrm2