vector exponential

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

vector exponential

Postby Volodimir » Sun Jul 15, 2018 6:06 pm

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?
Thanks much in advance,
/v
Volodimir
 
Posts: 10
Joined: Fri Jun 29, 2018 2:52 pm

Re: vector exponential

Postby mgates3 » Sun Jul 15, 2018 10:08 pm

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
mgates3
 
Posts: 822
Joined: Fri Jan 06, 2012 2:13 pm

Re: vector exponential

Postby Volodimir » Sun Jul 15, 2018 10:37 pm

thanks, will try to use.
Just for clarification - j - is "imaginary" 1.
/v
Volodimir
 
Posts: 10
Joined: Fri Jun 29, 2018 2:52 pm


Return to User discussion

Who is online

Users browsing this forum: No registered users and 1 guest