skcuda.cublas.cublasIdamax

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

Index of maximum magnitude element.

Finds the smallest index of the maximum magnitude element of a double precision real vector.

Note: for complex arguments x, the “magnitude” is defined as abs(x.real) + abs(x.imag), not as abs(x).

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

idx – Index of maximum magnitude element.

Return type:

int

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> x = np.random.rand(5).astype(np.float64)
>>> x_gpu = gpuarray.to_gpu(x)
>>> h = cublasCreate()
>>> m = cublasIdamax(h, x_gpu.size, x_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(m, np.argmax(abs(x.real) + abs(x.imag)))
True

Notes

This function returns a 0-based index.

References

cublasI<t>amax