 	int chosen = 0;
 	int skips = 0;
 	column_vector guess;
-	guess.set_size(elem_count, 1);
+	guess.set_size(elem_count + 1, 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++)

		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\n", sum, val);
		static int count = 0;
		count++;
		if (!(count & 255)) fflush(stdout);


//			guess((y * SHORT_SIDE + x) * 2) = val * cos(angle);
//			guess((y * SHORT_SIDE + x) * 2 + 1) = val * sin(angle);
			double r = y - SHORT_SIDE / 2 - SHORT_SIDE % 2;
			r *= r;
			double x2 = x - SHORT_SIDE / 2 - SHORT_SIDE % 2;
			x2 *= x2;
			r += x2;
			guess((y * SHORT_SIDE + x) * 2) = 1 * exp(-r);
			guess((y * SHORT_SIDE + x) * 2 + 1) = 0.0;
		}
	}
end:;

/*        printf("Maximum: %lf\n", find_min_bobyqa(eval, guess, 2 * SHORT_SIDE * SHORT_SIDE + 10, uniform_matrix<double>(elem_count + 1,1,-25000), uniform_matrix<double>(elem_count + 1,1, 25000),
			 	 	10000, 1e-2, 1e6));*/

	
/*        printf("Maximum: %lf\n", find_min_using_approximate_derivatives(cg_search_strategy(),
                                               gradient_norm_stop_strategy(1e-7).be_verbose(),
                                               eval, guess, -1e30));*/

	for (int y = 0; y < SHORT_SIDE / 2 + SHORT_SIDE % 2; y++)
	{
		for (int x = 0; x < SHORT_SIDE; x++)
		{
			int index = y * SIDE + x;
			if ((y * SHORT_SIDE + x) * 2 >= elem_count) goto end2;
			float angle = randval(0, M_PI * 2);
			float val = randval(1e-10, 15);
			//cufftComplex old = data[index];

//			guess((y * SHORT_SIDE + x) * 2) = val * cos(angle);
//			guess((y * SHORT_SIDE + x) * 2 + 1) = val * sin(angle);
			double r = y - SHORT_SIDE / 2 - SHORT_SIDE % 2;
			r *= r;
			double x2 = x - SHORT_SIDE / 2 - SHORT_SIDE % 2;
			x2 *= x2;
			r += x2;
			guess((y * SHORT_SIDE + x) * 2) = 1 * exp(-r);
			guess((y * SHORT_SIDE + x) * 2 + 1) = 0.0;
		}
	}
end2:;


	for (; factor < 1e9; factor *= 2)
{
	likelihooder.factor = factor;	
        printf("Maximum: %lf %lf\n", find_min_using_approximate_derivatives(cg_search_strategy(),
                                               objective_delta_stop_strategy(1e-7, 2000).be_verbose(),
                                               eval, guess, -1e30), factor);
}


/*        printf("Maximum: %lf\n", find_min_using_approximate_derivatives(newton_search_strategy(),
