예제 #1
0
/*
 * makesearchpart: make search part
 *
 *	@param[in]	target	$target
 *	@return		html
 */
static char *
makesearchpart(const char *target)
{
	STATIC_STRBUF(sb);

	strbuf_clear(sb);
	strbuf_puts(sb, header_begin);
	if (Fflag)
		strbuf_puts(sb, gen_href_begin(NULL, "search", normal_suffix, NULL));
	strbuf_puts(sb, "SEARCH");
	if (Fflag)
		strbuf_puts(sb, gen_href_end());
	strbuf_puts_nl(sb, header_end);
	if (!target) {
		strbuf_puts(sb, "Please input object name and select [Search]. POSIX's regular expression is allowed.");
		strbuf_puts_nl(sb, br);
	}
	strbuf_puts_nl(sb, gen_form_begin(target));
	strbuf_puts_nl(sb, gen_input("pattern", NULL, NULL));
	strbuf_puts_nl(sb, gen_input(NULL, "Search", "submit"));
	strbuf_puts(sb, gen_input(NULL, "Reset", "reset"));
	strbuf_puts_nl(sb, br);
	strbuf_puts(sb, gen_input_radio("type", "definition", 1, "Retrieve the definition place of the specified symbol."));
	strbuf_puts_nl(sb, target ? "Def" : "Definition");
	strbuf_puts(sb, gen_input_radio("type", "reference", 0, "Retrieve the reference place of the specified symbol."));
	strbuf_puts_nl(sb, target ? "Ref" : "Reference");
	strbuf_puts(sb, gen_input_radio("type", "symbol", 0, "Retrieve the place of the specified symbol is used."));
	strbuf_puts_nl(sb, target ? "Sym" : "Other symbol");
	strbuf_puts(sb, gen_input_radio("type", "path", 0, "Look for path name which matches to the specified pattern."));
	strbuf_puts_nl(sb, target ? "Path" : "Path name");
	if (enable_grep) {
		strbuf_puts(sb, gen_input_radio("type", "grep", 0, "Retrieve lines which matches to the specified pattern."));
		strbuf_puts_nl(sb, target ? "Grep" : "Grep pattern");
	}
	if (enable_idutils && test("f", makepath(dbpath, "ID", NULL))) {
		strbuf_puts(sb, gen_input_radio("type", "idutils", 0, "Retrieve lines which matches to the specified pattern using idutils(1)."));
		strbuf_puts_nl(sb, target ? "Id" : "Id pattern");
	}
	strbuf_puts_nl(sb, br);
	strbuf_puts(sb, gen_input_checkbox("icase", NULL, "Ignore case distinctions in the pattern."));
	strbuf_puts_nl(sb, target ? "Icase" : "Ignore case");
	if (other_files) {
		strbuf_puts(sb, gen_input_checkbox("other", NULL, "Files other than the source code are also retrieved."));
		strbuf_puts_nl(sb, target ? "Other" : "Other files");
	}
	if (other_files && !target) {
		strbuf_puts_nl(sb, br);
		strbuf_puts(sb, "('Other files' is effective only to 'Path name'");
		if (enable_grep)
			strbuf_puts(sb, " and 'Grep pattern'");
		strbuf_puts_nl(sb, ".)");
	}
	strbuf_puts_nl(sb, gen_form_end());
	return strbuf_value(sb);
}
예제 #2
0
int main (int argc, char **argv) {

    if (argc != 4) {
        print_help_message(argv);
        exit(1);
    }

    int n, choice;

    choice = atoi(argv[1]);
    n = atoi(argv[2]);

    validate_inputs(n, choice);

    int *A;
    A = (int *) malloc(n * sizeof(int));
    assert(A != 0);

    int input_type = atoi(argv[3]);
    assert(input_type >= 0);
    assert(input_type <= 4);

    gen_input(A, n, input_type);

    int num_iterations = 10;
   
    sort_routines(choice, A, n, num_iterations);
    //insertion_sort(A, n, num_iterations);

    free(A);

    return 0;
}
예제 #3
0
int main(int argc, char **argv) {

    if (argc != 4) {
        fprintf(stderr, "%s <n> <input_type> <alg_type>\n", argv[0]);
        fprintf(stderr, "input_type 0: uniform random\n");
        fprintf(stderr, "           1: already sorted\n");
        fprintf(stderr, "           2: almost sorted\n");
        fprintf(stderr, "           3: single unique value\n");
        fprintf(stderr, "           4: sorted in reverse\n");
        fprintf(stderr, "alg_type 0: use C qsort\n");
        fprintf(stderr, "         1: use inline qsort\n");
        exit(1);
    }

    int n;

    n = atoi(argv[1]);

    assert(n > 0);
    assert(n <= 1000000000);

    float *A;
    A = (float *) malloc(n * sizeof(float));
    assert(A != 0);

    int input_type = atoi(argv[2]);
    assert(input_type >= 0);
    assert(input_type <= 4);

    gen_input(A, n, input_type);

    int alg_type = atoi(argv[3]);

    int num_iterations = 10;
    
    assert((alg_type == 0) || (alg_type == 1));

    if (alg_type == 0) {
        qsort_serial(A, n, num_iterations);
    } else if (alg_type == 1) {    
        inline_qsort_serial(A, n, num_iterations);
    }

    free(A);

    return 0;
}
예제 #4
0
파일: pattern.c 프로젝트: Mougatine/ocr
char ask_nn(struct net nwk, t_img_desc *img)
{
    assert(img->comp == 1);

    if (img->x != 20 || img->y != 20) {
        uchar *ptr = malloc(sizeof(char) * 20 * 20);
        stbir_resize_uint8(img->data, img->x, img->y, 0, ptr, 20, 20, 0, 1);

        img->data = ptr;
        img->x = 20;
        img->y = 20;
        img->comp = 1;
    }

    double in[400];
    gen_input(img, in);

    net_compute(nwk, in);
    double *out = net_output(nwk);
    return convert_output(out, 52);
}
예제 #5
0
파일: pattern.c 프로젝트: Mougatine/ocr
struct training load_pattern(char *dir)
{
    char path[2048];
    char filename[2048];
    t_img_desc *img;

    strcpy(path, dir);
    for (dir = path; *dir; ++dir);
    if (*(--dir) != '/')
        strcat(path, "/");

    const size_t n_font = 7;
    const size_t n_letter = 52;
    const size_t n_set = n_letter * n_font;
    const size_t size_in = 400;
    const size_t size_out = 52;

    struct training t = { NULL, NULL, n_set, size_in, size_out };
    t.in = malloc(sizeof(double) * t.n_in * t.n_set);
    assert(t.in);
    t.out = malloc(sizeof(double) * t.n_out * t.n_set);
    assert(t.out);

    for (size_t f = 0; f < n_font; ++f) {
        /* Lower */
        for (size_t l = 0; l < n_letter / 2; ++l) {
            sprintf(filename, "%s%s/%c/%lu.png", path, "lower",
                    (char)l+'A', f);

            img = load_image(filename, 1);
            printf("[INFO] Load %s (%ix%i -- %i)\n", filename,
                    img->x, img->y, img->comp);

            process_pattern(img, 1);

            size_t line = l + f * n_letter;
            gen_input(img, get_in(&t, line));
            gen_output(get_out(&t, line), size_out, (char)l+'a');

            free_image(img);
        }

        /* Upper */
        for (size_t l = 0; l < n_letter / 2; ++l) {
            sprintf(filename, "%s%s/%c/%lu.png", path, "upper",
                    (char)l+'A', f);

            img = load_image(filename, 1);
            printf("[INFO] Load %s (%ix%i -- %i)\n", filename,
                    img->x, img->y, img->comp);

            process_pattern(img, 1);

            size_t line = (l + 26) + f * n_letter;
            gen_input(img, get_in(&t, line));
            gen_output(get_out(&t, line), size_out, (char)l+'A');

            free_image(img);
        }
    }

    return t;
}
예제 #6
0
파일: gen_input.cpp 프로젝트: ElaraFX/tbb
void generate_if_needed( const char *fname ) {
    if ( access(fname, F_OK) != 0 )
        gen_input(fname);
}
예제 #7
0
파일: codegen.c 프로젝트: dougives/lilium
void* gen_xop_set(BoundBuffer* boundbuffer)
{
	uint32_t random = 0;
	void* pages = VirtualAlloc(
		NULL,
		BLOCK_SIZE,
		MEM_COMMIT | MEM_RESERVE,
		PAGE_EXECUTE_READWRITE);
	if (pages == NULL)
		return NULL;

	uint8_t* nextfree = (uint8_t*)pages;
	nextfree += gen_header((void*)nextfree);

	while (nextfree < (uint8_t*)pages + BLOCK_SIZE - MAX_GEN_SIZE - 1)
	{
		boundbuffer->bounds[boundbuffer->free] = (void*)nextfree;
		rand_s(&random);
		random &= 0x0f;
		switch (random)
		{
		case 0x0f:
			nextfree += gen_input((void*)nextfree);
			break;

		case 0x00:
			nextfree += gen_output((void*)nextfree);
			break;

		case 0x01:
			nextfree += gen_xop_vprot((void*)nextfree);
			break;

		case 0x02:
			nextfree += gen_xop_vpcom((void*)nextfree);
			nextfree += gen_xop_vpcmov((void*)nextfree);
			break;

		case 0x03:
			if (boundbuffer->count > MIN_LOOP_SIZE * 4)
			{
				nextfree += gen_sse41_ptest((void*)nextfree);
				nextfree += gen_jcc((void*)nextfree, boundbuffer);
				break;
			}

		default:
			nextfree += gen_xop_vpperm((void*)nextfree);
			break;
		}

		if (boundbuffer->count < BOUND_BUFFER_SIZE)
			boundbuffer->count++;
		boundbuffer->free = ++boundbuffer->free & BOUND_BUFFER_MASK;
	}

	// return pointer to end of output ...
	// mov rax, rdx
	// ret

	*((uint32_t*)nextfree++) = 0xc3c28b48u;
	nextfree--;
	while (!*++nextfree
		&& nextfree < (uint8_t*)pages + BLOCK_SIZE - 1)
	{
		*nextfree = 0xcc;
	}
	return pages;
}
예제 #8
0
int main (int argc, char* argv[]) {
    if (argc <= 2) {
        print_usage(argv);
        exit(1);
    }

    struct comp_params p = parse_params("./bin/" + string(NAME) + ".params");

    mpz_t prime;
    mpz_init_set_str(prime, "21888242871839275222246405745257275088548364400416034343698204186575808495617", 10);



    if (!strcmp(argv[1], "setup")) {
        if (argc != 4 && argc != 5) {
            print_usage(argv);
            exit(1);
        }
        string verification_key_fn = std::string(v_dir) + argv[2];
        string proving_key_fn = std::string(p_dir) + argv[3];
        string unprocessed_vkey_fn;
        if (argc == 5) {
            unprocessed_vkey_fn = std::string(v_dir) + argv[4];
        }
        std::cout << "Creating proving/verification keys, will write to " << verification_key_fn
                  << ", " << proving_key_fn << std::endl;
        run_setup(p.n_constraints, p.n_inputs, p.n_outputs, p.n_vars, prime, verification_key_fn, proving_key_fn, unprocessed_vkey_fn);
    }
    else if (!strcmp(argv[1], "gen_input")) {
        if (argc < 3) {
            print_usage(argv);
            exit(1);
        }

        std::string input_filename = std::string(shared_dir) + argv[2];
        std::cout << "Generating inputs, will write to " << input_filename << std::endl;

        mpq_t * input_q;
        alloc_init_vec(&input_q, p.n_inputs);

        gen_input(input_q, p.n_inputs, argv);

        std::ofstream inputs_file(input_filename);

        for (int i = 0; i < p.n_inputs; i++) {
            inputs_file << input_q[i] << std::endl;
        }
        inputs_file.close();

        clear_del_vec(input_q, p.n_inputs);
    }
    else if(!strcmp(argv[1], "verify")) {
        if(argc != 6) {
            print_usage(argv);
            exit(1);
        }
        std::string verification_key_fn = std::string(v_dir) + argv[2];
        std::string inputs_fn = std::string(shared_dir) + argv[3];
        std::string outputs_fn = std::string(shared_dir) + argv[4];
        std::string proof_fn = std::string(shared_dir) + argv[5];
        verify(verification_key_fn, inputs_fn, outputs_fn, proof_fn, p.n_inputs, p.n_outputs, prime);
    }
    else {
        print_usage(argv);
        exit(1);
    }
}