Data RBBagging::generateBootstrap() {
    negative_binomial_distribution<int> distribution(positives->getNSamples(),0.5);
    int nPos = positives->getNSamples();
    int nNeg = distribution(generator);

    Data bootstrap(nPos + nNeg, trainData->getNFeatures(), trainData->getNLabels());
    int randSample;
    int nFeatures = trainData->getNFeatures();

    ///cout << "nNeg = " << nNeg << endl;

    // copies all positives
    for(int i = 0; i < nPos; ++i) {
        // copies the sample
        for(int j = 0; j < nFeatures; ++j) {
            bootstrap.setFeature(i, j, positives->getFeature(i, j));
        }
        bootstrap.setTrueLabel(i, positives->getTrueLabel(i));
    }

    for(int i = nPos; i < (nPos + nNeg); ++i) {
        // selects a random sample
        randSample = rand() % negatives->getNSamples();

        // copies the sample
        for(int j = 0; j < nFeatures; ++j) {
            bootstrap.setFeature(i, j, negatives->getFeature(randSample, j));
        }
        bootstrap.setTrueLabel(i, negatives->getTrueLabel(randSample));
    }

    return bootstrap;
}
Beispiel #2
0
void mp_manager::run_system()
{
	section* pSection =  mp_manager::create_section(m_startup_section);
	if (!pSection) 
	{
		assert(0 && "no startup section defined " );
		return;
	}
	startup_section_config cfg = pSection->configure();
	start_threads(cfg.m_thread_count);

	system_section bootstrap(0);
	bootstrap.start_self(m_startup_section);
	// system thread occupies thread 0 and we just started processing.
	bool result = true;
	for (int i = 0 ; i < m_threads.size() ; i ++ ) 
	{
		m_threads[i]->m_handle =  CreateEvent( NULL, TRUE, TRUE, NULL );
		// system thread is ... system. we dont need any specific thread to start.
		if (i > 0 ) 
		{
			result = result && _beginthread(&ThreadProc,0, m_threads[i])!=-1; 
		}
	}
	ThreadProc( m_threads[0] ) ;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    uid_t uid = geteuid();
    char buf[STRLEN];
    size_t len;

    if (uid != BBSUID)
        if (setgid(BBSGID) == -1 || setuid(BBSUID) == -1)
            error("Please run %s as BBSUSER or root.", argv[0]);

    if (system("pgrep bbsd > /dev/null") == 0 ||
            system("pgrep sshbbsd > /dev/null") == 0 ||
            system("pgrep miscd > /dev/null") == 0
       )
            // sshdbbsd or bbsd or miscd is running
        error("Please shutdown BBS first.");

    printf("Danger! This may destroy ALL OF YOUR USER AND BOARD DATA!\n");
    printf("Type `Go ahead!' exactly without quotes and press ENTER to continue\n");
    printf("Are you ready? ");
    fgets(buf, STRLEN, stdin);
    len = strlen(buf);
    if (buf[len-1] == '\n' || buf[len-1] == '\r')
        buf[len-1] = '\0';
    if (!strcmp("Go ahead!", buf))
        bootstrap();
    else
        printf("User aborted.\n");
    return 0;
}
Beispiel #4
0
int main(int argc, const char **argv)
{
    if (argc < 2)
    {
        printf("usage: %s file\n", argv[0]);
        return 0;
    }

    try
    {
        luna::State state;
        luna::VM vm(&state);
        luna::Bootstrap bootstrap(&state);

        lib::base::RegisterLibBase(&state);
        lib::math::RegisterLibMath(&state);
        lib::string::RegisterLibString(&state);

        state.LoadModule(argv[1]);
        bootstrap.Prepare();
        vm.Execute();
    }
    catch (const luna::OpenFileFail &exp)
    {
        printf("%s: can not open file %s\n", argv[0], exp.What().c_str());
    }
    catch (const luna::Exception &exp)
    {
        printf("%s\n", exp.What().c_str());
    }

    return 0;
}
Beispiel #5
0
static mdn_result_t
amcaceo_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
	size_t len;
	int k;
	int literal_mode = 0;
	unsigned long v;
	unsigned long refpoint[5];
	static unsigned long refpoint_initial[5] = {
		0, 0x10, 0, 0, 0x10000,
	};

	memcpy(refpoint, refpoint_initial, sizeof(refpoint));
	for (k = 2; k >= 0; k--) {
		len = decode_point(refpoint, from, fromlen, &v);
		if (len == 0)
			return (mdn_invalid_encoding);
		from += len;
		fromlen -= len;
		bootstrap(refpoint, k, v);
	}

	while (fromlen > 0) {
		if (from[0] == '-') {
			if (fromlen > 1 && from[1] == '-') {
				v = '-';
				from += 2;
				fromlen -= 2;
			} else {
				literal_mode = !literal_mode;
				from++;
				fromlen--;
				continue;
			}
		} else if (literal_mode) {
			v = from[0];
			from++;
			fromlen--;
		} else {
			len = decode_point(refpoint, from, fromlen, &v);
			if (len == 0)
				return (mdn_invalid_encoding);
			from += len;
			fromlen -= len;
		}
		len = mdn_utf8_putwc(to, tolen, v);
		if (len == 0)
			return (mdn_buffer_overflow);
		to += len;
		tolen -= len;
	}

	/*
	 * Terminate with NUL.
	 */
	if (tolen <= 0)
		return (mdn_buffer_overflow);

	*to = '\0';
	return (mdn_success);
}
Beispiel #6
0
static int
encode_refpoints(amcaceo_encode_ctx *ctx, char *to, size_t tolen) {
	int len;
	int total = 0;
	int k;

	/*
	 * No, despite the name, we are encoding prefixes, not refpoints.
	 */

	/*
	 * Set initial fixed refpoints.  Otherwise decoder cannot guess
	 * what they are.  The initial value is chosen so that prefix can
	 * be encoded efficiently.
	 */
	ctx->refpoint[0] = 0;
	ctx->refpoint[1] = 0x10;

	for (k = 2; k >= 0; k--) {
		len = encode_point(ctx->refpoint, ctx->prefix[k], to, tolen);
		if (len == 0)
			return (0);
		to += len;
		tolen -= len;
		total += len;
		bootstrap(ctx->refpoint, k, ctx->prefix[k]);
	}

	/*
	 * Here, all the refpoints is automagically restored to the
	 * original value.
	 */
	return (total);
}
Beispiel #7
0
void Tox_Dispatcher::start()
{
    if (run.load()) {
        LOG(INFO) << "Tox dispatcher is already running";
    }

    LOG(INFO) << "Starting Tox dispatcher";
    try {
        init_tox();
        init_callbacks();
        bootstrap();
    } catch (const std::exception& e) {
        LOG(ERROR) << e.what();
        exit(-1);
    }
    dispatcher_started.Emit(this);

    LOG(INFO) << "Tox Id: " << get_self_id();

    /* run tox main loop */
    run.store(true);
    while (run.load()) {
        lock.lock();
            tox_iterate(tox);
            uint32_t millis = tox_iteration_interval(tox);
        lock.unlock();
        std::this_thread::sleep_for(std::chrono::milliseconds(millis));
    }

    tox_kill(tox);
    tox = nullptr;
    LOG(INFO) << "Tox dispatcher stopped";
}
Beispiel #8
0
int main(int argc,char *argv[])
/*
 * main function of the shell program, calls process_input(). As process_input()
 *	does all the error reporting and does not propagate errors out of it
 *	and shell program does not have to return any failure exit status
 *	to its parent shell, main() simply retuns 0    
*/
{
	//Bootstrap
	bootstrap();
	//flexTimer0Start();

	//process input
	//process_input();
	uint32_t pid;
	struct spawnArgs args;
	args.argc = 1;
	args.argv = NULL;
	args.spawnedPidptr = &pid;
	args.stackSize = STACK_SIZE;
	args.funcPtr = runShell;
	svc_spawn(&args);
	sysTickStart();
	privUnprivileged();
	while(1);
	return 0;
}
Beispiel #9
0
int main(int argc, char *argv[])
{
    // Request multiboot caps and bootinfo from monitor
    bootstrap();

    messages_handler_loop();
    return 0;
}
Beispiel #10
0
int main() {
  bootstrap();

  run();

  st_delete(&process->cwd);
  free(process);
  return 0;
}
Beispiel #11
0
// This is the entry point for the whole show, the very first bit of code
// to run in user mode.
noreturn void _start(void* start_arg) {
    zx_handle_t log = ZX_HANDLE_INVALID;
    zx_debuglog_create(ZX_HANDLE_INVALID, 0, &log);
    if (log == ZX_HANDLE_INVALID)
        printl(log, "zx_debuglog_create failed, using zx_debug_write instead");

    zx_handle_t bootstrap_pipe = (uintptr_t)start_arg;
    bootstrap(log, bootstrap_pipe);
}
Beispiel #12
0
int	main(int ac, char **argv)
{
	int fd;

	if (ac != 2)
		usage();
	if (!(fd = open(argv[1], O_RDONLY)))
		err_opening();
	bootstrap(encode_pieces(fd));
	return (0);
}
Beispiel #13
0
int main(void) {
	printf("\nI am here.\n\n");
	double data[6] = {9.0, 2.0, 4.0, 8.0, 1.0, 10.0};
	
	double result;
	
	bootstrap(data, &result, 10, 6);
	
	printf("se is %f.\n", result);
	return 0;
}
 void run()
 {
   if (!molecule()->atoms().empty())
   {
     bootstrap();
     removeDoubles();
     sortCycles();
     keepMinimalCycles();
     keepAromaticCycles();
     /*keepPlanarCycles(0.10f);*/
   }
 }
void
PluginBootstrapper::bootStrap()
{
    QSettings bootstrap( QSettings::NativeFormat, QSettings::UserScope, "Last.fm", "Bootstrap", this );

    bootstrap.setValue( m_pluginId, lastfm::ws::Username );
    bootstrap.setValue( "data_path", lastfm::dir::runtimeData().path() );

    bootstrap.setValue( "Strings/progress_label",       tr("test! Last.fm is importing your current media library...") );
    bootstrap.setValue( "Strings/complete_label",       tr("Last.fm has imported your media library.\n\n Click OK to continue.") );
    bootstrap.setValue( "Strings/progress_title",       tr("Last.fm Library Import") );
    bootstrap.setValue( "Strings/cancel_confirmation",  tr("Are you sure you want to cancel the import?") );
    bootstrap.setValue( "Strings/no_tracks_found",      tr("Last.fm couldn't find any played tracks in your media library.\n\n Click OK to continue.") );

    // start the media player
    QProcess* process = new QProcess( this );
    QString mediaPlayer = "";

    if ( m_pluginId == "wa2" )
        mediaPlayer = QString( getenv( "ProgramFiles(x86)" ) ).append( "/Winamp/winamp.exe" );
    else
        mediaPlayer = QString( getenv( "ProgramFiles(x86)" ) ).append( "/Windows Media Player/wmplayer.exe" );

    qDebug() << mediaPlayer;

    if ( !QFile::exists( mediaPlayer ) )
    {
        mediaPlayer = QFileDialog::getOpenFileName( 0,
                                               m_pluginId == "wa2" ? tr( "Where is Winamp?" ) : tr( "Where is Windows Media Player?" ),
                                               QString( getenv( "ProgramFiles(x86)" ) ),
                                               m_pluginId == "wa2" ? "winamp.exe" : "wmplayer.exe" );


    }

    qDebug() << mediaPlayer;

    mediaPlayer = QString( "\"%1\"" ).arg( mediaPlayer );

    if ( !process->startDetached( mediaPlayer ) )
    {
        qDebug() << process->error() << process->errorString();

        emit done( Bootstrap_Cancelled );
    }
    else
    {
        // wait for it to do its stuff
        QTimer::singleShot( 1000, this, SLOT(checkBootstrapped()) );
    }
}
Beispiel #16
0
void 
skynet_start(struct skynet_config * config) {
	skynet_harbor_init(config->harbor);
	skynet_handle_init(config->harbor);
	skynet_mq_init();
	skynet_module_init(config->module_path);
	skynet_timer_init();
	skynet_socket_init();

	bootstrap(config->bootstrap);

	_start(config->thread);
	skynet_socket_free();
}
Beispiel #17
0
int main(int argc,char *argv[])
/*
 * main function of the shell program, calls process_input(). As process_input()
 *	does all the error reporting and does not propagate errors out of it
 *	and shell program does not have to return any failure exit status
 *	to its parent shell, main() simply retuns 0    
*/
{
	//Bootstrap
	bootstrap();

	//process input
	process_input();
	return 0;
}
Beispiel #18
0
Program::Program(int argc, char** argv) {
  program = this;

  basepath = dir(realpath(argv[0]));
  userpath = {nall::configpath(), "termboy/"};
  sharedpath = {nall::sharedpath(), "termboy/"};
  directory::create(userpath);

  bootstrap();
  active = nullptr;

  config = new ConfigurationSettings;
  utility = new Utility;

  audio.driver("ALSA");

  if(audio.init() == false) {
    audio.driver("None");
    audio.init();
  }

  init_curses();
  inputManager = new InputManager();
  inputManager->setupKeyboard();

  dspaudio.setPrecision(16);
  dspaudio.setBalance(0.0);
  dspaudio.setFrequency(96000);

  utility->synchronizeRuby();
  utility->updateShader();

  if(argc >= 2)
    utility->loadMedia(argv[1]);

  //TODO:  This is bad! Remove hardcoded string and use appropriate path
  //TODO:  periodically sync RAM in case of crash?
  Ananke ananke;
  ananke.sync("/home/dobyrch/ROMs/Game Boy/pokemon_blue.gb");
  while(true) {
    main();
  }

  utility->unload();
  //config->save();
}
Data Bagging::generateBootstrap(){
    Data bootstrap(bootstrapSize, trainData->getNFeatures(), trainData->getNLabels());
    int randSample;

    for(int i = 0; i < bootstrapSize; ++i){
        // selects a random sample
        randSample = rand() % trainData->getNSamples();

        // copies the sample
        for(int j = 0; j < trainData->getNFeatures(); ++j){
            bootstrap.setFeature(i, j, trainData->getFeature(randSample, j));
        }
        bootstrap.setTrueLabel(i, trainData->getTrueLabel(randSample));
    }

    return bootstrap;
}
void
PluginBootstrapper::checkBootstrapped()
{
    // check if the file exists

    QString savePath = lastfm::dir::runtimeData().filePath( lastfm::ws::Username + "_" + m_pluginId + "_bootstrap.xml" );

    if ( QFile::exists( savePath ) )
    {
        // make sure winamp doesn't create the bootstrap file again
        QSettings bootstrap( QSettings::NativeFormat, QSettings::UserScope, "Last.fm", "Bootstrap", this );
        bootstrap.remove( m_pluginId );

        submitBootstrap();
    }
    else
        QTimer::singleShot( 1000, this, SLOT(checkBootstrapped()) );
}
Beispiel #21
0
int main(int argc, char *argv[])
{
	vir_machine_init();
	bootstrap();
	os_init();

	char order[800];
	int i;
	while (1) {
		echo_mip4();
		mips_want_get_string(order, 799);
		switch(order[0]) {
			case 'e':
				sys_exec(order + 2);
				break;
			case 'f':
				format_disk();
				write_stdout("successfully formats the disk!\n", F_WHITE, B_BLACK);
				break;
			case 'c':
				sys_create(order + 2);
				write_stdout("successfully create file\n", F_WHITE, B_BLACK);
				break;
			case 'w':  // copy the file to disk!
			{
				char *name = order + 2; // only one spaces !
				sys_create(name);
				int fid = sys_open(name);
				int obj_id = open(name, O_RDONLY);
				while (1) {
					int buf;
					if (read(obj_id, &buf, 1) == 0)
						break;
					char char_buf = (char)buf;
					sys_write(fid, &char_buf, 1);
				}
				sys_close(fid);
				write_stdout("successfully write file\n", F_WHITE, B_BLACK);
				break;
			}
		}
	}
	return 0;
}
Beispiel #22
0
void skynet_start(SNServer &snserver, skynet_config *config)
{
	signal(SIGINT, OnSignal);
	signal(SIGTERM, OnSignal);
#ifdef _WINDOWS_
	signal(SIGBREAK, OnSignal);
#endif

	SNContextPtr pLogger = snserver.NewContext("logger", config->logger);
	if (pLogger == NULL) {
		LogError("Can't launch logger service\n");
		return;
	}
	if (!bootstrap(snserver, pLogger, config->bootstrap)) {
		return;
	}
	pLogger.reset(); //这里不要再引用了,生命周期留给全局句柄表(SNHandleMgr)管理

	_start(config->thread);
}
Beispiel #23
0
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) 
	: QMainWindow(parent, f)
{
	setupUi(this);
	connect(actionExit,SIGNAL(activated()),this, SLOT(close()));
	connect(BrowseELF,SIGNAL(clicked()),this,SLOT(browse_elf()));
	connect(BrowseST,SIGNAL(clicked()),this,SLOT(browse_st()));
	connect(fullLinking,SIGNAL(clicked()),this,SLOT(full_linking()));
	connect(lightLinking,SIGNAL(clicked()),this,SLOT(light_linking()));
	connect(connectToTelosb,SIGNAL(clicked()),this,SLOT(connect_to_telosb()));
	connect(telosReset,SIGNAL(clicked()),this,SLOT(reset()));
	connect(telosErase,SIGNAL(clicked()),this,SLOT(erase()));
	connect(BrowseBootstrap,SIGNAL(clicked()),this,SLOT(browseBootstrap()));
	connect(Bootstrap,SIGNAL(clicked()),this,SLOT(bootstrap()));
	connect(BootstrapNoErase,SIGNAL(clicked()),this,SLOT(bootstrapNoErase()));
	connect(BrowseWLF,SIGNAL(clicked()),this,SLOT(browse_wlf()));
	connect(loadWLF,SIGNAL(clicked()),this,SLOT(load_wlf()));
	connect(unloadThenLoadWLF,SIGNAL(clicked()),this,SLOT(unload_then_load_wlf()));

}
Beispiel #24
0
int main(int argc, char** argv)
{
	bootstrap();

	SDL_assert(globalApplication);
	SDL_assert(globalApplication->initialize);
	SDL_assert(globalApplication->loop);
	SDL_assert(globalApplication->cleanup);

	SDL_assert((globalApplication->initialize(globalApplication, argc, argv)));

	globalApplication->loop(globalApplication);

	int result = globalApplication->cleanup(globalApplication);

	Application_Destroy(globalApplication);
	globalApplication = 0;

	return result;
}
Beispiel #25
0
static void autoexec(void)
{
    struct {
        BYTE reserved[21];
        BYTE attr;
        WORD time;
        WORD date;
        LONG size;
        BYTE name[14];
    } dta;
    WORD err;

    if (kbshift(-1) & MODE_CTRL)        /* check if Control is held down */
        return;

    bootstrap();                        /* try to boot the new OS kernel directly */

    if( ! blkdev_avail(bootdev) )       /* check, if bootdev available */
        return;

    trap1( 0x1a, &dta);                      /* Setdta */
    err = trap1( 0x4e, "\\AUTO\\*.PRG", 7);  /* Fsfirst */
    while(err == 0) {
#ifdef TARGET_PRG
        if (!strncmp(dta.name, "EMUTOS", 6))
        {
            KDEBUG(("Skipping %s from AUTO folder\n", dta.name));
        }
        else
#endif
        {
            run_auto_program(dta.name);

            /* Setdta. BetaDOS corrupted the AUTO load if the Setdta
             * not repeated here */
            trap1( 0x1a, &dta);
        }

        err = trap1( 0x4f );                 /* Fsnext */
    }
}
int main(int argc, char *argv[], char ** envp) {
	char line[MAXLINE]; 
	char * tokens[LIMIT]; 
	int numTokens;		
	no_reprint_prmpt = 0; 				
	pid = -10; 	
	bootstrap();
	environ = envp;	
	setenv("shell",getcwd(currentDirectory, 1024),1);
	while(TRUE){
		if (no_reprint_prmpt == 0) prompt();
		no_reprint_prmpt = 0;
		memset ( line, '\0', MAXLINE );
		fgets(line, MAXLINE, stdin);
		if((tokens[0] = strtok(line," \n\t")) == NULL) continue;
		numTokens = 1;
		while((tokens[numTokens] = strtok(NULL, " \n\t")) != NULL) numTokens++;		
		invoke(tokens);	
	}          
	exit(0);
}
Beispiel #27
0
LibraryManager::LibraryManager() {
  libraryManager = this;

  setTitle("Game Library");
  setGeometry({128, 128, 640, 680});
  windowManager->append(this, "LibraryManager");

  layout.setMargin(5);
  bootstrap();
  libraryFrame.append("Import");
  libraryFrame.setLayout(browsers.size(), libraryImport);
  loadButton.setText("Load");

  unsigned height = Font::size(program->normalFont, " ").height;

  append(layout);
  layout.append(libraryFrame, {~0, ~0}, 5);
  layout.append(informationLayout, {~0, 0});
  informationLayout.append(information, {~0, height * 3}, 5);
  informationLayout.append(skipButton, {80, 0}, 5);
  informationLayout.append(loadButton, {80, 0});

  onClose = skipButton.onActivate = [&] {
    setModal(false);
    setVisible(false);
  };

  libraryFrame.onChange = {&LibraryManager::onChange, this};
  loadButton.onActivate = {&LibraryManager::onLoad, this};

  //initial config value of -1 defaults to import tab on first launch of higan
  if(config->library.selection < 0) config->library.selection = browsers.size();
  libraryFrame.setSelection(config->library.selection);

  if(libraryFrame.selection() < browsers.size()) {
    browsers[libraryFrame.selection()]->mediaMode.setSelection(config->library.mediaMode);
    browsers[libraryFrame.selection()]->setMode();
  }
}
Beispiel #28
0
void run_simulation(simulation_t *sim,FILE *outfile){
  DMSG("enter run_simulation");
  int *historyZ = malloc(sizeof(int) * (sim->iterations + 1));
  double *historyTheta = malloc(sizeof(double) * (sim->iterations + 1));	

  historyZ[0] = 200;
  

  int x,y,z;
  double theta;


  for(int i = 1; i <= sim->iterations; i++){
    bootstrap(gen,sim,&x,&y);
    historyTheta[i] = gibbs_sampler(gen,sim,historyZ,i,x,y);
  }	
  fprintf(outfile,"Z,\ttheta\n");
  
  for(int i = 1; i <= sim->iterations; i++){
    fprintf(outfile,"[%5d] Successes: %3d\t Theta = %.10f\n",i,historyZ[i],historyTheta[i]);
  }  
  DMSG("leave runsim");
}
Beispiel #29
0
void Tree::grow(std::vector<double>* variable_importance) {

  this->variable_importance = variable_importance;

  // Bootstrap, dependent if weighted or not and with or without replacement
  if (case_weights->empty()) {
    if (sample_with_replacement) {
      bootstrap();
    } else {
      bootstrapWithoutReplacement();
    }
  } else {
    if (sample_with_replacement) {
      bootstrapWeighted();
    } else {
      bootstrapWithoutReplacementWeighted();
    }
  }

  // While not all nodes terminal, split next node
  size_t num_open_nodes = 1;
  size_t i = 0;
  while (num_open_nodes > 0) {
    bool is_terminal_node = splitNode(i);
    if (is_terminal_node) {
      --num_open_nodes;
    } else {
      ++num_open_nodes;
    }
    ++i;
  }

  // Delete sampleID vector to save memory
  sampleIDs.clear();
  cleanUpInternal();
}
bool MapMatchingDynamicClusterer::add_clustering( Clustering &step_clustering )
{
	m_step += 1;
	/// First?
	if( m_step == 1 )
	{
		return bootstrap(step_clustering);
	}
	
	int step_cluster_index = 0;

	/// Build a map of Nodes -> Dynamic Communities containing those nodes
	map<NODE,set<int> > fastmap;
	DynamicClustering::iterator dit;
	DynamicClustering::iterator dend = m_dynamic.end();
	int dyn_count = (int)m_dynamic.size();
	int dyn_index = 0;
	long* dyn_sizes = new long[dyn_count+1];
	for( dit = m_dynamic.begin() ; dit != dend; dit++, dyn_index++ )
	{
		// Dead?
		if( m_death_age > 0 && m_dynamic[dyn_index].is_dead( m_step, m_death_age ) )
		{
			dyn_sizes[dyn_index] = 0;
			continue;
		}
		Cluster& front = (*dit).front();
		dyn_sizes[dyn_index] = (long)front.size();
		Cluster::const_iterator fit;
		Cluster::const_iterator	fend = front.end();
		for( fit = front.begin() ; fit != fend; fit++ )
		{
			NODE node_index = *fit;
			if( !fastmap.count( node_index ) )
			{
				set<int> first;
				first.insert(dyn_index);
				fastmap.insert( make_pair(node_index,first) );
			}
			else
			{
				fastmap[node_index].insert(dyn_index);
			}
		}
	}	

	/// Now try to match all
	int* all_intersection = new int[dyn_count+1];
	vector<DynamicCluster> fresh;
	PairVector matched_pairs;
	map<NODE,set<int> >::const_iterator mend = fastmap.end();
	Clustering::iterator cit;
	Clustering::iterator cend = step_clustering.end();
	for( cit = step_clustering.begin() ; cit != cend; cit++, step_cluster_index++ )
	{
		long size_step = (long)(*cit).size();
		if( size_step < MIN_CLUSTER_SIZE )
		{
			continue;
		}
		// Compute all intersections
		for( dyn_index = 0; dyn_index < dyn_count; dyn_index++)
		{
			all_intersection[dyn_index] = 0;
		}
		Cluster::const_iterator xit;
		Cluster::const_iterator	xend = (*cit).end();
		for( xit = (*cit).begin() ; xit != xend; xit++ )
		{
			NODE node_index = *xit;
			map<NODE,set<int> >::const_iterator mit = fastmap.find(node_index);
			if( mit != mend )
			{
				set<int>::const_iterator sit;
				for ( sit = fastmap[node_index].begin(); sit != fastmap[node_index].end(); sit++ )
				{
					all_intersection[(*sit)]++;
				}
			}
		}
		// Find matches
		vector<int> matches;
		for( dyn_index = 0; dyn_index < dyn_count; dyn_index++)
		{
			if( dyn_sizes[dyn_index] == 0 || all_intersection[dyn_index] == 0 )
			{
				continue;
			}
#ifdef SIM_OVERLAP
			double sim = ((double)(all_intersection[dyn_index]))/min(size_step,dyn_sizes[dyn_index]);
#else
			double sim = ((double)(all_intersection[dyn_index]))/(size_step+dyn_sizes[dyn_index]-all_intersection[dyn_index]);
#endif
			if( sim > m_threshold )
			{
				matches.push_back( dyn_index );
			}
		}

		// new community?
		if( matches.empty() )
		{
			DynamicCluster dc;
			dc.update( m_step, step_cluster_index, *cit );
			fresh.push_back(dc);
#ifdef DEBUG_MATCHING
			cout << "T" << m_step << ": Birth: Community M" << (m_dynamic.size()+fresh.size()) << " from C" << step_cluster_index+1 << endl;
#endif			
		}
		else
		{
			vector<int>::const_iterator iit;
			for( iit = matches.begin() ; iit != matches.end(); iit++ )
			{
				pair<int,int> p(step_cluster_index,(*iit));
				matched_pairs.push_back(p);
			}
		}
	}

	// Actually update existing dynamic communities now
	set<int> matched_dynamic;
	PairVector::const_iterator pit;
	for( pit = matched_pairs.begin(); pit != matched_pairs.end(); pit++ )
	{
		int step_cluster_index = (*pit).first;
		int dyn_cluster_index = (*pit).second;
		// already processed this dynamic cluster?
		if( matched_dynamic.count( dyn_cluster_index ) ) 
		{
			DynamicCluster dc( m_dynamic[dyn_cluster_index], m_step, step_cluster_index, step_clustering[step_cluster_index] );
			fresh.push_back(dc);
#ifdef DEBUG_MATCHING
			cout << "T" << m_step << ": Split: Matched C" << (step_cluster_index+1) << " to M" << (dyn_cluster_index+1) << ". Splitting to M" << (m_dynamic.size()+fresh.size()) <<  endl;
#endif
		}
		else
		{
#ifdef DEBUG_MATCHING
			cout << "T" << m_step << ": Continuation: Matched C" << (step_cluster_index+1) << " to M" << (dyn_cluster_index+1) << endl;
#endif
			m_dynamic[dyn_cluster_index].update( m_step, step_cluster_index, step_clustering[step_cluster_index] );
			matched_dynamic.insert(dyn_cluster_index);
		}
	}
	// And finally add any new dynamic communities
	for( dit = fresh.begin() ; dit != fresh.end(); dit++ )
	{
		m_dynamic.push_back(*dit);
	}

	delete[] dyn_sizes;
	delete[] all_intersection;
	return true;
}