 	int skips = 0;
 	column_vector guess;
 	guess.set_size(elem_count, 1);
+
+	column_vector lower;
+	column_vector upper;
+	lower.set_size(elem_count, 1);
+	upper.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++)
+	for (int y = 0; y < SIDE; y++)
+	{
+		for (int x = 0; x < SIDE; x++)
 		{
-			int index = y * SIDE + x;
-			if ((y * SHORT_SIDE + x) * 2 >= elem_count) goto end;
-			float angle = randval(0, M_PI * 2);
-			float val = randval(1e-10, 15);
+			float val = /*randval(1e-10, 15)*/ truePattern[y * SIDE + x];
 			//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;
+			if (val <= 1e-9) val = 1e-2;
+			guess(y * SIDE + x) = val;
+			lower(y * SIDE + x) = 1e-9;
+			upper(y * SIDE + x) = 1e6;
 		}
 	}
+
+	//lower(SIDE * (SIDE / 2) + SIDE / 2) = 1e5;
 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),

		 sum *= fabs(iorig[elem_count]) * 1e-5;*/
		 sum = 1;
		 i = shortData.begin();	
		 for (int y = 0; y < SHORT_SIDE / 2 + SHORT_SIDE % 2; y++)
		 {
			for (int x = 0; x < SHORT_SIDE; x++)
			{
				data[y * SIDE + x].x = *(i) / sum;
				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].x = *(i) / sum;
				i++;

				data[y * SIDE + x].y = *(i) / sum;
				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].y = -*(i) / sum;
				i++;
				if (i - iorig >= elem_count) goto end;
			}
		}
end:;

//		cudaMemcpy(d_data, data, sizeof(cufftComplex) * SIDE * SHORT_SIDE, cudaMemcpyHostToDevice);
		cudaMemcpy2D(d_data, sizeof(cufftComplex) * SIDE, &data[SHORT_SIDE / 2 * SIDE + SHORT_SIDE / 2], sizeof(cufftComplex) * SIDE, (SHORT_SIDE / 2 + SHORT_SIDE % 2) * sizeof(cufftComplex), SHORT_SIDE / 2 + SHORT_SIDE % 2, cudaMemcpyHostToDevice);
		cudaMemcpy2D(&d_data[SIDE - SHORT_SIDE / 2], sizeof(cufftComplex) * SIDE, &data[SHORT_SIDE / 2 * SIDE], sizeof(cufftComplex) * SIDE, SHORT_SIDE / 2 * sizeof(cufftComplex), SHORT_SIDE / 2 + SHORT_SIDE % 2, cudaMemcpyHostToDevice);
		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);

		cufftExecZ2Z(plan, d_data, d_pattern, CUFFT_FORWARD);
  }


		t_mask = thrust::device_pointer_cast(d_mask);
		t_truePattern = thrust::device_pointer_cast(d_truePattern);
		t_pattern = thrust::device_pointer_cast(d_pattern);
		t_data = thrust::device_pointer_cast(d_data);

		printf("Memset: %d\n", cudaMemset(d_data, 0, sizeof(cufftComplex) * SIDE * SIDE));
		cufftPlan2d(&plan, SIDE, SIDE, CUFFT_Z2Z);
