Passing heirarchical struct to kernel

I’m trying to make a program to render Mandelbrot-like images on the GPU. I generate a recursive function tree with the following code:

struct function {
	function *f1;
	function *f2;
	int index;
	int depth;
	function(int d) {
		depth = d;
		index = rand() % 24;
		if(depth < 5) index = rand() % 14 + 10;
		if(depth > 15) index = rand() % 10;
		if(index > 9) {
			f1 = (function*)malloc(sizeof(function));
			f1[0] = function(depth + 1);
		}
		if(index > 18) {
			f2 = (function*)malloc(sizeof(function));
			f2[0] = function(depth + 1);
		}
	}

	__device__ complexNumber eval(const complexNumber point, const complexNumber params[]) const {
		switch(index) {
			case 0: return point;
			case 1: return params[0];
			case 2: return params[1];
			case 3: return params[2];
			case 4: return params[3];
			case 5: return params[4];
			case 6: return params[5];
			case 7: return params[6];
			case 8: return params[7];
			case 10: return f1->eval(point, params).conjugate();
			case 11: return f1->eval(point, params).cos();
			case 12: return f1->eval(point, params).cosh();
			case 13: return f1->eval(point, params).log();
			case 14: return f1->eval(point, params).sin();
			case 15: return f1->eval(point, params).sinh();
			case 16: return f1->eval(point, params).tan();
			case 17: return f1->eval(point, params).tanh();
			case 18: return f1->eval(point, params).round();
			case 19: return f1->eval(point, params).dividedBy(f2->eval(point, params));
			case 20: return f1->eval(point, params).minus(f2->eval(point, params));
			case 21: return f1->eval(point, params).plus(f2->eval(point, params));
			case 22: return f1->eval(point, params).times(f2->eval(point, params));
			case 23: return f1->eval(point, params).power(f2->eval(point, params));
			default: return complexNumber();
		}
	}
};

At the top is a function. This function takes two arguments, which are two other functions. Each of these functions take two arguments… and so on, until it reaches the bottom of the tree when the arguments are constants.

How do I get this on the GPU? The pointers to other functions are on host memory, so when I pass it to the GPU it can’t access them. Do I have to copy the entire tree structure with cudaMemcpy?

I’m definitely a novice, especially with the GPU. Thanks in advance for your help.