コード例 #1
0
ファイル: init_eye.c プロジェクト: athomaj/rtracer
int		create_eye(t_all *all, t_list *list, FILE *fd, int *err)
{
  char		*str;
  int		i;

  list = NULL;
  i = 0;
  while ((str = get_next_line_custom(fd)) != NULL && ++ i > 0 &&
	 lexer(&list, str) != -1 && the_end(list, "EYE") == -1)
    {
      if ((strcmp("pos", (list = list->next)->lexeme) == 0 &&
	   init_coords(list->next, &all->eye.pos) == -1) ||
	  (strcmp("rot", list->lexeme) == 0 &&
	   init_coords(list->next, &all->eye.rot) == -1) ||
	  (strcmp("rot", list->lexeme) != 0 &&
	   strcmp("pos", list->lexeme) != 0))
	*err = -1;
      free_things(list, str);
      if (*err == -1)
	return (-1);
      list = NULL;
    }
  if (the_end(list, "EYE") == 0)
    return (i);
  *err = -1;
  return (i);
}
コード例 #2
0
ファイル: part1.c プロジェクト: MrTerrorbyte/cs241-fa13
/**
 * (Edit this function to print out the ten "Illinois" lines in mp1-functions.c in order.)
 */
int main()
{

	first_step(81);
	
	int * two= malloc(sizeof(int));
	*two= 132;
	second_step(two);
	free(two);
	
	int ** three= malloc(sizeof(int *));
	three[0]= malloc(sizeof(int));
	*three[0]= 8942;
	double_step(three);
	free(three[0]);
	free(three);

	int * four=0;	
	strange_step(four);

	char * five= calloc(4,sizeof(char));
	empty_step((void*)(five));
	free(five);

	char * s2= calloc(4,sizeof(char));
	s2[3]='u';
	void * s= s2;
	two_step(s, s2);
	free(s2);

	char * first= 0;
	char * second= first+2;
	char * third= second+2;
	three_step(first, second, third);	

	first= calloc(2,sizeof(char));
	first[1]= 0;
	second= malloc(3*sizeof(char));
	second[2]= first[1]+8;
	third= malloc(4*sizeof(char));
	third[3]= second[2]+8;
	step_step_step(first, second, third);
	free(first);
	free(second);
	free(third);

	char * nine= malloc(sizeof(char));
	*nine= 1;
	it_may_be_odd(nine, 1);	
	free(nine);

	int * orange= malloc(sizeof(int));
	*orange= 513;
	int * blue= orange;
	the_end((void *)orange,(void *) blue);	
	//printf("temp= %d\n", (*temp));
	free(orange);
	return 0;
}
コード例 #3
0
ファイル: field.C プロジェクト: jayant91089/orbiter-mod
int main(int argc, char **argv)
{
	INT verbose_level = 0;
	INT i;
	INT f_q = FALSE;
	INT q = 0;
	INT xmax = 300;
	INT ymax = 300;
	INT f_type = FALSE;
	INT type = 0;
	INT param_a = 0;
	
 	t0 = os_ticks();
	
	for (i = 1; i < argc - 1; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		else if (strcmp(argv[i], "-q") == 0) {
			f_q = TRUE;
			q = atoi(argv[++i]);
			cout << "-q " << q << endl;
			}
		else if (strcmp(argv[i], "-type") == 0) {
			f_type = TRUE;
			type = atoi(argv[++i]);
			param_a = atoi(argv[++i]);
			cout << "-type " << type << endl;
			}
		else if (strcmp(argv[i], "-x") == 0) {
			xmax = atoi(argv[++i]);
			cout << "-x " << xmax << endl;
			}
		else if (strcmp(argv[i], "-y") == 0) {
			ymax = atoi(argv[++i]);
			cout << "-y " << ymax << endl;
			}
		}
	if (!f_q) {
		cout << "please use option -q <q>" << endl;
		exit(1);
		}
	if (!f_type) {
		cout << "please use option -type <type>" << endl;
		exit(1);
		}
	draw_empty_grid(q, type, param_a, xmax, ymax, verbose_level);

	the_end(t0);
}
コード例 #4
0
/**
 * (Edit this function to print out the ten "Illinois" lines in functions.c in order.)
 */
int main()
{
	first_step(81);
	
	int second_value = 132;
	int *second_p = &second_value;
	second_step(second_p);

	
	int third_value = 8942;
	int *third_p = &third_value;
	int **third_pp = &third_p;
	double_step(third_pp);

	int *forth_value = 0;
	strange_step(forth_value);

	void *fifth_value[] = {0, 0, 0, 0};
	empty_step(fifth_value);
	
	char *s2 = "uuuu";
	void *s = s2;
	two_step(s, s2);
	
	char *first, *second, *third;
	first = 0;
	second = first + 2;
	third = second + 2;
	three_step(first, second, third);
		
	char *arr = malloc(4*sizeof(char));
	arr[1] = 'a';
	arr[2] = arr[1] + 8;
	arr[3] = arr[2] + 8;
	step_step_step(arr, arr, arr);
	free(arr);
	
	int b = 1;
	void *a = &b;
	it_may_be_odd(a, b);	
	
	int end = 1281;
	void *orange, *blue;
	orange = blue = &end;
	the_end(orange, blue);	
	
	return 0;
}
コード例 #5
0
ファイル: had.C プロジェクト: SALAM2016/orbiter
int main(int argc, char **argv)
{
	INT i;
	INT verbose_level = 0;
	
 	t0 = os_ticks();
	
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		}

	do_it(verbose_level);

	the_end(t0);

}
コード例 #6
0
ファイル: codes.C プロジェクト: jayant91089/orbiter-mod
int main(int argc, const char **argv)
{
    cout << version << endl;
    t0 = os_ticks();


    {
        code_generator cg;

        cg.init(argc, argv);

        cg.main();

        //cg.gen->print_tree();

    }
    the_end(t0);
    //the_end_quietly(t0);
}
コード例 #7
0
ファイル: game_launcher.cpp プロジェクト: doofus-01/wesnoth
void game_launcher::launch_game(RELOAD_GAME_DATA reload)
{
	assert(!load_data_);
	if(play_replay_)
	{
		play_replay();
		return;
	}

	gui2::dialogs::loading_screen::display(video(), [this, reload]() {

		gui2::dialogs::loading_screen::progress("load data");
		if(reload == RELOAD_DATA) {
			try {
				game_config_manager::get()->
					load_game_config_for_game(state_.classification());
			} catch(config::error&) {
				return;
			}
		}
	});

	try {
		campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
		LEVEL_RESULT result = ccontroller.play_game();
		// don't show The End for multiplayer scenario
		// change this if MP campaigns are implemented
		if(result == LEVEL_RESULT::VICTORY && !state_.classification().is_normal_mp_game()) {
			preferences::add_completed_campaign(state_.classification().campaign, state_.classification().difficulty);
			the_end(video(), state_.classification().end_text, state_.classification().end_text_duration);
			if(state_.classification().end_credits) {
				gui2::dialogs::end_credits::display(video(), state_.classification().campaign);
			}
		}
	} catch (savegame::load_game_exception &e) {
		load_data_.reset(new savegame::load_game_metadata(std::move(e.data_)));
		//this will make it so next time through the title screen loop, this game is loaded
	} catch(wml_exception& e) {
		e.show(video());
	} catch(mapgen_exception& e) {
		gui2::show_error_message(video(), _("Map generator error: ") + e.message);
	}
}
コード例 #8
0
ファイル: part2-main.c プロジェクト: cwang100/class-projects
/**
 * (Edit this function to print out the ten "Illinois" lines in part2-functions.c in order.)
 */
int main()
{
	first_step(81);
	int x = 132;
	int* y = &x;
	second_step(y);
	int *ww[1];
	*y = 8942;
	ww[0] = y;
	
	double_step(ww);
	void* ss = malloc(sizeof(int)*15);

	*(int*)(ss+5) = 15;
	strange_step(ss);
	*(char*)(ss+3) = 0;
	empty_step(ss);
	char a[4];
	a[3] = 'u';
	void* wwww;
	wwww = (void* )a;
	two_step(wwww, a); 
	
	three_step(a,a+2,a+4);
	free(ss);
	char b[4];
	b[1] = 'A';
	b[2] = 'A'+8;
	b[3] = 'A'+16;
	step_step_step(b,b,b);
	int sd = 'A';
	it_may_be_odd(b+(sizeof(char)), sd);
	char i[] = "C,CS241,41";
	tok_step(i);
	
	void* www;	
	x = 4353;
	www = (void*)&x;
	the_end(www,www);
	
	return 0;
}
コード例 #9
0
ファイル: game_launcher.cpp プロジェクト: ArtBears/wesnoth
void game_launcher::launch_game(RELOAD_GAME_DATA reload)
{
	if(play_replay_)
	{
		play_replay();
		return;
	}

	gui2::tloadscreen::display(video(), [this, reload]() {

		gui2::tloadscreen::progress("load data");
		if(reload == RELOAD_DATA) {
			try {
				game_config_manager::get()->
					load_game_config_for_game(state_.classification());
			} catch(config::error&) {
				return;
			}
		}
	});

	try {
		campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
		LEVEL_RESULT result = ccontroller.play_game();
		// don't show The End for multiplayer scenario
		// change this if MP campaigns are implemented
		if(result == LEVEL_RESULT::VICTORY && !state_.classification().is_normal_mp_game()) {
			preferences::add_completed_campaign(state_.classification().campaign, state_.classification().difficulty);
			the_end(video(), state_.classification().end_text, state_.classification().end_text_duration);
			if(state_.classification().end_credits) {
				about::show_about(video(),state_.classification().campaign);
			}
		}

		clear_loaded_game();
	} catch (game::load_game_exception &) {
		//this will make it so next time through the title screen loop, this game is loaded
	} catch(twml_exception& e) {
		e.show(video());
	}
}
コード例 #10
0
// Check for any problems with WeakPtrFactory class members. This currently
// only checks that any WeakPtrFactory<T> member of T appears as the last
// data member in T. We could consider checking for bad uses of
// WeakPtrFactory to refer to other data members, but that would require
// looking at the initializer list in constructors to see what the factory
// points to.
// Note, if we later add other unrelated checks of data members, we should
// consider collapsing them in to one loop to avoid iterating over the data
// members more than once.
void FindBadConstructsConsumer::CheckWeakPtrFactoryMembers(
    SourceLocation record_location,
    CXXRecordDecl* record) {
  // Skip anonymous structs.
  if (record->getIdentifier() == NULL)
    return;

  // Iterate through members of the class.
  RecordDecl::field_iterator iter(record->field_begin()),
      the_end(record->field_end());
  SourceLocation weak_ptr_factory_location;  // Invalid initially.
  for (; iter != the_end; ++iter) {
    // If we enter the loop but have already seen a matching WeakPtrFactory,
    // it means there is at least one member after the factory.
    if (weak_ptr_factory_location.isValid()) {
      diagnostic().Report(weak_ptr_factory_location,
                          diag_weak_ptr_factory_order_);
    }
    const TemplateSpecializationType* template_spec_type =
        iter->getType().getTypePtr()->getAs<TemplateSpecializationType>();
    if (template_spec_type) {
      const TemplateDecl* template_decl =
          template_spec_type->getTemplateName().getAsTemplateDecl();
      if (template_decl && template_spec_type->getNumArgs() >= 1) {
        if (template_decl->getNameAsString().compare("WeakPtrFactory") == 0 &&
            GetNamespace(template_decl) == "base") {
          const TemplateArgument& arg = template_spec_type->getArg(0);
          if (arg.getAsType().getTypePtr()->getAsCXXRecordDecl() ==
              record->getTypeForDecl()->getAsCXXRecordDecl()) {
            weak_ptr_factory_location = iter->getLocation();
          }
        }
      }
    }
  }
}
コード例 #11
0
ファイル: conic.C プロジェクト: SALAM2016/orbiter
int main(int argc, char **argv)
{
	INT verbose_level = 0;
	INT i;
	
 	t0 = os_ticks();
	
	for (i = 1; i < argc - 1; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		}

	INT q = 8;
	INT five_pts[] = {48,55,38,29,60};

	determine_conic(q, NULL /* override_poly */, five_pts, 5, verbose_level);


	//draw_empty_grid(5, TRUE /* INT f_include_line_at_infinity  */,  0); exit(1);
	//LunelliSce(verbose_level);


	//INT six_coeffs[] = { 3, 1, 2, 4, 1, 4 }; INT f_do_stabilizer = FALSE;

	//INT six_coeffs[] = { 0, 1, 0, 0, 6, 0 }; INT f_do_stabilizer = FALSE;



	//INT six_coeffs[] = { 0, 1, 0, 0, 1, 0 }; INT q = 4; INT f_do_stabilizer = FALSE; 
	// Y^2 = XZ


	//INT six_coeffs[] = { 0, 1, 0, 0, 1, 0 }; INT q = 8; INT f_do_stabilizer = TRUE;
	// Y^2 = XZ PROBLEM in set_stabilizer !!!
	
	//INT six_coeffs[] = { 0, 1, 0, 0, 4, 0 }; INT q = 5; INT f_do_stabilizer = FALSE;

	//INT six_coeffs[] = { 1, 1, 0, 1, 1, 0 }; INT q = 5; INT f_do_stabilizer = FALSE;
	
	// Osaka homework problem:
	//INT six_coeffs[] = { 1, 6, 1, 0, 0, 1 }; INT q = 7; INT f_do_stabilizer = FALSE;
	//INT xmax = 270; INT ymax = 270;


	// Osaka homework problem:
	// X^2 + Y^2 = Z^2 mod 13 (affine: x^2 + y^2 = 1, ellipse, 2 pts at infinity)
	//INT six_coeffs[] = { 1, 1, 12, 0, 0, 0  }; INT q = 13; INT f_do_stabilizer = FALSE;
	//INT xmax = 400; INT ymax = 400;


	//INT six_coeffs[] = { 0, 1, 0, 0, 12, 0  }; INT q = 13; INT f_do_stabilizer = FALSE;
	// Y^2 = XZ mod 13 

	//INT six_coeffs[] = { 1, 0, 0, 0, 0, 12  }; INT q = 13; INT f_do_stabilizer = FALSE;
	// X^2 = YZ mod 13 (affine: y = x^2, parabola, 1 pt at infinity)
	
	//INT six_coeffs[] = { 0, 0, 1, 12, 0, 0  }; INT q = 13; INT f_do_stabilizer = FALSE;
	// XY = Z^2 mod 13 (affine: y = 1/x, hyperbola, 2 pts at infinity)

	//INT six_coeffs[] = { 1, 1, 6, 0, 0, 0  }; INT q = 7; INT f_do_stabilizer = FALSE;
	// X^2 + Y^2 = Z^2 mod 7 (affine: x^2 + y^2 = 1, ellipse, 0 pts at infinity)
	
	//INT six_coeffs[] = { 1, 1, 10, 0, 0, 0  }; INT q = 11; INT f_do_stabilizer = FALSE;
	// X^2 + Y^2 = Z^2 mod 11 (affine: x^2 + y^2 = 1, ellipse, 0 pts at infinity)
	
	//INT six_coeffs[] = { 1, 1, 12, 0, 0, 0  }; INT q = 13; INT f_do_stabilizer = FALSE;
	// X^2 + Y^2 = Z^2 mod 13 (affine: x^2 + y^2 = 1, ellipse, 2 pts at infinity)

	//INT six_coeffs[] = { 1, 0, 0, 0, 0, 2  }; INT q = 27; INT f_do_stabilizer = FALSE;
	// X^2 = YZ in GF(27) (affine: y = x^2, parabola, 1 pt at infinity)
	
	//INT six_coeffs[] = { 1, 2, 3, 4, 5, 6  }; INT q = 17; INT f_do_stabilizer = FALSE; 
	// 
	
	//conic(q, six_coeffs, xmax, ymax, f_do_stabilizer, verbose_level);
	
	the_end(t0);
}
コード例 #12
0
ファイル: part2-main.c プロジェクト: mrlevitas/first-repo
/**
 * (Edit this function to print out the ten "Illinois" lines in part2-functions.c in order.)
 */
int main()
{
	//1
	first_step(81);

	//2
	int two = 132;
	second_step( &two );

	//3  ????

	int three =8942;
	int * threeP = &three;

	double_step(&threeP);

	//4
	int * four = 0;	
	strange_step(four);

	//5
	char five[4];
	five[3] =0;
	empty_step(five);

	//6
	char * six1, six2[4];
	six2[3] = 'u';
	six1= six2;	
	
	two_step(six1, six2);

	//7

	char * seven1;
	char * seven2;
	char * seven3;
	//seven2 = malloc(sizeof(char));
	seven1 = malloc(sizeof(char));
	//seven3 = malloc(sizeof(char));
	seven2 = seven1 + (char) 2;	
	seven3 = seven2 + (char) 2;

	three_step(seven1, seven2, seven3);
	
	free(seven1);
	
	//8
	char eight1[2];
	eight1[1] = 'b';

	char eight2[3];
	eight2[2] = 'b' + 8;	

	char eight3[4];
	eight3[3] = eight2[2] + 8;
	step_step_step(eight1, eight2, eight3);
	
	//9
	char * nineA = malloc (sizeof(char));
	int    nineB = 1;

	*nineA = (char) 1;

	it_may_be_odd(nineA, nineB);
	free(nineA);

	//10
	char * tenB = malloc(4*sizeof(char));
	int *  tenO = (int*) tenB;
	tenB[0] = (char) 1;
	tenB[1] = 2;
	
	the_end(tenO, tenB);
//((char *)blue)[0] == 1          *((int *)orange) % 3 == 0)


	return 0;

}
コード例 #13
0
ファイル: udpspy.c プロジェクト: malaise/c
int main (const int argc, const char *argv[]) {
  /* Result of operation */
  int res;
  char buffer[255];

  /* The socket and its fd */
  soc_token socket = init_soc;
  int fd;

  /* Event result */
  boolean read;
  timeout_t timeout;
  int evtfd;

  /* parse arguments */
  parse_args (argc, argv);

  /* Create socket and get fd */
  if ( (res = soc_open (&socket, udp_socket)) != SOC_OK) {
    trace ("soc_open error", soc_error (res));
    error ("cannot open socket", "");
  }
  if ( (res = soc_get_id (socket, &fd)) != SOC_OK) {
    trace ("soc_get_id error", soc_error (res));
    error ("cannot get socket fd", "");
  }
  /* Bind socket to lan:port */
  bind_socket (socket);

  /* Attach fd for reading */
  if ( (res = evt_add_fd (fd, TRUE)) != WAIT_OK) {
    trace ("evt_add_fd error", "");
    error ("cannot add fd", "");
  }

  /* Main loop */
  timeout.tv_sec = -1;
  timeout.tv_usec = -1;
  for (;;) {
    /* Infinite wait for events */
    if ( (res = evt_wait (&evtfd, & read, &timeout)) != WAIT_OK) {
      trace ("evt_wait error", "");
      error ("cannot wait for event", "");
    }
    /* Analyse event */
    if (evtfd == SIG_EVENT) {
      if (get_signal() == SIG_TERMINATE) {
        /* Sigterm/sigint */
        break;
      } /* else unexpected signal => drop */
    } else if (evtfd == fd) {
      /* Got a packet: read it */
      res = soc_receive (socket, message, sizeof(message), TRUE);
      if (res < 0) {
        sprintf (buffer, "%d", res);
        trace ("soc_receive error", soc_error (res));
        error ("cannot read message", soc_error(res));
      } else {
        if (res > (int)sizeof(message)) {
          sprintf (buffer, "%d", res);
          trace ("soc_receive truncated message length", "buffer");
          res = (int)sizeof(message);
         }
         /* Put message info */
         display (socket, message, res);
      }
    } else if (evtfd >= 0) {
      /* Unexpected event on an unexpected fd */
      sprintf (buffer, "%d", evtfd);
      trace ("evt_wait got unexpected even on fd", "buffer");
      error ("even on unexpected fd", "");
    }

  } /* Main loop */

  /* Done */
  (void) evt_del_fd (fd, TRUE);
  (void) soc_close (&socket);
  the_end ();
}
コード例 #14
0
ファイル: all_cycles.C プロジェクト: SALAM2016/orbiter
int main(int argc, char **argv)
{
	INT i, j;
	t0 = os_ticks();
	INT verbose_level = 0;
	INT f_file = FALSE;	
	const BYTE *fname = NULL;
	INT f_depth = FALSE;
	INT depth = 0;
	INT f_draw_poset = FALSE;
	INT f_embedded = FALSE;
	INT f_sideways = FALSE;
	INT nb_print_level = 0;
	INT print_level[1000];

	
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		else if (strcmp(argv[i], "-file") == 0) {
			f_file = TRUE;
			fname = argv[++i];
			cout << "-file " << fname << endl;
			}
		else if (strcmp(argv[i], "-depth") == 0) {
			f_depth = TRUE;
			depth = atoi(argv[++i]);
			cout << "-depth " << depth << endl;
			}
		else if (strcmp(argv[i], "-draw_poset") == 0) {
			f_draw_poset = TRUE;
			cout << "-draw_poset " << endl;
			}
		else if (strcmp(argv[i], "-embedded") == 0) {
			f_embedded = TRUE;
			cout << "-embedded " << endl;
			}
		else if (strcmp(argv[i], "-sideways") == 0) {
			f_sideways = TRUE;
			cout << "-sideways " << endl;
			}
		else if (strcmp(argv[i], "-print_level") == 0) {
			print_level[nb_print_level++] = atoi(argv[++i]);
			cout << "-embedded " << endl;
			}

		}

	if (!f_file) {
		cout << "Please specify the file name using -file <fname>" << endl;
		exit(1);
		}
	if (!f_depth) {
		cout << "Please specify the depth using -depth <depth>" << endl;
		exit(1);
		}
	colored_graph *CG;

	CG = new colored_graph;

	CG->load(fname, verbose_level);




	INT *Adj;
	action *Aut;
	longinteger_object ago;

	cout << "computing automorphism group of the graph:" << endl;
	//Aut = create_automorphism_group_of_colored_graph_object(CG, verbose_level);


	Adj = NEW_INT(CG->nb_points * CG->nb_points);
	INT_vec_zero(Adj, CG->nb_points * CG->nb_points);
	for (i = 0; i < CG->nb_points; i++) {
		for (j = i + 1; j < CG->nb_points; j++) {
			if (CG->is_adjacent(i, j)) {
				Adj[i * CG->nb_points + j] = 1;
				}
			}
		}


	CG->compute_edges(verbose_level);

	INT *M;
	INT nb_rows, nb_cols;
	
	create_incidence_matrix_of_graph(Adj, CG->nb_points, M, nb_rows, nb_cols, verbose_level);

	if (nb_cols != CG->nb_edges) {
		cout << "nb_cols != CG->nb_edges" << endl;
		exit(1);
		}

	Aut = create_automorphism_group_of_graph(Adj, CG->nb_points, verbose_level);

	Aut->group_order(ago);	
	cout << "ago=" << ago << endl;

	action *Aut_on_edges;
	INT *edges;
	
	Aut_on_edges = new action;
	edges = NEW_INT(nb_cols);
	for (i = 0; i < nb_cols; i++) {
		edges[i] = nb_rows + i;
		}

	Aut_on_edges->induced_action_by_restriction(*Aut, 
		TRUE /* f_induce_action */, Aut->Sims, 
		nb_cols /* nb_points */, edges, verbose_level);
	
	Aut_on_edges->group_order(ago);	
	cout << "ago on edges = " << ago << endl;

	
	BYTE prefix[1000];
	generator *gen;
	



	strcpy(prefix, fname);
	replace_extension_with(prefix, "_p_and_c");


	compute_orbits_on_subsets(gen, 
		depth /* target_depth */,
		prefix, 
		FALSE /* f_W */, FALSE /* f_w */,
		Aut_on_edges, Aut_on_edges, 
		Aut_on_edges->Strong_gens, 
		early_test_function_paths_and_cycles,
		CG, 
		NULL, 
		NULL, 
		verbose_level);


	if (f_draw_poset) {
		gen->draw_poset(gen->fname_base, depth, 0 /* data1 */, f_embedded, f_sideways, verbose_level);
		}

	print_orbits_at_level(gen, depth, verbose_level);
	if (nb_print_level) {
		for (i = 0; i < nb_print_level; i++) {
			print_orbits_at_level(gen, print_level[i], verbose_level);
			}
		}

	INT nb_selected_orbits;
	INT *orbits;

	select_cycles(CG, gen, depth, nb_selected_orbits, orbits);
	print_selected_orbits_at_level(gen, depth, nb_selected_orbits, orbits, verbose_level);

	FREE_INT(orbits);
	FREE_INT(M);
	FREE_INT(Adj);
	FREE_INT(edges);
	delete Aut_on_edges;
	delete Aut;
	delete CG;

	the_end(t0);
	//the_end_quietly(t0);

}
コード例 #15
0
ファイル: Dispatcher.hpp プロジェクト: connorimes/GraphZ
        void dispatch() {
            int id = 0; //index of worker
            struct TaskBlock<struct adjlst<edge_t> *, TASK_SIZE> *ataskblock = vertex_buffers[id]->get_free_block();
            ataskblock->size = 0;
            
            
            logstream(LOG_INFO) << "enter dispatch" << std::endl;
            
            while (true) {
                struct io_buffer <edge_t, BUFF_SIZE> *abuf = in_iobuffer->get_task_block();
//                logstream(LOG_DEBUG) << "abuf->bufsiz: " << abuf->bufsiz << std::endl;
//                logstream(LOG_DEBUG) << "abuf->startid: " << abuf->startid << std::endl;                
//                logstream(LOG_DEBUG) << "abuf->endid: " << abuf->endid << std::endl;
                //logstream(LOG_INFO) << "get a task blcok" << std::endl;
                if (abuf->bufsiz == INVALID_SIZE) {
                    
                    abuf->bufsiz = 0;
                    in_iobuffer->add_free_block(abuf);
                    if (ataskblock->size == 0) {
                        vertex_buffers[id]->add_free_block(ataskblock);
                    } else {
                        //blocks++;
                        vertex_buffers[id]->add_task_block(ataskblock);
                    }
//                    logstream(LOG_DEBUG) << "end_now " << std::endl;
                    the_end();
                    break;
                }
               // counter degree = abuf->bufsiz / (abuf->endid - abuf->startid) / sizeof (edge_t);                
                counter degree = abuf->bufsiz / (abuf->endid - abuf->startid) ;
                
                int nbytes = degree * sizeof (edge_t); //nbytes is the number bytes consumed by a vertex's out edges

//                logstream(LOG_DEBUG) << "degree" << degree << std::endl;
                size_t index = 0;
                
                for (vertex_id i = abuf->startid; i < abuf->endid; i++) {
                    timer.start();
                    // vc ++;
                    struct adjlst<edge_t> * padj = adjlst<edge_t>::get_adjlst(i, degree);
                    
                    //logstream(LOG_INFO) << "adding adjs" << std::endl;
                    if (padj == 0) {
                        perror("run out of memory");
                        exit(-3);
                    }
                    memcpy(padj->edges, abuf->buf + index, nbytes);
                    index += degree;

                    timer.stop();
                    if (!ataskblock->add_element(padj)) {
                        //logstream(LOG_DEBUG) << "size: " << ataskblock->size << std::endl;
                        vertex_buffers[id]->add_task_block(ataskblock);
                        //blocks++;
//                        logstream(LOG_DEBUG) << "distribute one: " << std::endl;
                        //logstream(LOG_DEBUG) << "co a adj b" << std::endl;
                        if (++id >= worker_num) {
                            id = 0;
                        }
                        ataskblock = vertex_buffers[id]->get_free_block();
                        
                        ataskblock->clear();
                        ataskblock->add_element(padj);
                    }
                }
                
                in_iobuffer->add_free_block(abuf);
                //logstream(LOG_DEBUG) << "get a free task blcok" << std::endl;
            }
//            logstream(LOG_DEBUG) << "vc in dispatcher: " << vc << std::endl;
//            logstream(LOG_DEBUG) << "blocks in dispatcher: " << blocks << std::endl;
        }
コード例 #16
0
ファイル: matrix_rank.C プロジェクト: SALAM2016/orbiter
int main(int argc, char **argv)
{
	INT verbose_level = 0;
	INT i;
	INT f_n = FALSE;
	INT n = 0;
	INT f_k = FALSE;
	INT k = 0;
	INT f_q = FALSE;
	INT q = 0;
	
 	t0 = os_ticks();
	
	for (i = 1; i < argc - 1; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		else if (strcmp(argv[i], "-q") == 0) {
			f_q = TRUE;
			q = atoi(argv[++i]);
			cout << "-q " << q << endl;
			}
		else if (strcmp(argv[i], "-n") == 0) {
			f_n = TRUE;
			n = atoi(argv[++i]);
			cout << "-n " << n << endl;
			}
		else if (strcmp(argv[i], "-k") == 0) {
			f_k = TRUE;
			k = atoi(argv[++i]);
			cout << "-k " << k << endl;
			}
		}
	if (!f_k) {
		cout << "please use option -k <k>" << endl;
		exit(1);
		}
	if (!f_n) {
		cout << "please use option -n <n>" << endl;
		exit(1);
		}
	if (!f_q) {
		cout << "please use option -q <q>" << endl;
		exit(1);
		}

	finite_field *F;

	F = new finite_field;

	F->init(q, 0);


	count(n, k, F, verbose_level);


	delete F;
	
	the_end(t0);
}
コード例 #17
0
ファイル: part1.c プロジェクト: harsha176/Dictionary-ADT
int main()
{
	/*
	 * [Part 1]:
	 *   Edit the provided part1.c file to print out the tweleve "Illinois" lines
	 *   that are provided in the code inside mp1-functions.c.
	 */
        
        //pass 81 value to print first Illinois.
        first_step(81);
        
        // initialize a varaible with value 132 and pass its pointer as an argument.
        int val = 132;
        second_step(&val);

        // pass a double pointer to string which has value 8942 as its value.
        // int double_val = 8942;
        int** pp = (int **) malloc(sizeof(int*));
        *pp = (int *) malloc(sizeof(int)); 
        *pp[0] = 8942;
        double_step(pp);

        free(*pp);
        free(pp);
        // initialize a pointer value to zero and pass it to strange_step function.
        int* p_val = 0;
        strange_step(p_val);

        // pass a character array whose fourth value is zero.
        int name[4] = {0};
        empty_step(name);

        // create a character array and pointer to that array.
        char s[4];
        char* s1;
        s1 = s;
        s[3] = 'u';
        two_step(s, s1);

        // create a character array and assign other these values.
        char first[10];
        char* second = first + 2;
        char* third = second + 2;
        three_step(first, second, third);

        // use above arrays assign values in such away that they will call this.
        *first = 0;
        *second = *first + 4;
        *third = *second + 4;
        triple_step(first, second, third);
        
        // use the above arrays to call third
        //third = second = first; 
        first[1] = 0;
        second[2] = first[1] + 8;
        third[3] = second[2] + 8;
        step_step_step(first, second, third);         

        // everything is set just call above function.
        triple_three_step_step_step(first, second, third);

        // create an integer which is less than 256
        int b = 10;
        char* a = (char* )&b;
        it_may_be_odd(a, b);

        // create an integer array with initial value 0;
        p_val =(int *) malloc(sizeof(int));
        *p_val = 513;
        the_end(p_val, p_val);
        free(p_val);

	return 0;
}
コード例 #18
0
int main(int argc, char **argv)
{
	INT i, j;
	t0 = os_ticks();
	INT verbose_level = 0;
	INT f_file = FALSE;	
	const BYTE *fname = NULL;
	INT f_coordinates = FALSE;
	INT xmax_in = ONE_MILLION;
	INT ymax_in = ONE_MILLION;
	INT xmax_out = ONE_MILLION;
	INT ymax_out = ONE_MILLION;
	INT f_export_magma = FALSE;
	const BYTE *magma_fname = NULL;
	INT f_export_matlab = FALSE;
	const BYTE *matlab_fname = NULL;
	INT f_on_circle = FALSE;
	INT f_bitmatrix = FALSE;
	INT f_labels = FALSE;
	INT f_embedded = FALSE;
	INT f_sideways = FALSE;
	INT f_scale = FALSE;
	double scale = .45;
	INT f_line_width = FALSE;
	double line_width = 1.5;
	INT f_aut = FALSE;
	INT f_is_association_scheme = FALSE;
	INT f_all_cliques = FALSE;
	INT f_all_cocliques = FALSE;
	INT f_characteristic_polynomial = FALSE;
	INT f_export = FALSE;
	const BYTE *export_fname = NULL;
	INT f_expand_power = FALSE;
	INT expand_power = 0;
	INT expand_power_nb_graphs;
	const BYTE *expand_power_graph_fname[1000];
	
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose_level = atoi(argv[++i]);
			cout << "-v " << verbose_level << endl;
			}
		else if (strcmp(argv[i], "-file") == 0) {
			f_file = TRUE;
			fname = argv[++i];
			cout << "-file " << fname << endl;
			}
		else if (strcmp(argv[i], "-coordinates") == 0) {
			f_coordinates = TRUE;
			xmax_in = atoi(argv[++i]);
			ymax_in = atoi(argv[++i]);
			xmax_out = atoi(argv[++i]);
			ymax_out = atoi(argv[++i]);
			cout << "-coordinates " << xmax_in << " " << ymax_in << " " << xmax_out << " " << ymax_out << endl;
			}
		else if (strcmp(argv[i], "-export_magma") == 0) {
			f_export_magma = TRUE;
			magma_fname = argv[++i];
			cout << "-export_magma " << magma_fname << endl;
			}
		else if (strcmp(argv[i], "-export_matlab") == 0) {
			f_export_matlab = TRUE;
			matlab_fname = argv[++i];
			cout << "-export_matlab " << matlab_fname << endl;
			}
		else if (strcmp(argv[i], "-on_circle") == 0) {
			f_on_circle = TRUE;
			cout << "-on_circle " << endl;
			}
		else if (strcmp(argv[i], "-bitmatrix") == 0) {
			f_bitmatrix = TRUE;
			cout << "-bitmatrix " << endl;
			}
		else if (strcmp(argv[i], "-labels") == 0) {
			f_labels = TRUE;
			cout << "-labels " << endl;
			}
		else if (strcmp(argv[i], "-embedded") == 0) {
			f_embedded = TRUE;
			cout << "-embedded " << endl;
			}
		else if (strcmp(argv[i], "-sideways") == 0) {
			f_sideways = TRUE;
			cout << "-sideways " << endl;
			}
		else if (strcmp(argv[i], "-scale") == 0) {
			f_scale = TRUE;
			sscanf(argv[++i], "%lf", &scale);
			cout << "-scale " << scale << endl;
			}
		else if (strcmp(argv[i], "-line_width") == 0) {
			f_line_width = TRUE;
			sscanf(argv[++i], "%lf", &line_width);
			cout << "-line_width " << line_width << endl;
			}
		else if (strcmp(argv[i], "-aut") == 0) {
			f_aut = TRUE;
			cout << "-aut " << endl;
			}
		else if (strcmp(argv[i], "-is_association_scheme") == 0) {
			f_is_association_scheme = TRUE;
			cout << "-is_association_scheme " << endl;
			}
		else if (strcmp(argv[i], "-all_cliques") == 0) {
			f_all_cliques = TRUE;
			cout << "-all_cliques " << endl;
			}
		else if (strcmp(argv[i], "-all_cocliques") == 0) {
			f_all_cocliques = TRUE;
			cout << "-all_cocliques " << endl;
			}
		else if (strcmp(argv[i], "-characteristic_polynomial") == 0) {
			f_characteristic_polynomial = TRUE;
			cout << "-characteristic_polynomial " << endl;
			}
		else if (strcmp(argv[i], "-export") == 0) {
			f_export = TRUE;
			export_fname = argv[++i];
			cout << "-export " << export_fname << endl;
			}
		else if (strcmp(argv[i], "-expand_power") == 0) {
			f_expand_power = TRUE;
			sscanf(argv[++i], "%ld", &expand_power);
			for (j = 0; ; j++) {
				expand_power_graph_fname[j] = argv[++i];
				cout << "j=" << j << " : " << expand_power_graph_fname[j] << endl;
				if (strcmp(expand_power_graph_fname[j], "-1") == 0) {
					cout << "break j=" << j << endl;
					break;
					}
				}
			expand_power_nb_graphs = j;
			cout << "-expand_power " << expand_power << " " << endl;
			for (j = 0; j < expand_power_nb_graphs; j++) {
				cout << expand_power_graph_fname[j] << " " << endl;
				}
			cout << endl;
			}

		}

	if (!f_file) {
		cout << "Please specify the file name using -file <fname>" << endl;
		exit(1);
		}
	colored_graph *CG;

	CG = new colored_graph;

	CG->load(fname, verbose_level);

	if (f_export_magma) {
		CG->export_to_magma(magma_fname, 0 /* verbose_level */);
		}

	if (f_export_matlab) {
		CG->export_to_file_matlab(matlab_fname, 0 /* verbose_level */);
		}

	if (f_export) {
		CG->export_to_file(export_fname, 0 /* verbose_level */);
		}






	if (f_on_circle) {
		BYTE fname2[1000];

		strcpy(fname2, fname);
		replace_extension_with(fname2, "_on_circle");
		CG->draw_on_circle(fname2, 
			xmax_in, ymax_in, xmax_out, ymax_out,
			f_labels, f_embedded, f_sideways, 
			scale, line_width);
		}
	else if (f_bitmatrix) {

		BYTE fname2[1000];

		strcpy(fname2, fname);
		replace_extension_with(fname2, "_bitmatrix");

		CG->draw(fname2, xmax_in, ymax_in, xmax_out, ymax_out, verbose_level);
		//CG->draw_partitioned(fname2, xmax_in, ymax_in, xmax_out, ymax_out, verbose_level);
		}

	if (f_aut) {
		
		INT *Adj;
		action *Aut;
		longinteger_object ago;

		cout << "computing automorphism group of the graph:" << endl;
		//Aut = create_automorphism_group_of_colored_graph_object(CG, verbose_level);


		Adj = NEW_INT(CG->nb_points * CG->nb_points);
		INT_vec_zero(Adj, CG->nb_points * CG->nb_points);
		for (i = 0; i < CG->nb_points; i++) {
			for (j = i + 1; j < CG->nb_points; j++) {
				if (CG->is_adjacent(i, j)) {
					Adj[i * CG->nb_points + j] = 1;
					}
				}
			}
		Aut = create_automorphism_group_of_graph(Adj, CG->nb_points, verbose_level);

		Aut->group_order(ago);	
		cout << "ago=" << ago << endl;
		
		FREE_INT(Adj);
		}

	if (f_is_association_scheme) {

		INT n = CG->nb_points;
		INT *Adj;
	
		Adj = NEW_INT(n * n);
		INT_vec_zero(Adj, n * n);
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				if (CG->is_adjacent(i, j)) {
					Adj[i * n + j] = 1;
					}
				}
			}
		for (i = 0; i < n * n; i++) {
			Adj[i] += 1;
			}
		for (i = 0; i < n; i++) {
			Adj[i * n + i] = 0;
			}
	
		INT *Pijk;
		//INT *colors;
		//INT nb_colors;
		
		if (is_association_scheme(Adj, n, Pijk, 
			CG->point_color, CG->nb_colors, verbose_level)) {
			cout << "Is an association scheme" << endl;
			}
		else {
			cout << "Is NOT an association scheme" << endl;
			}

		FREE_INT(Adj);
		
		}

	if (f_expand_power) {


		INT n = CG->nb_points;
		INT *Adj;
		INT *A, *B;
		INT e, c, k, diag, p;

		if (expand_power <= 1) {
			cout << "expand_power <= 1" << endl;
			exit(1);
			}

		Adj = NEW_INT(n * n);
		A = NEW_INT(n * n);
		B = NEW_INT(n * n);
		INT_vec_zero(Adj, n * n);
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				if (CG->is_adjacent(i, j)) {
					Adj[i * n + j] = 1;
					Adj[j * n + i] = 1;
					}
				}
			}
		INT_vec_copy(Adj, A, n * n);
		e = 1;

		while (e < expand_power) {

			for (i = 0; i < n; i++) {
				for (j = 0; j < n; j++) {
					c = 0;
					for (k = 0; k < n; k++) {
						c += Adj[i * n + k] * A[k * n + j];
						}
					B[i * n + j] = c;
					}
				}
			INT_vec_copy(B, A, n * n);
			e++;


			}

		cout << "the " << expand_power << " power of the adjacency matrix is:" << endl;
		INT_matrix_print(B, n, n);
		
		diag = B[0 * n + 0];
		for (i = 0; i < n; i++) {
			if (B[i * n + i] != diag) {
				cout << "diagonal is not constant" << endl;
				exit(1);
				}
			}

		for (i = 0; i < n; i++) {
			B[i * n + i] = 0;
			}

		cout << "after subtracting " << diag << " times the identity, the matrix is:" << endl;
		INT_matrix_print(B, n, n);

		for (p = 0; p < n * n; p++) {
			if (Adj[p]) {
				break;
				}
			}

		c = B[p];
		if (c) {
			for (i = 0; i < n * n; i++) {
				if (Adj[i]) {
					if (B[i] != c) {
						cout << "B is not constant on the original graph" << endl;
						exit(1);
						}
					}
				}
			for (i = 0; i < n * n; i++) {
				if (Adj[i]) {
					B[i] = 0;
					}
				}
			}
		

		cout << "after subtracting " << c << " times the original graph, the matrix is:" << endl;
		INT_matrix_print(B, n, n);


		INT h;
		INT *coeffs;
		colored_graph *CG_basis;

		coeffs = NEW_INT(expand_power_nb_graphs + 2);
		CG_basis = new colored_graph[expand_power_nb_graphs];
		INT_vec_zero(coeffs, expand_power_nb_graphs);
		coeffs[expand_power_nb_graphs] = c;
		coeffs[expand_power_nb_graphs + 1] = diag;

		for (h = 0; h < expand_power_nb_graphs; h++) {
			CG_basis[h].load(expand_power_graph_fname[h], verbose_level);
			
			if (CG_basis[h].nb_points != n) {
				cout << "the graph " << expand_power_graph_fname[h] << " has the wrong number of vertices" << endl;
				exit(1);
				}
			INT *H;

			H = NEW_INT(n * n);
			INT_vec_zero(H, n * n);
			for (i = 0; i < n; i++) {
				for (j = i + 1; j < n; j++) {
					if (CG_basis[h].is_adjacent(i, j)) {
						H[i * n + j] = 1;
						H[j * n + i] = 1;
						}
					}
				}
			
			for (p = 0; p < n * n; p++) {
				if (H[p]) {
					break;
					}
				}

			coeffs[h] = B[p];
			if (coeffs[h]) {
				for (i = 0; i < n * n; i++) {
					if (H[i]) {
						if (B[i] != coeffs[h]) {
							cout << "B is not constant on the graph " << expand_power_graph_fname[h] << endl;
							exit(1);
							}
						}
					}
				for (i = 0; i < n * n; i++) {
					if (H[i]) {
						B[i] = 0;
						}
					}
				}
			cout << "after subtracting " << coeffs[h] << " times the graph " << expand_power_graph_fname[h] << ", the matrix is:" << endl;
			INT_matrix_print(B, n, n);
			
			FREE_INT(H);
			}

		cout << "coeffs=";
		INT_vec_print(cout, coeffs, expand_power_nb_graphs + 2);
		cout << endl;
		
		FREE_INT(Adj);
		FREE_INT(A);
		FREE_INT(B);
		}

	if (f_all_cliques || f_all_cocliques) {


		INT *Adj;
		action *Aut;
		longinteger_object ago;

		cout << "computing automorphism group of the graph:" << endl;
		//Aut = create_automorphism_group_of_colored_graph_object(CG, verbose_level);


		Adj = NEW_INT(CG->nb_points * CG->nb_points);
		INT_vec_zero(Adj, CG->nb_points * CG->nb_points);
		for (i = 0; i < CG->nb_points; i++) {
			for (j = i + 1; j < CG->nb_points; j++) {
				if (CG->is_adjacent(i, j)) {
					Adj[i * CG->nb_points + j] = 1;
					}
				}
			}
		Aut = create_automorphism_group_of_graph(Adj, CG->nb_points, verbose_level);

		Aut->group_order(ago);	
		cout << "ago=" << ago << endl;

		action *Aut_on_points;
		INT *points;
		
		Aut_on_points = new action;
		points = NEW_INT(CG->nb_points);
		for (i = 0; i < CG->nb_points; i++) {
			points[i] = i;
			}

		Aut_on_points->induced_action_by_restriction(*Aut, 
			TRUE /* f_induce_action */, Aut->Sims, 
			CG->nb_points /* nb_points */, points, verbose_level);
		
		Aut_on_points->group_order(ago);	
		cout << "ago on points = " << ago << endl;

		
		BYTE prefix[1000];
		generator *gen;
		INT nb_orbits, depth;
		

		strcpy(prefix, fname);
		replace_extension_with(prefix, "_cliques");

		if (f_all_cliques) {
			compute_orbits_on_subsets(gen, 
				CG->nb_points /* target_depth */,
				prefix, 
				TRUE /* f_W */, FALSE /* f_w */,
				Aut_on_points, Aut_on_points, 
				Aut_on_points->Strong_gens, 
				early_test_function_cliques,
				CG, 
				NULL, 
				NULL, 
				verbose_level);
			}
		else {
			compute_orbits_on_subsets(gen, 
				CG->nb_points /* target_depth */,
				prefix, 
				TRUE /* f_W */, FALSE /* f_w */,
				Aut_on_points, Aut_on_points, 
				Aut_on_points->Strong_gens, 
				early_test_function_cocliques,
				CG, 
				NULL, 
				NULL, 
				verbose_level);
			}

		for (depth = 0; depth < CG->nb_points; depth++) {
			nb_orbits = gen->nb_orbits_at_level(depth);
			if (nb_orbits == 0) {
				depth--;
				break;
				}
			}

		if (f_all_cliques) {
			cout << "the largest cliques have size " << depth << endl;
			for (i = 0; i <= depth; i++) {
				nb_orbits = gen->nb_orbits_at_level(i);
				cout << setw(3) << i << " : " << setw(3) << nb_orbits << endl;
				}
			}
		else if (f_all_cocliques) {
			cout << "the largest cocliques have size " << depth << endl;
			for (i = 0; i <= depth; i++) {
				nb_orbits = gen->nb_orbits_at_level(i);
				cout << setw(3) << i << " : " << setw(3) << nb_orbits << endl;
				}
			}

		INT *set;
		longinteger_object go, ol;
		longinteger_domain D;

		set = NEW_INT(depth);
		nb_orbits = gen->nb_orbits_at_level(depth);

		cout << "orbit : representative : stabilizer order : orbit length" << endl;
		for (i = 0; i < nb_orbits; i++) {
			gen->get_set_by_level(depth, i, set);

			strong_generators *gens;
			gen->get_stabilizer_generators(gens,  
				depth, i, verbose_level);
			gens->group_order(go);
			D.integral_division_exact(ago, go, ol);


			cout << "Orbit " << i << " is the set ";
			INT_vec_print(cout, set, depth);
			cout << " : " << go << " : " << ol << endl;
			cout << endl;

			
			}

		FREE_INT(set);
		FREE_INT(Adj);
		FREE_INT(points);
		delete Aut;
		delete Aut_on_points;


		
		}


	else if (f_characteristic_polynomial) {
		
		characteristic_polynomial(CG, verbose_level);
		
		}
	
	delete CG;

	cout << "draw_colored_graph.out is done" << endl;
	the_end(t0);
	//the_end_quietly(t0);

}