 	int chosen = 0;
 	int skips = 0;
 	column_vector guess;
-	guess.set_size(elem_count + 1, 1);
-	guess(elem_count) = 1;
+	guess.set_size(elem_count, 1);
+	//	guess(elem_count) = 1;
 	for (int y = 0; y < SHORT_SIDE / 2 + SHORT_SIDE % 2; y++)
 	{
 		for (int x = 0; x < SHORT_SIDE; x++)

		cudaMemcpy2D(&d_data[(SIDE - SHORT_SIDE / 2) * SIDE], sizeof(cufftComplex) * SIDE, &data[SHORT_SIDE / 2], sizeof(cufftComplex) * SIDE, (SHORT_SIDE / 2 + SHORT_SIDE % 2) * sizeof(cufftComplex), SHORT_SIDE / 2, cudaMemcpyHostToDevice);
		cudaMemcpy2D(&d_data[(SIDE - SHORT_SIDE / 2) * (SIDE + 1)], sizeof(cufftComplex) * SIDE, &data[0], sizeof(cufftComplex) * SIDE, SHORT_SIDE / 2 * sizeof(cufftComplex), SHORT_SIDE / 2, cudaMemcpyHostToDevice);

		cufftExecC2C(plan, d_data, d_pattern, CUFFT_FORWARD);
		thrust::device_ptr<int> t_mask = thrust::device_pointer_cast(d_mask);
		thrust::device_ptr<int> t_truePattern = thrust::device_pointer_cast(d_truePattern);
		thrust::device_ptr<cufftComplex> t_pattern = thrust::device_pointer_cast(d_pattern);
		double val = thrust::transform_reduce(thrust::make_zip_iterator(thrust::make_tuple(t_truePattern, t_mask, t_pattern)),
                                         thrust::make_zip_iterator(thrust::make_tuple(&t_truePattern[SIDE * SIDE], &t_mask[SIDE * SIDE], &t_pattern[SIDE * SIDE])), likelihooder,
					 (double) 0, thrust::plus<double>()) /*+ 34154. * SIDE * SIDE*/;
		printf("VAL %le %le %le\n", sum, val, iorig[elem_count]);
		static int count = 0;
		count++;
		if (!(count & 255)) fflush(stdout);

		mask[x] = 1;
	}
evaluator eval;
	  derivator deriv(eval);
     eval.setTarget(truePattern, mask);


