int main(int argc, char *argv[])
{
  
  boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB>> cloud;
  K2G k2g(OPENGL);
  std::cout << "getting cloud" << std::endl;
  cloud = k2g.getCloud();

  cloud->sensor_orientation_.w() = 0.0;
  cloud->sensor_orientation_.x() = 1.0;
  cloud->sensor_orientation_.y() = 0.0;
  cloud->sensor_orientation_.z() = 0.0;
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer->setBackgroundColor (0, 0, 0);
  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
  viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
  
  while (!viewer->wasStopped()) {
    viewer->spinOnce ();
    using namespace std::chrono;
    static high_resolution_clock::time_point last;

    auto tnow = high_resolution_clock::now();   
    cloud = k2g.getCloud();
    auto tpost = high_resolution_clock::now();
    std::cout << "delta " << duration_cast<duration<double>>(tpost-tnow).count()*1000 << std::endl;
    
    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
    viewer->updatePointCloud<pcl::PointXYZRGB> (cloud, rgb, "sample cloud"); 
  }

  k2g.shutDown();
  return 0;
}
/*
* Actual HL-Decomposition part
* Initially all entries of chainHead[] are set to -1.
* So when ever a new chain is started, chain head is correctly assigned.
* As we add a new node to chain, we will note its position in the baseArray.
* In the first for loop we find the child node which has maximum sub-tree size.
* The following if condition is failed for leaf nodes.
* When the if condition passes, we expand the chain to special child.
* In the second for loop we recursively call the function on all normal nodes.
* chainNo++ ensures that we are creating a new chain for each normal child.
*/
void HLD(int curNode, int cost, int prev) {
    if(chainHead[chainNo] == -1) {
        chainHead[chainNo] = curNode; // Assign chain head
    }
    
    chainInd[curNode] = chainNo;
    posInBase[curNode] = ptr; // Position of this node in baseArray which we will use in Segtree
    baseArray[ptr++] = cost;
    
    int sc = -1, ncost;
    // Loop to find special child
    for(int i=0; i<adj[curNode].size(); i++) if(adj[curNode][i] != prev) {
        if(sc == -1 || subsize[sc] < subsize[adj[curNode][i]]) {
            sc = adj[curNode][i];
            ncost = costs[curNode][i];
        }
    }
    
    if(sc != -1) {
        // Expand the chain
        HLD(sc, ncost, curNode);
    }
    
    for(int i=0; i<adj[curNode].size(); i++) if(adj[curNode][i] != prev) {
        if(sc != adj[curNode][i]) {
            // New chains at each normal node
            chainNo++;
            HLD(adj[curNode][i], costs[curNode][i], curNode);
        }
    }
}
Example #3
0
void nofCarrier::HandleDerivedEvent(const unsigned int id)
{
    switch(id)
    {
            // Produktivitätsevent
        case 1:
        {
            productivity_ev = 0;

            // Gucken, ob bis jetzt gearbeitet wurde/wird oder nicht, je nachdem noch was dazuzählen
            if(since_working_gf != 0xFFFFFFFF)
            {
                // Es wurde bis jetzt nicht mehr gearbeitet, das also noch dazuzählen
                worked_gf += static_cast<unsigned short>(GetEvMgr().GetCurrentGF() - since_working_gf);
                // Zähler zurücksetzen
                since_working_gf = GetEvMgr().GetCurrentGF();
            }

            // Produktivität ausrechnen
            productivity = worked_gf * 100 / PRODUCTIVITY_GF;

            // Zähler zurücksetzen
            worked_gf = 0;

            // Nächstes Event anmelden
            productivity_ev = GetEvMgr().AddEvent(this, PRODUCTIVITY_GF, 1);

            // Reif für einen Esel?
            if(productivity >= DONKEY_PRODUCTIVITY && ct == CT_NORMAL)
                workplace->UpgradeDonkeyRoad();

        } break;
    }
}
Example #4
0
/* This fuction determines the correct name of the file that the information
 * is dumped into 
 */
void createDataFile(char *name, int fileType){
  
    char *word;  //The timestamp that we will create the filename from
    char *prefix; //The beginning of the filename
    time_t timestamp; //The timestamp that we take for creating the file

    if(fileType == 2){
		prefix = "../data/L1Cache-2.";
    }
    else{
		prefix = "../data/L1Cache.";
    }
    timestamp = time(NULL);
    word = ctime(&timestamp);

	/* Here we are picking out the parts of the timestamp that we would like in the file name */
    strcpy(name, prefix); 		    
	strncat(name, &word[4], 3);
    if(word[8] == ' '){ word[8] = '0'; } //Get rid of spaces in the title
    strncat(name, &word[8], 2);
    strcat(name, ".");
    strncat(name, &word[11], 2);
    strcat(name, ".");
    strncat(name, &word[14], 2);
    strcat(name, ".");
    strncat(name, &word[17], 2);

    return;
}
Example #5
0
bool
Feature::getWorldBound(const SpatialReference* srs,
                       osg::BoundingSphered&   out_bound) const
{
    if ( srs && getSRS() && getGeometry() )
    {
        out_bound.init();

        ConstGeometryIterator i( getGeometry(), false); 
        while( i.hasMore() )
        {
            const Geometry* g = i.next();
            for( Geometry::const_iterator p = g->begin(); p != g->end(); ++p )
            {
                GeoPoint point( getSRS(), *p, ALTMODE_ABSOLUTE );
                GeoPoint srs_point;
                if ( point.transform( srs, srs_point ) )
                {
                    osg::Vec3d world;
                    srs_point.toWorld(world);
                    out_bound.expandBy( world );
                }
            }
        }
        if ( out_bound.valid() && out_bound.radius() == 0.0 )
        {
            out_bound.radius() = 1.0;
        }
        return true;
    }
    return false;
}
void SceneGraphWorker::run()
{
	//-------------------------------------------------------------------------
	// Start
	jobsCount = 1;
	done = 0;
	emit progress(0, 0); // undetermined (moving) progress bar

    repoLog("Fetching scene: " + database + ", " + project);
	repo::core::model::RepoScene *masterSceneGraph
		= controller->fetchScene(
		token,
		database,
		project,
		id.toString().toStdString(),
		headRevision,
		//THIS NEEDS TO SET TO FALSE IF YOU WANT TO EXAMINE THE SCENE
		//at the moment we only visualise the scene so there isn't a need for the whole
		//scene graph being loaded onto memory.
		true ); 


	//--------------------------------------------------------------------------
	emit progress(++jobsCount, jobsCount);
	//--------------------------------------------------------------------------
	emit finished(masterSceneGraph);
	emit RepoAbstractWorker::finished();
}
Example #7
0
int cppalgo::Fibonacci::fibonacci(int n)
{
    if (n == 1 || n == 2)
        return 1;
    else
        return fibonacci(n - 1) + fibonacci(n - 2);
}
/** Processes branches that are in progress, removing those that have
 * completed.
 * @return the number of contigs and k-mer assembled
 */
pair<size_t, size_t> NetworkSequenceCollection::
processBranchesAssembly(ISequenceCollection* seqCollection,
		FastaWriter* fileWriter, unsigned currContigID)
{
	size_t assembledContigs = 0, assembledKmer = 0;
	for (BranchGroupMap::iterator it = m_activeBranchGroups.begin();
			it != m_activeBranchGroups.end();) {
		if (!it->second.isActive()) {
			assert(it->second.size() == 1);
			BranchRecord& branch = it->second[0];
			assert(branch.getState() == BS_NOEXT
					|| branch.getState() == BS_AMBI_SAME
					|| branch.getState() == BS_AMBI_OPP);
			if (branch.isCanonical()) {
				assembledContigs++;
				assembledKmer += branch.size();
				assembleContig(seqCollection, fileWriter, branch,
						m_numAssembled + currContigID++);
			}
			m_activeBranchGroups.erase(it++);
		} else
			++it;
	}
	return make_pair(assembledContigs, assembledKmer);
}
void NetworkSequenceCollection::processSequenceExtension(
		uint64_t groupID, uint64_t branchID, const Kmer& seq,
		const ExtensionRecord& extRec, int multiplicity)
{
	switch(m_state)
	{
		case NAS_TRIM:
			return processLinearSequenceExtension(groupID, branchID,
					seq, extRec, multiplicity, m_trimStep);
		case NAS_ASSEMBLE:
		case NAS_COVERAGE:
			return processLinearSequenceExtension(groupID, branchID,
					seq, extRec, multiplicity, UINT_MAX);
		case NAS_DISCOVER_BUBBLES:
			return processSequenceExtensionPop(groupID, branchID,
					seq, extRec, multiplicity,
					opt::bubbleLen - opt::kmerSize + 1);
		case NAS_WAITING:
			if (m_finishedGroups.count(groupID) == 0) {
				logger(0) << "error: unexpected seqext message: "
					"state: " << m_state << " "
					"gid: " << groupID << " bid: " << branchID << " "
					"seq: " << seq.str() << '\n';
				assert(false);
			}
			break;
		default:
			logger(0) << "error: unexpected seqext message: "
				"state: " << m_state << " "
				"gid: " << groupID << " bid: " << branchID << " "
				"seq: " << seq.str() << '\n';
			assert(false);
			break;
	}
}
SharedPointer< OrientedQuadParticleRenderer > LuaOrientedQuadParticleRendererBuilder::build( ScriptEvaluator &eval )
{
	auto renderer = crimild::alloc< OrientedQuadParticleRenderer >();

	std::string textureFileName;
	if ( eval.getPropValue( "texture", textureFileName ) ) {
		auto texture = crimild::alloc< Texture >( crimild::alloc< ImageTGA >( FileSystem::getInstance().pathForResource( textureFileName ) ) );
		renderer->getMaterial()->setColorMap( texture );
	}

	std::string blendMode;
	if ( eval.getPropValue( "blendMode", blendMode ) ) {
		if ( blendMode == "additive" ) {
			renderer->getMaterial()->setAlphaState( crimild::alloc< AlphaState >( true, AlphaState::SrcBlendFunc::SRC_ALPHA, AlphaState::DstBlendFunc::ONE ) );
		}
		else {
			renderer->getMaterial()->setAlphaState( AlphaState::ENABLED );
		}
	}

	crimild::Bool cullFaceEnabled;
	if ( eval.getPropValue( "cullFaceEnabled", cullFaceEnabled ) ) {
		renderer->getMaterial()->getCullFaceState()->setEnabled( cullFaceEnabled );
	}

	crimild::Bool depthStateEnabled;
	if ( eval.getPropValue( "depthStateEnabled", depthStateEnabled ) ) {
		renderer->getMaterial()->setDepthState( depthStateEnabled ? DepthState::ENABLED : DepthState::DISABLED );
	}

	return renderer;
}
Example #11
0
int main() {
    //We find the number of solutions to
    //the Diophantine equation
    //2x + 4y - 3 = n
    ll ways=0;
    ll a = 1201763915ll;
    ll b = 2;
    ll c = 2403527830ll;
    ll d = -1;
    ll x,y;
    for (ll t = 1; ; t++) {
        x = a-b*t;
        y = c-d*t;
        if (x<0 or y<0) break;
        if (gcd(x,y)!=1) continue;
        ways++;
    }
    for (ll t = 0; ; t++) {
        x = a+b*t;
        y = c+d*t;
        if (x<0 or y<0) break;
        if (x>=y) break;
        if (gcd(x,y)!=1) continue;
        ways++;
    }
    cout << 2*ways << endl;
    return 0;
}
Example #12
0
// Replace a sequence of branches leading to a ret, with a clone of a ret
// instruction. Suspend instruction represented by a switch, track the PHI
// values and select the correct case successor when possible.
static bool simplifyTerminatorLeadingToRet(Instruction *InitialInst) {
  DenseMap<Value *, Value *> ResolvedValues;

  Instruction *I = InitialInst;
  while (isa<TerminatorInst>(I)) {
    if (isa<ReturnInst>(I)) {
      if (I != InitialInst)
        ReplaceInstWithInst(InitialInst, I->clone());
      return true;
    }
    if (auto *BR = dyn_cast<BranchInst>(I)) {
      if (BR->isUnconditional()) {
        BasicBlock *BB = BR->getSuccessor(0);
        scanPHIsAndUpdateValueMap(I, BB, ResolvedValues);
        I = BB->getFirstNonPHIOrDbgOrLifetime();
        continue;
      }
    } else if (auto *SI = dyn_cast<SwitchInst>(I)) {
      Value *V = SI->getCondition();
      auto it = ResolvedValues.find(V);
      if (it != ResolvedValues.end())
        V = it->second;
      if (ConstantInt *Cond = dyn_cast<ConstantInt>(V)) {
        BasicBlock *BB = SI->findCaseValue(Cond)->getCaseSuccessor();
        scanPHIsAndUpdateValueMap(I, BB, ResolvedValues);
        I = BB->getFirstNonPHIOrDbgOrLifetime();
        continue;
      }
    }
    return false;
  }
  return false;
}
Example #13
0
void run_fine_grained()
{
   pthread_t write_threads[NUM_WRITE_THREADS];
   pthread_t read_threads[NUM_WRITE_THREADS];
   pthread_barrier_init(&thread_barrier,NULL,NUM_READ_THREADS+NUM_WRITE_THREADS);
   
   // Create threads
   
   for(int i(0); i< NUM_WRITE_THREADS; i++)
   {
       pthread_create(&(write_threads[i]), NULL, thread_fine_grained_write, NULL);
   }
   
   for(int i(0); i< NUM_READ_THREADS; i++)
   {
       pthread_create(&(read_threads[i]), NULL, thread_fine_grained_read, (void*) NULL);
   }
   
   // Threads will only start when they reach the desired number
   
   // Wait for threads
   
   for(int i(0); i< NUM_WRITE_THREADS; i++)
   {
       pthread_join((write_threads[i]), NULL);
   }
   
   for(int i(0); i< NUM_READ_THREADS; i++)
   {
       pthread_join((read_threads[i]), NULL);
   }
   
   // Destroy the barrier
   pthread_barrier_destroy(&thread_barrier);
}
Example #14
0
// Server host initiate.
ServerSocket::ServerSocket(int portInput, int noOfConnections)
{
try 
{
  // Structure is used by Windows Sockets to specify a local or remote endpoint address to which to connect a socket.
  sockaddr_in sockAddress;


  // Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
  memset(&sockAddress, 0, sizeof(sockAddress));

  sockAddress.sin_family = PF_INET;             
  sockAddress.sin_port = htons(portInput);          
  DefaultSocket = socket(AF_INET, SOCK_STREAM, 0);
  if (DefaultSocket == INVALID_SOCKET) {
    throw "INVALID_SOCKET";
  }
  /* bind the socket to the internet address */
  if (bind(DefaultSocket, (sockaddr *)&sockAddress, sizeof(sockaddr_in)) == SOCKET_ERROR) {
    closesocket(DefaultSocket);
    throw "INVALID_SOCKET";
  }
  
  listen(DefaultSocket, noOfConnections);                               
}
catch (exception &e)
	{
		cout << endl << "Socket Exception: " << e.what() << endl;
		ErrorLogger::LogError(e.what());
	}

}
Example #15
0
            void imprimirTeclasArriba(int numTecla){

            int anchura[12] = {2,1,1,1,2,2,1,1,1,1,1,2};
            bool ultimaFila = false;

            imprimirEspacios(25);
            cout << " ___________________________ " << endl;

            for ( int fila=0 ;fila<4 ;fila++ ){

                if (fila==3){ultimaFila=true;}
                imprimirEspacios(25);

                for ( int tecla=0 ; tecla<12 ; tecla++ ){
                    cout << "|";
                    if ( tecla==numTecla ){
                        for ( int ancho=0 ; ancho < anchura[tecla] ; ancho++ ){
                            cout << "#";
                        }
                    }
                    else{
                        for ( int ancho=0 ; ancho < anchura[tecla] ; ancho++ ){
                            if (ultimaFila && ( tecla==1 || tecla==3 || tecla==6 || tecla==8 || tecla==10) ){
                                cout << "_";
                            }
                            else{
                                cout << " ";
                            }
                        }
                    }
                }
                cout << "|" << endl;
            }
        }
/** Pop bubbles discovered previously. */
size_t NetworkSequenceCollection::
performNetworkPopBubbles(ostream& out)
{
	Timer timer("NetworkPopBubbles");

	// Deal with any packets still in the queue. The barrier
	// synchronization guarantees that the packets have been
	// delivered, but we may not have dealt with them yet.
	pumpNetwork();
	assert(m_comm.receiveEmpty());

	size_t numPopped = 0;
	for (BranchGroupMap::iterator iter = m_bubbles.begin();
			iter != m_bubbles.end(); iter++) {
		assert(iter->second.getStatus() == BGS_JOINED);
		// Check whether this bubble has already been popped.
		if (!iter->second.isAmbiguous(m_data))
			continue;
		numPopped++;
		AssemblyAlgorithms::writeBubble(out,
				iter->second, m_numPopped + numPopped);
		AssemblyAlgorithms::collapseJoinedBranches(
				this, iter->second);
		assert(!iter->second.isAmbiguous(m_data));
		assert(m_comm.receiveEmpty());
	}
	m_bubbles.clear();
	out.flush();
	assert(out.good());

	logger(0) << "Removed " << numPopped << " bubbles.\n";
	return numPopped;
}
Example #17
0
        void imprimirPiano(int tecla , string nota){

            system("cls");
            cout << endl << endl << endl << endl;
            imprimirEspacios(37);
            cout << "PIANO" << endl << endl;
            imprimirEspacios(38);
            cout << nota << endl << endl;

            imprimirTeclasArriba(tecla);
            if (tecla==0){
                imprimirTeclasAbajo(0);
            }
            else if (tecla==2){
                imprimirTeclasAbajo(1);
            }
            else if (tecla==4){
                imprimirTeclasAbajo(2);
            }
            else if (tecla==5){
                imprimirTeclasAbajo(3);
            }
            else if (tecla==7){
                imprimirTeclasAbajo(4);
            }
            else if (tecla==9){
                imprimirTeclasAbajo(5);
            }
            else if (tecla==11){
                imprimirTeclasAbajo(6);
            }
            else{
                imprimirTeclasAbajo(-1);
            }
        }
/** Pop the bubbles discovered previously. */
size_t NetworkSequenceCollection::controlPopBubbles(ostream& out)
{
	controlDiscoverBubbles();
	m_comm.sendControlMessage(APC_BARRIER);
	m_comm.barrier();
	pumpNetwork();

	// Perform a round-robin bubble pop to avoid concurrency issues
	SetState(NAS_POPBUBBLE);
	m_checkpointSum = performNetworkPopBubbles(out);
	EndState();

	// Now tell all the slave nodes to perform the pop one by one
	for(int i = 1; i < opt::numProc; i++) {
		m_comm.sendControlMessage(APC_BARRIER);
		m_comm.barrier();
		m_numReachedCheckpoint = 0;
		m_comm.sendControlMessageToNode(i, APC_POPBUBBLE,
				m_numPopped + m_checkpointSum);
		while (!checkpointReached(1))
			pumpNetwork();
	}

	size_t numPopped = m_checkpointSum;
	m_numPopped += numPopped;
	if (numPopped > 0)
		cout << "Removed " << numPopped << " bubbles.\n";
	return numPopped;
}
int gettimeofday(struct timeval *tv/*in*/, struct timezone *tz/*in*/)
{
	FILETIME ft;
	__int64 tmpres = 0;
	TIME_ZONE_INFORMATION tz_winapi;
	int rez = 0;

	ZeroMemory(&ft, sizeof(ft));
	ZeroMemory(&tz_winapi, sizeof(tz_winapi));

	GetSystemTimeAsFileTime(&ft);

	tmpres = ft.dwHighDateTime;
	tmpres <<= 32;
	tmpres |= ft.dwLowDateTime;

	/*converting file time to unix epoch*/
	tmpres /= 10;  /*convert into microseconds*/
	tmpres -= DELTA_EPOCH_IN_MICROSECS;
	tv->tv_sec = (__int32)(tmpres*0.000001);
	tv->tv_usec = (tmpres % 1000000);


	//_tzset(),don't work properly, so we use GetTimeZoneInformation
	/*
	rez = GetTimeZoneInformation(&tz_winapi);
	tz->tz_dsttime = (rez == 2) ? true : false;
	tz->tz_minuteswest = tz_winapi.Bias + ((rez == 2) ? tz_winapi.DaylightBias : 0); */

	return 0;
}
Example #20
0
void AgencyCallback::refetchAndUpdate(bool needToAcquireMutex) {
  if (!_needsValue) {
    // no need to pass any value to the callback
    if (needToAcquireMutex) {
      CONDITION_LOCKER(locker, _cv);
      executeEmpty();
    } else {
      executeEmpty();
    }
    return;
  }

  AgencyCommResult result = _agency.getValues(key);

  if (!result.successful()) {
    return;
  }
  
  std::vector<std::string> kv = basics::StringUtils::split(AgencyComm::prefixPath() + key,'/');
  kv.erase(std::remove(kv.begin(), kv.end(), ""), kv.end());
  
  std::shared_ptr<VPackBuilder> newData = std::make_shared<VPackBuilder>();
  newData->add(result.slice()[0].get(kv));
  
  if (needToAcquireMutex) {
    CONDITION_LOCKER(locker, _cv);
    checkValue(newData);
  } else {
    checkValue(newData);
  }
}
Example #21
0
const char* signalToString(uint32_t signal)
{
    uint32_t i;
    for(i=0; i<sizeof(sigTable)/sizeof(struct SignalEntry); i++)
        if (sigTable[i].value==signal) return sigTable[i].szValue;
    return "UNKNOWN";
       }
Example #22
0
	FlujoCosto AumentarFlujo( int s, int t, Flujo f ){
		Costo1D dist( n, CINF );
		fill( prv.begin(), prv.end(), Par( -1, -1 ) );
		priority_queue <CostoNodo, vector<CostoNodo>, greater<CostoNodo> > pq;
		pq.push( FlujoCosto( 0, s ) ); dist[s] = 0;
		while( !pq.empty() ){
			int u = pq.top().second;
			Costo p = pq.top().first;
			pq.pop();
			if( !Igual( dist[u], p ) ) continue;
			for( int i = 0; i < aristas[u].size(); i++ ){
				AristaFlujo* v = aristas[u][i];
				if( v->flujo == v->cap ) continue;
				Costo ndist = dist[u] + v->npeso;
				if( !Igual( ndist, dist[v->dst] ) && ndist < dist[ v->dst ]){
					dist[ v->dst ] = dist[u] + v->npeso;
					pq.push( CostoNodo( ndist, v->dst ) );
					prv[ v->dst ].second = i;
					prv[v->dst].first = u;
				}
			}
		}
		if( Igual( dist[t], CINF ) ) return FlujoCosto( 0, 0 );
		RecalcularCosto( dist );
		return ActualizarFlujo( t, f );
	}
Example #23
0
void CPROD (pInt, Int *, Int *, Bool *, Real * x, Real * y, Real * p, Real * q) {
  Real x1 = x[0], x2 = x[1];
  Real y1 = y[0], y2 = y[1];
  q[0] = - y1 * exp(x1) * p[0];
  q[1] = - y2 * exp(x2) * p[1];
  q[2] = 0;
}
Example #24
0
int main()
{
    #ifdef tuhin
    freopen("1138.in","r",stdin);
    #endif
    int tc,cs=1,t,lo,hi,mid;
    scanf("%d",&tc);
    while(tc--){
        scanf("%d",&t);
        lo=1;
        hi=90000000;
        for(;hi-lo>=1;){
            mid=(hi+lo)/2;
            if(nofzero(mid*5)==t) break;
            if(nofzero(mid*5)>t) hi=mid-1;
            else lo=mid+1;
        }

        if(hi-lo<=1)
            printf("Case %d: %d\n",cs++,mid*5);
        else
            printf("Case %d: impossible\n",cs++);
    }
    return 0;
}
int dfs(int index, int pathValue)
{
	int t;
	for (int i = 0; i <= vertexNum + 1; i++)
		if (network[index][i] != 0 && visitedd[i] == false)
		{
			visitedd[i] = true;
			parent[i] = index;
			if (i == vertexNum + 1)
			{
				int result = min(pathValue, network[index][i]);
				int p = index;
				int q = i;
				while (p!=vertexNum)
				{
					network[p][q] -= result;
					network[q][p] = result;
					q = p;
					p = parent[p];
				}
				network[p][q] -= result;
				network[q][p] = result;
				return result;
			}
			else if (t = dfs(i, min(pathValue, network[index][i])))
				return t;
			else
			{
				visitedd[i] = false;
				continue;
			}
		}
	return 0;
}
Example #26
0
void assignBasicStemDirections(vector<vector<int> >& stemdir, 
		vector<vector<int> >& voice, vector<vector<vector<int> > >& notepos, 
		HumdrumFile& infile) {

	int i, j;
	for (i=0; i<infile.getNumLines(); i++) {
		if (!infile[i].isData()) {
				continue;
		}
		for (j=0; j<infile[i].getFieldCount(); j++) {
				if (!infile[i].isExInterp(j, "**kern")) {
				continue;
				}
				if (strcmp(infile[i][j], ".") == 0) {
				continue;
				}
				if (strchr(infile[i][j], 'r') != NULL) {
				continue;
				}
				if (removeQ) {
				removeStem2(infile, i, j);
				}

				if (strchr(infile[i][j], '/') != NULL) {
				stemdir[i][j] = +1;
				} else if (strchr(infile[i][j], '\\') != NULL) {
				stemdir[i][j] = -1;
				} else {
				stemdir[i][j] = determineChordStem(voice, notepos, infile, i, j);
				}
		}
	}
}
Example #27
0
void nofCarrier::LookForWares()
{
    // Gibts an dieser Flagge etwas, das ich tragen muss?
    if(workplace->AreWareJobs(!rs_dir, ct, true))
    {
        // Dann soll das CARRS_FETCHWARE übernehmen
        FetchWare(false);
    }
    else if(workplace->AreWareJobs(rs_dir, ct, false))
    {
        // Oder evtl auf der anderen Seite?
        state = CARRS_FETCHWARE;
        rs_dir = !rs_dir;
        rs_pos = 0;
        StartWalking(cur_rs->GetDir(rs_dir, rs_pos));
    }
    else
    {
        // Wieder zurück in die Mitte gehen
        state = CARRS_GOTOMIDDLEOFROAD;
        rs_dir = !rs_dir;
        rs_pos = 0;
        StartWalking(cur_rs->GetDir(rs_dir, rs_pos));
    }
}
Example #28
0
DataPhraseBin::DataPhraseBin(char *p_prefix, ifstream &ifs, DataPhraseBin* prev_df) : DataFile(p_prefix, ifs, prev_df),
 max_len(0), mode(0), src_phlen(0), tgt_phlen(0),
 inbphw(NULL),
 icnbphw(NULL),
 onbphw(NULL),
 ocnbphw(NULL),
 nbi(0)
{
    // DataPhraseBin <file_name> <resampl_coeff> <src_phrase_len> <tgt_phrase_len> [flags]
    // parse addtl params
  if (prev_df) {
    src_phlen=prev_df->src_phlen;
    tgt_phlen=prev_df->tgt_phlen;
    mode=prev_df->mode;
  }
  else {
    ifs >> src_phlen >> tgt_phlen >> mode;
    if (src_phlen<1 || src_phlen>9)
      Error("length of source phrases must be in [1,9]\n");
    if (tgt_phlen<1 || tgt_phlen>9)
      Error("length of target phrases must be in [1,9]\n");
    if (mode<0 || mode>DATA_PHRASE_IGN_ALL)
      Error("wrong value of DataPhraseBin mode\n");
  }

  do_constructor_work();
}
Example #29
0
int PkiUtility::SignCsr(const String& csrfile, const String& certfile)
{
	char errbuf[120];

	InitializeOpenSSL();

	BIO *csrbio = BIO_new_file(csrfile.CStr(), "r");
	X509_REQ *req = PEM_read_bio_X509_REQ(csrbio, NULL, NULL, NULL);

	if (!req) {
		Log(LogCritical, "SSL")
		    << "Could not read X509 certificate request from '" << csrfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
		return 1;
	}

	BIO_free(csrbio);

	boost::shared_ptr<X509> cert = CreateCertIcingaCA(X509_REQ_get_pubkey(req), X509_REQ_get_subject_name(req));

	X509_REQ_free(req);

	std::ofstream fpcert;
	fpcert.open(certfile.CStr());

	if (!fpcert) {
		Log(LogCritical, "cli")
		    << "Failed to open certificate file '" << certfile << "' for output";
		return 1;
	}

	fpcert << CertificateToString(cert);
	fpcert.close();

	return 0;
}
int main ()
{
    QuickFindUF uf(N);
    int *p;
    string result;
    p = uf.get_id();
    cout << "Current Table" << endl;
    cout << "--------------" << endl;

    print_ids(p);

    result = askuser();
    while (result != "quit") {
        if (result == "union") {
            cout << "Doing union..." << endl;
            int ux, uy;
            cout << "select number to union with: " << endl;
            cin >> ux;
            cout << "select number to " << ux << " with" << endl;
            cin >> uy;
            uf.custom_union(ux, uy);
            p = uf.get_id();
            print_ids(p);
        }
        result = askuser();
    }