示例#1
0
文件: main.C 项目: ibukanov/ahome
void loopMassMuTan(
    ConstData& constData, const Intervals& intervals,
    const BeamParams& beamParam,
    DataSeparator& massSeparator, DataSeparator& csSeparator,
    FILE* massOut, FILE* crossSectionOut) 
{
    for (unsigned i = 0; i < intervals.Lambda_tilda_mass.pointCount(); ++i) 
    {
        double lambdaMass = intervals.Lambda_tilda_mass.point(i);
        for (unsigned j_re = 0; j_re < intervals.mu_re.pointCount(); ++j_re) 
        {
            double mu1 = intervals.mu_re.point(j_re);
            for (unsigned j_im = 0; j_im < intervals.mu_im.pointCount(); ++j_im) 
            {
                double mu2 = intervals.mu_im.point(j_im);
                double mu_re, mu_im;
                if (intervals.mu_as_x_and_y) 
                {
                    mu_re = mu1;
                    mu_im = mu2;
                }
                else
                {
                    mu_re = mu1 * cos(mu2);
                    mu_im = mu1 * sin(mu2);
                }
                for (unsigned k = 0; k < intervals.tan_beta.pointCount(); ++k) 
                { 
                    double tan_beta = intervals.tan_beta.point(k);

                    CSet set;
                    set.calculate(mu_re, mu_im, tan_beta, lambdaMass, 
                                  constData);
                    char charsForMass[100];
                    sprintf(charsForMass, " % .6e % .6e % .6e % .6e", 
                            lambdaMass, mu1, mu2, tan_beta); 
                    double mass = ysqrt(set.chargino_mass_in2);
                    fprintf(massOut, "%s % .6e\n", charsForMass, mass);
                    calculate_cs(charsForMass, 
                                 intervals, constData, set, beamParam, 
                                 csSeparator, crossSectionOut);
                }
                csSeparator.make(intervals.tan_beta); 
                massSeparator.make(intervals.tan_beta); 
            }
            csSeparator.make(intervals.mu_im); 
            massSeparator.make(intervals.mu_im); 
        }      
        csSeparator.make(intervals.mu_re); 
        massSeparator.make(intervals.mu_re); 
    }
    csSeparator.make(intervals.Lambda_tilda_mass); 
    massSeparator.make(intervals.Lambda_tilda_mass); 
}
 // Remove all items from the instance of the CSet<Tsint> class.
 static void remove(IWriter& writer, CSet<Tsint>& a_rSet)
 { CALL
   writer << STR("CSet<Tsint>(") << STR("size = ") << a_rSet.getSize() << STR(")") << ln;
   CSet<Tsint>::TIterator it = a_rSet.getItFirst();
   writer << STR("{") << ln;
   while (it.isValid())
   {
     writer << STR(" removed item = ") << *it << ln;
     it.remove();
   }
   writer << STR("}") << ln;
 }
 // Write instance of the CSet<Tsint> class into the given writer.
 static void show(IWriter& writer, const CSet<Tsint>& a_crSet)
 { CALL
   writer << STR("CSet<Tsint>(") << STR("size = ") << a_crSet.getSize() << STR(")") << ln;
   CSet<Tsint>::TIteratorConst it = a_crSet.getItFirst();
   if (it.isValid())
   {
     writer << STR("{") << ln;
     do
     {
       writer << STR(" item = ") << *it << ln;
     } while (it.stepForward() == 1);
     writer << STR("}") << ln;
   }
 }
  Tsint main(const CStringBuffer<CString>& a_crArguments, const CStringBuffer<CString>& a_crEnvironment)
  { CALL
    IGNORE_UNUSED(a_crArguments);
    IGNORE_UNUSED(a_crEnvironment);

    // Use standard output stream of the current process.
    CStreamStdOutput stdoutput(true);

    CSet<Tsint> a;

    // Fill the set.
    a.insert(6);
    a.insert(3);
    a.insert(7);
    a.insert(2);
    a.insert(8);
    a.insert(1);
    a.insert(4);
    a.insert(9);
    a.insert(5);
    a.insert(6);
    a.insert(3);
    a.insert(7);
    a.insert(2);
    a.insert(8);
    a.insert(1);
    a.insert(4);
    a.insert(9);
    a.insert(5);

    // Show the set.
    show(stdoutput, a);

    // Copy the set.
    CSet<Tsint> b(a);

    // Show the copied set.
    show(stdoutput, b);

    // Remove items from the set.
    remove(stdoutput, b);

    return IApplication::EXIT_WITH_SUCCESS;
  }
示例#5
0
unsigned int WINAPI TaskSynch::SynchThreadProc(void *pContext)
{
	TaskSynch *pSynch = reinterpret_cast<TaskSynch *>(pContext);
	WaitForSingleObject(pSynch->m_synchMap.m_synchEvent, INFINITE);
	ResetEvent(pSynch->m_synchMap.m_synchEvent);
	while(pSynch->m_synchMap.GetCount())
	{
		SynchData *pSynchData = pSynch->m_synchMap.Get(0);
		if(pSynchData)
		{
			Group *pGroup = pSynch->m_pDataManager->GetGroupManagerInstance()->GetGroup(pSynchData->m_sbGroup);
			if(pGroup)
			{
				int count = 0;
				unsigned __int64 *pIDs = pGroup->GetTaskIDs(&count);
				//TODO: build sets then use diffSet to get the missing items.. synch the existing items
				//and request the missing items
				SortedSet<unsigned __int64> localIDs;
				localIDs.addAll(pIDs, count);
				SortedSet<unsigned __int64> foreignIDs;
				delete [] pIDs;
				foreignIDs.addAll(pSynchData->m_pIDs, pSynchData->m_taskCount);
				CSet<unsigned __int64, 32> remainingIDs = localIDs.diff(foreignIDs);
				IterWrapper<Task> iter(pGroup->IterateTasks());
				while(iter.Next())
				{
					pSynch->SynchTaskTreeSeg(iter.Get(), pSynchData->m_ipSet[0]);
				}
				IterWrapper<unsigned __int64> idIter(remainingIDs.Iterate());
				int len = 0;
				char * pMsg = NULL;
				while(idIter.Next())
				{
					pMsg = MakeReqTask(*idIter.Get(), &len, true);
					pSynch->m_pNetwork->Send(pMsg, len, pSynchData->m_ipSet[0]);
				}
			}
		}
		pSynch->m_synchMap.RemoveItem(0);
	}
	pSynch->m_threadID = 0;
	return 0;
}
示例#6
0
文件: Forest.cpp 项目: robfinch/Cores
int Forest::GetSpillCount()
{
	int c;
	int spillCount;
	CSet ts;
	char buf[2000];

	ts.clear();
	for (spillCount = c = 0; c < treecount; c++) {
		if (trees[c]->spill) {
			spillCount++;
			ts.add(c);
		}
	}
	dfs.printf("<SpillCount>%d</SpillCount>\n", spillCount);
	ts.sprint(buf, sizeof(buf));
	dfs.printf("<TreesSpilled>%s</TreesSpilled>\n", buf);
	return (spillCount);
}
示例#7
0
文件: Forest.cpp 项目: robfinch/Cores
void Forest::Color()
{
	int nn, m;
	int c;
	int j, k = 17;
	int *p;
	CSet used;
	Tree *t;

	if (pass == 1) {
		for (c = 0; c < treecount; c++) {
			trees[c]->spill = false;
			trees[c]->color = k;
			if (trees[c]->var < 3)
				trees[c]->color = trees[c]->var;
			if (trees[c]->var >= regFirstArg && trees[c]->var <= regLastArg) {
				trees[c]->color = trees[c]->var - regFirstArg + 18;
			}
			if (trees[c]->var == regFP
				|| trees[c]->var == regLR
				|| trees[c]->var == regXLR
				|| trees[c]->var == regSP) {
				trees[c]->color = trees[c]->var - regXLR + 28;
			}
		}
	}
	used.clear();
	used.add(0);	// reg0 is a constant 0
	used.add(1);	// these two are return value
	used.add(2);
	while (!stk->IsEmpty()) {
		t = trees[m=pop()];
		if (pass == 1 && !t->infinite && t->cost < 0.0f) {	// was <= 0.0f
			t->spill = true;
		}
		else {
			p = iGraph.GetNeighbours(m, &nn);
			for (j = 0; j < nn; j++)
				used.add(trees[p[j]]->color);
			for (c = 0; used.isMember(c) && c < k; c++);
			if (c < k && t->color == k) {	// The tree may have been colored already
				t->color = c;
				used.add(c);
			}
			else if (t->color <= k)		// Don't need to spill args
				t->spill = true;
		}
	}
}
示例#8
0
 void CRABMedium::Update() {
    /* Update positional index of RAB entities */
    m_pcRABEquippedEntityIndex->Update();
    /* Delete routing table */
    for(TRoutingTable::iterator it = m_tRoutingTable.begin();
        it != m_tRoutingTable.end();
        ++it) {
       it->second.clear();
    }
    /* This map contains the pairs that have already been checked */
    unordered_map<ssize_t, std::pair<CRABEquippedEntity*, CRABEquippedEntity*> > mapPairsAlreadyChecked;
    /* Iterator for the above structure */
    unordered_map<ssize_t, std::pair<CRABEquippedEntity*, CRABEquippedEntity*> >::iterator itPair;
    /* Used as test key */
    std::pair<CRABEquippedEntity*, CRABEquippedEntity*> cTestKey;
    /* Used as hash for the test key */
    UInt64 unTestHash;
    /* The ray to use for occlusion checking */
    CRay3 cOcclusionCheckRay;
    /* Buffer for the communicating entities */
    CSet<CRABEquippedEntity*,SEntityComparator> cOtherRABs;
    /* Buffer to store the intersection data */
    SEmbodiedEntityIntersectionItem sIntersectionItem;
    /* The distance between two RABs in line of sight */
    Real fDistance;
    /* Go through the RAB entities */
    for(TRoutingTable::iterator it = m_tRoutingTable.begin();
        it != m_tRoutingTable.end();
        ++it) {
       /* Get a reference to the current RAB entity */
       CRABEquippedEntity& cRAB = *reinterpret_cast<CRABEquippedEntity*>(GetSpace().GetEntityVector()[it->first]);
       /* Initialize the occlusion check ray start to the position of the robot */
       cOcclusionCheckRay.SetStart(cRAB.GetPosition());
       /* For each RAB entity, get the list of RAB entities in range */
       cOtherRABs.clear();
       m_pcRABEquippedEntityIndex->GetEntitiesAt(cOtherRABs, cRAB.GetPosition());
       /* Go through the RAB entities in range */
       for(CSet<CRABEquippedEntity*>::iterator it2 = cOtherRABs.begin();
           it2 != cOtherRABs.end();
           ++it2) {
          /* Get a reference to the RAB entity */
          CRABEquippedEntity& cOtherRAB = **it2;
          /* First, make sure the entities are not the same */
          if(&cRAB != &cOtherRAB) {
             /* Proceed if the pair has not been checked already */
             if(&cRAB < &cOtherRAB) {
                cTestKey.first = &cRAB;
                cTestKey.second = &cOtherRAB;
             }
             else {
                cTestKey.first = &cOtherRAB;
                cTestKey.second = &cRAB;
             }
             unTestHash = HashRABPair(cTestKey);
             itPair = mapPairsAlreadyChecked.find(unTestHash);
             if(itPair == mapPairsAlreadyChecked.end() ||   /* Pair does not exist */
                itPair->second.first != cTestKey.first ||   /* Pair exists, but first RAB involved is different */
                itPair->second.second != cTestKey.second) { /* Pair exists, but second RAB involved is different */
                /* Mark this pair as already checked */
                mapPairsAlreadyChecked[unTestHash] = cTestKey;
                /* Proceed if the message size is compatible */
                if(cRAB.GetMsgSize() == cOtherRAB.GetMsgSize()) {
                   /* Proceed if the two entities are not obstructed by another object */
                   cOcclusionCheckRay.SetEnd(cOtherRAB.GetPosition());
                   if((!m_bCheckOcclusions) ||
                      (!GetClosestEmbodiedEntityIntersectedByRay(sIntersectionItem,
                                                                 cOcclusionCheckRay,
                                                                 cRAB.GetEntityBody())) ||
                      (&cOtherRAB.GetEntityBody() == sIntersectionItem.IntersectedEntity)) {
                      /* If we get here, the two RAB entities are in direct line of sight */
                      /* cRAB can receive cOtherRAB's message if it is in range, and viceversa */
                      /* Calculate square distance */
                      fDistance = cOcclusionCheckRay.GetLength();
                      if(fDistance < cOtherRAB.GetRange()) {
                         /* cRAB receives cOtherRAB's message */
                         m_tRoutingTable[cRAB.GetIndex()].insert(&cOtherRAB);
                      }
                      if(fDistance < cRAB.GetRange()) {
                         /* cOtherRAB receives cRAB's message */
                         m_tRoutingTable[cOtherRAB.GetIndex()].insert(&cRAB);
                      }
                   } // occlusion found?
                } // is msg size the same?
             } // is check necessary?
          } // are entities the same?
       } // for entities in range
    } // for routing table
 }
示例#9
0
文件: Forest.cpp 项目: robfinch/Cores
bool Forest::SpillCode()
{
	int c, m, n;
	Var *v;
	Tree *t;
	BasicBlock *bb;
	int64_t spillOffset;
	OCODE *cd;
	CSet spilled;
	bool ret;

	ret = false;
	cd = currentFn->spAdjust;
	if (cd == nullptr)
		return (ret);
	spillOffset = cd->oper3->offset->i;
	spilled.clear();
	for (c = 0; c < treecount; c++) {
		t = trees[c];	// convenience
		// Tree couldn't be colored that means there are no available registers.
		// So, spill one of the registers. The register to spill should be one
		// that isn't live at the same time as this tree.
		if (t->spill) {
			ret = true;
			v = Var::Find(t->var);
			v = v->GetVarToSpill(&spilled);
			if (v == nullptr)
				continue;
			// The var is spilled at the head of the tree, and restored later
			t->blocks->resetPtr();
			m = t->blocks->nextMember();
			if (m >= 0) {	// should always be true, otherwise no code
				bb = basicBlocks[m];
				if (!spilled.isMember(v->num)) {
					v->spillOffset = spillOffset;
					spillOffset += sizeOfWord;
					spilled.add(v->num);
				}
				bb->InsertSpillCode(v->num, -v->spillOffset);
				while(1) {
					n = m;
					m = t->blocks->nextMember();
					if (m < 0)
						break;
					// Detect when a different branch is present. The node
					// number will jump by more than 1 between branches.
					// *** suspect this won't work, should just pick last block in tree
					if (m - n > 1) {
						bb = basicBlocks[n];
						bb->InsertFillCode(v->num, -v->spillOffset);
					}
				}
				bb = basicBlocks[n];
				bb->InsertFillCode(v->num, -v->spillOffset);
			}
			t->spill = false;
		}
	}
	cd->oper3->offset->i = spillOffset;
	return (ret);
}