 		}
 		out_fit_test[1] = shm[0] / double(NROWS_TEST);
 	}
-
-	/*
-	if (tig == 0) {
-		double d = 0;
-		double a = *ls_a;
-		double b = *ls_b;
-		for (int i = 0; i < NROWS_TEST; i++) {
-			double yy = getDataset(NUM_VARIABLE_SYMBOLS, i+NROWS_TRAIN, set);
-			d += ERROR_FUNC(yy, a + b * sem_test[i]);
-		}
-		out_fit_test[1] = d / double(NROWS_TEST);
-	}
-	*/
-}
-
-extern "C" __global__
-void sem_fitness(double *set, double *sem_train, double *sem_test, double *out_fit) {
-	int tig = blockIdx.x * blockDim.x + threadIdx.x;
-	if (tig == 0) {
-		double d = 0;
-		for (int i = 0; i < NROWS_TRAIN; i++) {
-			double yy = getDataset(NUM_VARIABLE_SYMBOLS, i, set);
-			d += ERROR_FUNC(yy, sem_train[i]);
-		}
-		out_fit[0] = d / double(NROWS_TRAIN);
-	} else if (tig == 1) {
-		double d = 0;
-		for (int i = 0; i < NROWS_TEST; i++) {
-			double yy = getDataset(NUM_VARIABLE_SYMBOLS, i+NROWS_TRAIN, set);
-			d += ERROR_FUNC(yy, sem_test[i]);
-		}
-		out_fit[1] = d / double(NROWS_TEST);
-	}
 }
 
 extern "C" __global__

		}
		out_fit_train[0] = shm[0] / double(NROWS_TRAIN);
	}
	/*
	if (tig == 0) {
		double sum_out = 0; // Maybe initialize it to first value and start for loop with 1, faster?
		double sum_tar = 0;
		double sum_oxo = 0;
		double sum_oxt = 0;
		for (int i = 0; i < NROWS_TRAIN; i++) {
			double t = getDataset(NUM_VARIABLE_SYMBOLS, i, set);
			double y = sem_train[i];
			sum_out += y;
			sum_tar += t;
			sum_oxo += y * y;
			sum_oxt += y * t;
		}

		double avg_out = sum_out / NROWS_TRAIN;
		double avg_tar = sum_tar / NROWS_TRAIN;

		double num = sum_oxt - sum_tar * avg_out - sum_out * avg_tar + NROWS_TRAIN * avg_out * avg_tar; 
		double den = sum_oxo - 2.0 * sum_out * avg_out + NROWS_TRAIN * avg_out * avg_out; 

		double b = num / den;
		double a = avg_tar - b * avg_out;
		*out_ls_b = b;
		*out_ls_a = a;

		double d = 0; // Same as above
		for (int i = 0; i < NROWS_TRAIN; i++) {
			double yy = getDataset(NUM_VARIABLE_SYMBOLS, i, set);
			d += ERROR_FUNC(yy, a + b * sem_train[i]);
		}
		out_fit_train[0] = d / double(NROWS_TRAIN);
	}
	*/
}

extern "C" __global__

	if (i < NROWS_TOT) {
		double sem_val = eval_arrays(sym, set, tree, 0, i);
		out_sem_tot[i] = sem_val;
	}
}

