## vector exponential

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Volodimir
Posts: 10
Joined: Fri Jun 29, 2018 2:52 pm

### vector exponential

Hello,
let say I have a vector

Code: Select all

``V[v0,v1,v2,...,vN]``
.
I want to convert it to the vector

Code: Select all

``e(2*j*PI*V)``
.
Is there anything in MAGMA to address this operation?
/v

mgates3
Posts: 914
Joined: Fri Jan 06, 2012 2:13 pm

### Re: vector exponential

No, sorry.

If you want this on the GPU, a CUDA kernel would be fairly easy. Something like below (completely UNTESTED CODE). I'm not sure what you mean by "j"; here I assumed you meant the row index, starting from i = 0, where v is a column vector. Adjust as desired. Compile with nvcc CUDA compiler. I based this off the magma/magmablas/zaxpycp.cu code.

Code: Select all

``````#include <magma_v2.h>        // for magma_ceildiv
#include <math_constants.h>  // for CUDART_PI

__global__
void exponential_kernel( int n, double* v )
{
const int i = threadIdx.x + blockIdx.x*blockDim.x;
if (i < n) {
v[i] = exp( 2 * i * CUDART_PI * v[i] );
}
}

void exponential( int n, double* x, cudaStream_t stream )
{
const int nb = 32;
exponential_kernel<<< magma_ceildiv( n, nb ), nb, 0, stream >>>( n, x );
}
``````
-mark

Volodimir
Posts: 10
Joined: Fri Jun 29, 2018 2:52 pm

### Re: vector exponential

thanks, will try to use.
Just for clarification - j - is "imaginary" 1.
/v