#include "../common/book.h"
#include "../common/cpu_bitmap.h"
//自学的一个CUDA比较有趣的编程,我也来写写注释
#define DIM 1000
struct cuComplex {
float r;
float i;
//这里的话就是原来少些了个__device__,这是结构体的构造函数,在julia()里使用了,然后Julia()是设备端的函数,所以这里也需要加上,要不然没有办法运行的
__device__ cuComplex( float a, float b ) : r(a), i(b) {}
//这个函数是求复数的模
__device__ float magnitude2( void ) {
return r * r + i * i;
}
//这里定义了一个*运算,和下面的+运算,用来执行复数运算的
__device__ cuComplex operator*(const cuComplex& a) {
return cuComplex(r*a.r - i*a.i, i*a.r + r*a.i);
}
__device__ cuComplex operator+(const cuComplex& a) {
return cuComplex(r+a.r, i+a.i);
}
};