Hi
Can you tell me, why those 2 operations give different results?
z.power(2);
z = z*z;
given:
__device__ void power(int p){
float R=r;
float I=i;
float tmpR=0;
float tmpI=0;
for(int i=1; i<p; i++) {
tmpR = r*R - i*I;
tmpI = r*I + i*R;
R = tmpR;
I = tmpI;
}
r=R;
i=I;
}
and
__device__ cudaComplex operator*(const cudaComplex& a) {
return cudaComplex(r*a.r - i*a.i, i*a.r + r*a.i);
}
where cudaComplex is my class
class cudaComplex {
public:
float r;
float i;
...
};
Please help.
Kind regards