skcuda.cublas.cublasSnrm2¶
-
skcuda.cublas.
cublasSnrm2
(handle, n, x, incx)[source]¶ Euclidean norm (2-norm) of real vector.
Computes the Euclidean norm of a single precision real vector.
Parameters: - handle (int) – CUBLAS context.
- n (int) – Number of elements in input vectors.
- x (ctypes.c_void_p) – Pointer to single precision real input vector.
- incx (int) – Storage spacing between elements of x.
Returns: nrm – Euclidean norm of x.
Return type: numpy.float32
Examples
>>> import pycuda.autoinit >>> import pycuda.gpuarray as gpuarray >>> import numpy as np >>> x = np.float32(np.random.rand(5)) >>> x_gpu = gpuarray.to_gpu(x) >>> h = cublasCreate() >>> nrm = cublasSnrm2(h, x.size, x_gpu.gpudata, 1) >>> cublasDestroy(h) >>> np.allclose(nrm, np.linalg.norm(x)) True
References