# Complex conjugate function in cuda? maths

Hi all,

I’d like to execute the following c code using cuda…

for(i = 1; i <= n; i++) {
x1[i] = bmass*bmass * p[i]
- expv[i][id1] *
(expv[ishf[i][id1]][id2]*p[ishf[ishf[i][id1]][id2]]
- conj(expv[ishb[ishf[i][id1]][id2]][id2])*p[ishb[ishf[i][id1]][id2]])
+ conj(expv[ishb[i][id1]][id1])
* (expv[ishb[i][id1]][id2]*p[ishf[ishb[i][id1]][id2]]
- conj(expv[ishb[ishb[i][id1]][id2]][id2])*p[ishb[ishb[i][id1]][id2]]);
}

I’ve replaced it in my source with the following…

``````cudaSum<<<1, n>>>(n, id1, id2, ishf, ishb, bmass, p, x1, expv);
``````

and my cuda sum function is…

global void cudaSum(int n, int id1, int id2, int **ishf, int **ishb, float bmass, float complex *p, float complex *x1, float complex **expv) {

``````int i = threadIdx.x;

x1[i] = bmass*bmass * p[i]
- expv[i][id1] *
(expv[ishf[i][id1]][id2]*p[ishf[ishf[i][id1]][id2]]
- conjf(expv[ishb[ishf[i][id1]][id2]][id2])*p[ishb[ishf[i][id1]][id2]])
+ conjf(expv[ishb[i][id1]][id1])
* (expv[ishb[i][id1]][id2]*p[ishf[ishb[i][id1]][id2]]
- conjf(expv[ishb[ishb[i][id1]][id2]][id2])*p[ishb[ishb[i][id1]][id2]]);
``````

}

My problem is I get an error when trying to use the conjf function.

Does cuda have a function that returns the complex conjugate of a number???

Thanks,

Wes

I am not sure if such a function exists, but it is trivial to implement it.

cuConjf, defined in cuComplex.h

Many thanks for both replies. the functions in cuComplex.h do exactly what I want.

Where can i find cuComplex.h?

It’s in CUDAs include directory…C:\CUDA\include\cuComplex.h for me.

I guess that’s the toolkit install directory…