Page 1 of 1
vector exponential
Posted: Sun Jul 15, 2018 6:06 pm
by Volodimir
Hello,
let say I have a vector
.
I want to convert it to the vector
.
Is there anything in MAGMA to address this operation?
Thanks much in advance,
/v
Re: vector exponential
Posted: Sun Jul 15, 2018 10:08 pm
by mgates3
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
Re: vector exponential
Posted: Sun Jul 15, 2018 10:37 pm
by Volodimir
thanks, will try to use.
Just for clarification - j - is "imaginary" 1.
/v