Example #1
0
void printNumberOfMirrorStrings (char * s)
{
	int max = 0, i, C = 0, R = 0, n = 0;
	
	i = 0;
	while (s[i++])
		n++;
	char * T = preprocess (s, n);
	n = 0;
	i = 0;
	while (T[i++])
		n++;
	int * P = (int *) malloc (n * sizeof (int));
	
	int max_arr[3001] = {0};
	
	for (i = 0; i < n; i++)
		P[i] = 0;
	
	for (i = 1; i < n-1; i++)
	{
		int i_mirror = C - (i - C);
		
		P[i] = (R > i) ? min (R - i, P[i_mirror]) : 0;
		
		while (T[i + 1 + P[i]] == T[i - 1 - P[i]])
			P[i]++;
		
		if (i + P[i] > R)
		{
			C = i;
			R = i + P[i];
		}
	}
	
	for (i = 1; i < n-1; i++)
	{
		if (P[i] > max)
		{
			max = P[i];
		}
		max_arr[P[i]]++;
	}
	
	printf ("%d %d\n", max, max_arr[max]);
	
	free (P);
	free (T);
}
Example #2
0
void testConstructDFA2(){
	regexps = malloc(sizeof(struct REentry));
	char *s = "(a|b)*abb(a|b)*";
	regexps->regexp = malloc(strlen(s));
	strcpy(regexps->regexp, s);
	regexps->action = "printf;";
	regexps->next = NULL;
	preprocess();
	constructNFA();
	constructDFA();
	printDFATransTable();
	destroyDFA();
	destroyNFA();
	destroyGraph();
}
// Prints LCAs for given queries q[0..m-1] in a tree
// with given root
void printLCAs(Node *root, Query q[], int m)
{
    // Allocate memory for V subsets and nodes
    struct subset * subsets = new subset[V+1];
 
    // Creates subsets and colors them WHITE
    initialise(subsets);
 
    // Preprocess the tree
    preprocess(root, subsets);
 
    // Perform a tree walk to process the LCA queries
    // offline
    lcaWalk(root->data , q, m, subsets);
}
Example #4
0
static void test_compute_inf_timeslot(void) {
    init_test_exam();
    exam *test_exams[] = {exam1, exam2, exam3, exam4,
                            exam5, exam6, exam7, exam8};
    init_test_array_exams(8, test_exams);
    preprocess(exams);
    CU_ASSERT_EQUAL(compute_inf_timeslot(exam1, exams), 0);
    CU_ASSERT_EQUAL(compute_inf_timeslot(exam7, exams), 0);
    /* Schedule Exam 1 at timeslot 2 (index 1)*/
    exams->data[0]->timeslot = 1;
    CU_ASSERT_EQUAL(compute_inf_timeslot(exams->data[0], exams), 0);
    /* First timeslot expected for Exam 7 (depends on Exam 1) : 3 (index 2) */
    CU_ASSERT_EQUAL(compute_inf_timeslot(exams->data[6], exams), 2);
    clean_array_exams();
}
void DeclarationValidator::visit(Declaration* declaration)
{
  bool testDataOk;
  QJson::Parser parser;
  QVariantMap testData = parser.parse(preprocess(declaration->comment()), &testDataOk).toMap();
  if (!testDataOk)
  {
    d->testsPassed = false;
    qDebug() << "Error parsing test data for declaration on line" << declaration->range().start.line + 1;
    qDebug() << "Parser error on comment line" << parser.errorLine() << "was" << parser.errorString();
    return;
  }
  if (!KDevelop::runTests(testData, declaration))
    d->testsPassed = false;
}
Example #6
0
  void Oscillator::process() {
    preprocess();

    int i = 0;
    if (input(kReset)->source->triggered &&
        input(kReset)->source->trigger_value == kVoiceReset) {
      int trigger_offset = input(kReset)->source->trigger_offset;
      for (; i < trigger_offset; ++i)
        tick(i);

      offset_ = 0.0;
    }
    for (; i < buffer_size_; ++i)
      tick(i);
  }
Example #7
0
void testConstructNFA3(){
	regexps = malloc(sizeof(struct REentry));
	char *s = "(a|b)*abb(a|b)*";
	regexps->regexp = malloc(strlen(s));
	strcpy(regexps->regexp, s);
	regexps->action = "printf;";
	regexps->next = malloc(sizeof(struct REentry));
	s = "(a|b)+abc(a|b|c)?";
	regexps->next->regexp = malloc(strlen(s));
	strcpy(regexps->next->regexp, s);
	regexps->next->action = "donothing";
	preprocess();
	constructNFA();
	printGraph();
	destroyNFA();
}
Example #8
0
int main(void)
{
    preprocess();
    scanf("%d", &tests);
    for(int t = 0; t < tests; ++ t)
    {
        scanf("%d", &bits);
        word[bits] = 0;
        for(int b = 0; b < bits; ++ b)
            scanf(" %c", &word[b]);

        solve();
    }

    return 0;
}
Example #9
0
void UvdState::processK1(K1 k1)
{
    preprocess(k1.ri.time);

    if (k1.ri.confidence == 3)
    {
        m_recvStats.k1Conf3Lines++;
    }
    else
    {
        m_recvStats.k1Conf4Lines++;
    }

    OccurrenceRecord record;
    if (m_pendingOccurrences.count(k1.tailNumber) == 0)
    {
        record.tailNumber = k1.tailNumber;
        record.firstTime = k1.ri.time;
        record.lastTime = k1.ri.time;
        m_pendingOccurrences[k1.tailNumber] = record;
    }
    else
    {
        record = m_pendingOccurrences[k1.tailNumber];
        if (record.lastTime + 100.0 < k1.ri.time)
        {
            // finalize old occurrence
            lock();
            m_occurrences.push_back(record);
            unlock();

            // and replace with new
            record.tailNumber = k1.tailNumber;
            record.firstTime = k1.ri.time;
            record.lastTime = k1.ri.time;
        }
        else
        {
            record.lastTime = k1.ri.time;
        }

        m_pendingOccurrences[k1.tailNumber] = record;
    }

    postprocess(k1.ri.time);
}
Example #10
0
//---------------------------------------------------------------------------------------
Mat PAN::getcontours(vector<vector<Point>> &finalcontours,int parameter,String database){
	Mat img;
	finalcontours._Pop_back_n(finalcontours.size());
	Image image=PAN::Image(&img, 0, 0, 0, 0, Point(0, 0));
	Mat mod;
	if (parameter == 1){ mod = preprocess(panimage.img, &image, REMOVE_EMBLEM,database); }//used for cropping the image
	else if (parameter == 2){ mod = panimage.img->clone(); }
	int erosion_size = 4/parameter;
	Mat element = getStructuringElement(MORPH_RECT, Size(2 * erosion_size + 1, 2 * erosion_size + 1), Point(erosion_size, erosion_size));
	*image.img = mod.clone();
	int kernel_size = 3;
	int threshold = 81;
	int ratio = 2/parameter;
	int lowThreshold = 100;
	if (image.img->channels() >= 2){ cvtColor(*image.img, *image.img, CV_BGR2GRAY); }
	adaptiveThreshold(*image.img, *image.img, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, threshold, threshold);
	erode(*image.img, *image.img, element);
	blur(*image.img, *image.img, Size(kernel_size, kernel_size));
	Canny(*image.img, *image.img, lowThreshold, lowThreshold*(2*ratio+1), 3, true);
	vector<vector<Point>> contours;
	findContours(*image.img, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, Point(0, 0));

	for (unsigned int i = 0; i< contours.size(); i++){
		if (contours[i].size()>80 && contours[i].size() < 1000){
			vector<Point>temp = contours[i];
			if (parameter == 1){
				if (checktext(temp) == 1){ finalcontours.push_back(temp); }
			}
			else if (parameter == 2){
				if (checksign(temp) == 1){ 
					finalcontours.push_back(temp);
				}
			}
		}
	}

	RNG rng(1235);
	for (unsigned int i = 0; i<finalcontours.size(); i++){
		Scalar color = Scalar(rng.uniform(150, 255), rng.uniform(150, 255), rng.uniform(150, 255));
		drawContours(*image.img, finalcontours, i, color, 2, 8);
	}
	
	//imshow("output", *image.img);
	//waitKey();
	return mod;
}
Example #11
0
static void test_get_first_exam(void) {
    init_test_exam();
    exam *test_exams[] = {exam1, exam2, exam3, exam4,
                            exam5, exam6, exam7, exam8};
    init_test_array_exams(8, test_exams);
    preprocess(exams);
    exam *first = get_first_exam(exams, MAX_TIMESLOT);
    /* Initially, lower sat degree is Exam 4 */
    CU_ASSERT_PTR_EQUAL(first, exams->data[3]);
    /* Assign Exam 4 */
    exams->data[3]->timeslot = 2;
    first = get_first_exam(exams, MAX_TIMESLOT);
    /* Tie break between Exam 2, 5 and 6.
     * Exam 5 has the most students enrolled */
    CU_ASSERT_PTR_EQUAL(first, exams->data[4]);
    clean_array_exams();
}
Example #12
0
int main(int argc, char** argv) {
	char* sourceFileName = argv[1];
	FILE* source = fopen(sourceFileName, "r");
	preprocess(source);
	SymbolList* symlist = getSymbols();
	Symbol* symbols = symlist->symbols;
	// printf("Number of symbols: %d\n", symlist->size);
	// for (int i = 0; i < symlist->size; i++) {
	// 	printf("\n\n");
	// 	printSymbol(symbols);
	// 	symbols++;
	// }

	FILE* datasection = fopen("binarydata.txt", "w+");
	printDataSection(datasection, symlist);
	fclose(source);
}
Example #13
0
/* OpenCL processing function */
static cl_int
cl_process (GeglOperation       *op,
            cl_mem               in_tex,
            cl_mem               out_tex,
            size_t               global_worksize,
            const GeglRectangle *roi,
            int                  level)
{
  /* Retrieve a pointer to GeglChantO structure which contains all the
   * chanted properties
   */

  GeglChantO   *o         = GEGL_CHANT_PROPERTIES (op);
  const gfloat *coeffs    = o->chant_data;

  cl_int cl_err = 0;

  if (! coeffs)
    {
      coeffs = o->chant_data = preprocess (o);
    }

  if (!cl_data)
    {
      const char *kernel_name[] = {"kernel_temp", NULL};
      cl_data = gegl_cl_compile_and_build (kernel_source, kernel_name);
    }

  if (!cl_data) return 1;

  cl_err |= gegl_clSetKernelArg(cl_data->kernel[0], 0, sizeof(cl_mem),    (void*)&in_tex);
  cl_err |= gegl_clSetKernelArg(cl_data->kernel[0], 1, sizeof(cl_mem),    (void*)&out_tex);
  cl_err |= gegl_clSetKernelArg(cl_data->kernel[0], 2, sizeof(cl_float),  (void*)&coeffs[0]);
  cl_err |= gegl_clSetKernelArg(cl_data->kernel[0], 3, sizeof(cl_float),  (void*)&coeffs[1]);
  cl_err |= gegl_clSetKernelArg(cl_data->kernel[0], 4, sizeof(cl_float),  (void*)&coeffs[2]);
  if (cl_err != CL_SUCCESS) return cl_err;

  cl_err = gegl_clEnqueueNDRangeKernel(gegl_cl_get_command_queue (),
                                        cl_data->kernel[0], 1,
                                        NULL, &global_worksize, NULL,
                                        0, NULL, NULL);
  if (cl_err != CL_SUCCESS) return cl_err;

  return cl_err;
}
Example #14
0
  void Oscillator::process() {
    MOPO_ASSERT(inputMatchesBufferSize(kFrequency));
    MOPO_ASSERT(inputMatchesBufferSize(kPhase));

    preprocess();

    int i = 0;
    if (input(kReset)->source->triggered &&
        input(kReset)->source->trigger_value == kVoiceReset) {
      int trigger_offset = input(kReset)->source->trigger_offset;
      for (; i < trigger_offset; ++i)
        tick(i);

      offset_ = 0.0;
    }
    for (; i < buffer_size_; ++i)
      tick(i);
  }
Example #15
0
int main(void)
{
    preprocess();
    scanf("%lld", &tests);
    for(long long int t = 0; t < tests; ++ t)
    {
        scanf("%lld %lld", &numbers, &subset);
        for(long long int n = 0; n < numbers; ++ n)
        {
            scanf("%lld", &number[n]);
            number[n] %= MOD;
        }

        printf("Case #%lld: %lld\n", t + 1, solve(numbers, subset));
    }

    return 0;
}
Example #16
0
	Barcode& Barcode2dBase::build( const std::string& rawData,
				       double             w,
				       double             h )
	{
		std::string  cookedData;   /* Preprocessed data */
		Matrix<bool> encodedData;  /* Encoded data matrix */

		clear();

		if ( rawData.empty() )
		{
			setIsEmpty( true );
			setIsDataValid( false );

			setWidth( 0 );
			setHeight( 0 );
		}
		else
		{
			setIsEmpty( false );

			if ( !validate( rawData ) )
			{
				setIsDataValid( false );

				setWidth( 0 );
				setHeight( 0 );
			}
			else
			{
				setIsDataValid( true );

				cookedData  = preprocess( rawData );
				encode( cookedData, encodedData );

				vectorize( encodedData, w, h );

				setWidth( w );
				setHeight( h );
			}
		}

		return *this;
	}
Example #17
0
File: caffe.cpp Project: aaalgo/xnn
    virtual void apply (vector<cv::Mat> const &images, vector<float> *ft) {
        int batch = shape[0];
        CHECK(!images.empty()) << "must input >= 1 images";
        CHECK(images.size() <= batch) << "Too many input images.";
        if (fcn()) {    // for FCN, we need to resize network according to image size
            cv::Size sz = images[0].size();
            for (unsigned i = 1; i < images.size(); ++i) {
                CHECK(images[i].size() == sz) << "all images must be the same size";
            }
            int input_height = input_blob->shape(2);
            int input_width = input_blob->shape(3);
            if ((input_width != sz.width)
                    || (input_height != sz.height)) {
                input_blob->Reshape(shape[0], shape[1], sz.height, sz.width);
                net.Reshape();
            }
        }
        float *input_data = input_blob->mutable_cpu_data();
        float *e = preprocess(images, input_data);
        CHECK(e -input_data <= input_blob->count());
        net.ForwardPrefilled();

        // compute output dimension
        int dim = 0;
        for (auto const &b: output_blobs) {
            int d = b->count() / batch;
            LOG(INFO) << "output: " << b->shape_string();
            dim += d;
        }
        LOG(INFO) << "output size " << images.size() << " x " << dim;
        ft->resize(images.size() * dim);    // total output size
        int off = 0;
        for (auto const &b: output_blobs) {
            int blob_dim = b->count() / batch;
            float const *from_begin = b->cpu_data();
            for (int i = 0; i < images.size(); ++i) {
                float const *from_end = from_begin + blob_dim;
                std::copy(from_begin, from_end, &ft->at(i * dim + off));
                from_begin = from_end;
            }
            off += blob_dim;
        } 
        CHECK(off == dim);
    }
Example #18
0
char *longestPalindrome(char *s) {
	char *T = preprocess(s);
	int n = strlen(T);
	int *P = malloc(n * sizeof(int));
	memset(P, 0, n * sizeof(int));
	int C = 0, R = 0;

	for (int i = 1; i < n - 1; i++) {
		int i_mirror = 2 * C - i; // equals to i' = C - (i-C)

		P[i] = (R > i) ? (R - i < P[i_mirror] ? R - i : P[i_mirror]) : 0;

		// Attempt to expand palindrome centered at i
		while (T[i + 1 + P[i]] == T[i - 1 - P[i]])
			P[i]++;

		// If palindrome centered at i expand past R,
		// adjust center based on expanded palindrome.
		if (i + P[i] > R) {
			C = i;
			R = i + P[i];
		}
	}

	// Find the maximum element in P.
	int maxLen = 0;
	int centerIndex = 0;
	for (int i = 1; i < n - 1; i++) {
		if (P[i] > maxLen) {
			maxLen = P[i];
			centerIndex = i;
		}
	}
	char *pld = malloc((maxLen + 1) * sizeof(char));
	for (int i = 0; i < maxLen; i++) {
		pld[i] = T[centerIndex - maxLen + 2 * i + 1] + 'a';
		//pld[i] = 'a' + i + P[i];
	}
	pld[maxLen] = 0;
	free(T);
	free(P);
	return pld;

}
Example #19
0
void AbstractProcessor::run()
{
    Q_D(AbstractProcessor);
    if (!d->query.isValid()) {
        qWarning() << "Warning: the query is not valid";
        setError(tr("The query is not valid"));
        emit error();
        return;
    }

    PreprocessorData &preprocessorData = d->query.preprocessorData();
    bool ok = false;
    switch (d->processingTask) {
    case Preprocessing:
        preprocessorData.setPostData(processPostData(preprocessorData.data()));
        ok = preprocess();
        if (ok) {
            emit preprocessingFinished(d->needLoading);
        } else {
            emit error();
        }
        break;
    case PostProcessing:
        if (!d->dataSource) {
            qWarning() << "Warning: no data source provided";
            setError(tr("No data source provided"));
            emit error();
            return;
        }
        ok = processDataSource(d->dataSource);
        d->dataSource->deleteLater();
        if (ok) {
            emit postProcessingFinished();
        } else {
            emit error();
        }
        break;
    default:
        qWarning() << "Warning: no processing task set";
        setError(tr("No processing task set"));
        emit error();
        return;
    }
}
Example #20
0
int main(int argc, char *argv[], char *env[])
{
	IplImage *src;
	struct intern_bitmap *bm;
	int i;

	/* Argumente testen */
	if (argc == 1) {
		printf("usage: \n\t%s <ein Bild>\n",argv[0]);
		return 1;
	}

	/* init OpenCV */
  #ifdef DEBUG
	cvInitSystem(argc, argv);
  #endif

	for (i = 1; i < argc; i++ ) {
		/* Bild Lesen */
		src = cvLoadImage(argv[i], CV_LOAD_IMAGE_GRAYSCALE);
		if (!src) {
			printf("Error: cvLoadImage()\n");
			return 1;
		}

		/* das original Bild anzeigen */
    #ifdef DEBUG
		cvNamedWindow("Demo Window", CV_WINDOW_AUTOSIZE);
		cvShowImage("Demo Window", src);
		cvWaitKey(-1);
		cvDestroyWindow("Demo Window");
    #endif

		bm = preprocess(src);
		ocr_bestpassend(bm, ergebnis, ERGEBNIS_LAENGE);
		bm_release(bm);

		cvReleaseData(src);

		printf("Ergebnis: %s\n", ergebnis);

	}
	return 0;
}
Example #21
0
bool cpp_languaget::parse(
  const std::string &path,
  message_handlert &message_handler)
{
  // store the path

  parse_path=path;

  // preprocessing

  std::ostringstream o_preprocessed;

  internal_additions(o_preprocessed);

  if(preprocess(path, o_preprocessed, message_handler))
    return true;

  std::istringstream i_preprocessed(o_preprocessed.str());

  // parsing

  cpp_parser.clear();
  cpp_parser.filename=path;
  cpp_parser.in=&i_preprocessed;
  cpp_parser.set_message_handler(&message_handler);
  cpp_parser.grammar=cpp_parsert::LANGUAGE;

  if(config.ansi_c.os==configt::ansi_ct::OS_WIN32)
    cpp_parser.mode=cpp_parsert::MSC;
  else
    cpp_parser.mode=cpp_parsert::GCC;

  cpp_scanner_init();

  bool result=cpp_parser.parse();

  // save result
  cpp_parse_tree.swap(cpp_parser.parse_tree);

  // save some memory
  cpp_parser.clear();

  return result;
}
Example #22
0
int main(int argc, char** argv)
{
	/* If no args are specified... */
	if (argc == 1)
	{
		puts(HELP_MSG);
		return 1;
	}

	/* Set defaults */
	os_detect();
	g_filename = DEFAULT;
	g_cc       = NULL;
	g_dotnet   = NULL;
	g_verbose  = 0;

	/* Process any options that will effect script processing */
	arg_set(argc, argv);
	if (!preprocess())
		return 1;

	/* chdir() to the directory containing the project script, so that
	 * relative paths may be used in the script */
	io_chdir(path_getdir(g_filename));

	/* Now run the script */
	g_hasScript = script_run(g_filename);
	if (g_hasScript < 0)
	{
		puts("** Script failed to run, ending.");
		return 1;
	}

	/* Process any options that depend on the script output */
	arg_reset();
	if (!postprocess())
		return 1;

	/* All done */
	if (g_hasScript)
		script_close();
	prj_close();
	return 0;
}
Example #23
0
int main(int argc, char const *argv[])
{
	preprocess();
	s(T);
	while(T--)
	{
		s(N);
		int startind=(N*(N-1))/2;
		float t=0;
		int c=0;
		for (int i = 0; i < N; ++i)
		{
			s(c);
			t+=c*coeffs[startind+i];
		}				
		printf("%.3f\n",t);
	}
	return 0;
}
Example #24
0
void UvdState::processK2(K2 k2)
{
    preprocess(k2.ri.time);

    if (k2.ri.confidence == 3)
    {
        m_recvStats.k2Conf3Lines++;
    }
    else
    {
        m_recvStats.k2Conf4Lines++;
    }

    lock();
    m_points.push_back(k2);
    unlock();

    postprocess(k2.ri.time);
}
Example #25
0
int main(int argc, const char *argv[])
{
    int fd_server, fd_client;
    int reuse = 1; 
    struct sockaddr_in client_addr;
    int addrlen = sizeof(client_addr);

    preprocess(&fd_server);

    if((fd_client = accept(fd_server, (struct sockaddr*)&client_addr, &addrlen)) == -1)
        ERR_EXIT("accept");

    do_service(fd_client);

    close(fd_client);
    close(fd_server);
   
    return 0;
}
Example #26
0
int main(int argc, char **argv)
{
    const char *outdir;
    if(argc <= 1)
        usage();

    while(1)
    {
        static struct option long_options[] =
        {
            {"help", no_argument, 0, '?'},
            {0, 0, 0, 0}
        };

        int c = getopt_long(argc, argv, "?o:", long_options, NULL);
        if(c == -1)
            break;
        switch(c)
        {
            case -1:
                break;
            case '?':
                usage();
                break;
            case 'o':
                outdir = optarg;
                break;
            default:
                abort();
        }
    }
    if(argc == optind)
    {
        printf("You need at least one header file file\n");
        return 3;
    }
    if(outdir == 0)
        printf("Warning: no output directory, dry run.\n");
    for(int i = optind; i < argc; i++)
        if(!preprocess(argv[i], outdir))
            return 1;
    return 0;
}
Example #27
0
File: kmp.c Project: Leggy/udoodev
/*Search the text for the first appearance of the pattern.*/
size_t kmpSearch(const char *text, const char *pattern)
{
	size_t m = 0;
	size_t i = 0;
	size_t patternLength = strlen(pattern);
	size_t textLen = strlen(text);
	size_t ret = textLen;
	size_t incr = 0;

	size_t *table = preprocess(pattern);
	if(!table)
		return textLen;

	while((m + i) < textLen)
	{
		//fprintf(stderr, "((m + i) < textLen\n");
		//fprintf(stderr, "%zu < %zu\n", (m + i), textLen);
		if(pattern[i] == text[m+i])
		{
			if(i == (patternLength - 1))
			{
				ret = m;
				break;
			}
			++i;
		}
		else
		{
			incr = 1 - table[i];
			//fprintf(stderr, "%zu\n", ( 1 - table[i]));
			if (!incr) {
				free(table);
				return ret;
			}
			m += incr;
			i = table[i];
		}
	}

	free(table);
	return ret;
}
boost::shared_ptr<cuNDArray<float_complext> > gpuBufferSensePrepGadget::reconstruct_regularization(
		cuNDArray<float_complext>* data, cuNDArray<floatd2>* traj, cuNDArray<float>* dcw, size_t ncoils ) {

	if (dcw) { //We have density compensation, so we can get away with gridding

		cuNFFT_plan<float,2> plan(from_std_vector<size_t,2>(image_dims_recon_),image_dims_recon_os_,kernel_width_);
		std::vector<size_t> csm_dims = image_dims_recon_;
		csm_dims.push_back(ncoils);
		auto result = new cuNDArray<float_complext>(csm_dims);
		GDEBUG("Coils %i \n\n",ncoils);

		std::vector<size_t> flat_dims = {traj->get_number_of_elements()};
		cuNDArray<floatd2> flat_traj(flat_dims,traj->get_data_ptr());
		GDEBUG("traj: %i data %i\n",traj->get_number_of_elements(),data->get_number_of_elements());
		GDEBUG("Preprocessing\n\n");
		plan.preprocess(&flat_traj,cuNFFT_plan<float,2>::NFFT_PREP_NC2C);
		GDEBUG("Computing\n\n");
		plan.compute(data,result,dcw,cuNFFT_plan<float,2>::NFFT_BACKWARDS_NC2C);

		return boost::shared_ptr<cuNDArray<float_complext>>(result);

	} else { //No density compensation, we have to do iterative reconstruction.
		std::vector<size_t> csm_dims = image_dims_recon_;
		csm_dims.push_back(ncoils);

		auto E = boost::make_shared<cuNFFTOperator<float,2>>();

		E->setup(from_std_vector<size_t,2>(image_dims_recon_),image_dims_recon_os_,kernel_width_);
		std::vector<size_t> flat_dims = {traj->get_number_of_elements()};
		cuNDArray<floatd2> flat_traj(flat_dims,traj->get_data_ptr());

		E->set_domain_dimensions(&csm_dims);
		cuCgSolver<float_complext> solver;
		solver.set_max_iterations(0);
		solver.set_encoding_operator(E);
		solver.set_output_mode(cuCgSolver<float_complext>::OUTPUT_VERBOSE);
		E->set_codomain_dimensions(data->get_dimensions().get());
		E->preprocess(&flat_traj);
		auto res = solver.solve(data);
		return res;
	}
}
Example #29
0
int
main(int argc, char** argv)
{
	std::cout << std::endl << "γ-ray version 0.2" << std::endl << std::endl;

	try
	{
		const rt::configuration_t configuration = configure(argc, argv);
		const rt::rendering::writer_t write = rt::rendering::make_writer(configuration.output);
		const rt::scene::instance_t scene = preprocess(configuration);
		const rt::rendering::image_t image = render(configuration, scene);
		postprocess(write, image);
		return EXIT_SUCCESS;
	}
	catch (const std::exception& exception)
	{
		std::cerr << "Error: " << exception.what() << std::endl;
		return EXIT_FAILURE;
	}
}
Example #30
0
static void test_color_graph_backtrack(void) {
    init_test_exam_2();
    exam *test_exams[] = {exam1, exam2, exam3};
    init_test_array_exams(3, test_exams);
    preprocess(exams);
    init_test_array_rooms();
    uint8_t max_room_type = 3;
    size_t **rooms_limit = get_rooms_sizes(FACULTY_SIZE, max_room_type, rooms);
    matrix_rooms *matrix_rooms = get_rooms_matrix(FACULTY_SIZE, max_room_type, rooms,
                                 rooms_limit);
    bool result = color_graph_backtrack(exams, matrix_rooms, FACULTY_SIZE, max_room_type,
                                        MAX_TIMESLOT);
    CU_ASSERT_TRUE(result);
    /* Expected : E1 : 1, E2: 3, E3 : 2 */
    CU_ASSERT_EQUAL(exams->data[0]->timeslot, 0);
    CU_ASSERT_EQUAL(exams->data[1]->timeslot, 2);
    CU_ASSERT_EQUAL(exams->data[2]->timeslot, 1);
    clean_test_room();
    clean_array_exams_2();
}