void saveToReport(char report[DIM]) {
	FILE *save = NULL;
	char pathName[DIM] = "";
	printf("\nDrag-and-drop to here your txt file to save the report.\n");
	while (save == NULL) {
		gets_s(pathName);
		if (isContained("\\", pathName)) {
			if (isContained("\"", pathName)) {
				replace("\"", "", pathName);
			}
			else {
				sprintf(expressionF, pathName);
			}
			replace("\\", "AZ", expressionF);
			replace("AZ", "\\\\", expressionF);
			sprintf(pathName, "%s", expressionF);
		}
		save = fopen(pathName, "r");
		if (save == NULL) {
			printf("\nDrag-and-drop to here your txt file to save the report.\n");
		}
	}
	if (save != NULL) {
		fclose(save);
	}
	save = NULL;
	while (save == NULL) {
		save = fopen(pathName, "w");
	}
	fputs(report, save);
	fclose(save);
	printf("\n==> Your report was saved successfully. <==\n\n");
}
vector<Query::Query_t> Ccurve::linearizeRangeQuery(vector<int> low,vector<int> high)
{


	vector<Query::Query_t> qs;
		int curr_idx =linearizePointQuery(low);
		int limit = linearizePointQuery(high);

		//cout<<curr_idx<<"-"<<limit<<endl;

		while(curr_idx<=limit)
		{

			//cout<<"curr idx:"<<curr_idx<<endl;
			//cout<<"limit: "<<limit<<endl;


				Query::Query_t q;
				while(!isContained(delinearizeCurveValue(curr_idx),low,high))
				{
					//printp(delinearizeCurveValue(curr_idx));
					//getchar();
					curr_idx++;
					if(curr_idx>limit)
					{
						return qs;
					}
				}
				q.left = curr_idx;

				while(isContained(delinearizeCurveValue(curr_idx),low,high))
				{
					curr_idx++;
					if(curr_idx>limit)
					{
						curr_idx = limit+1;
						break;
					}
				}

				q.right = curr_idx-1;

				qs.push_back(q);
				if(curr_idx == limit)
					break;

		}

/*
		cout<<"Ccurve interval count:"<<qs.size()<<endl;
		cout<<"range q:"<<endl;
			cout<<low[0]<<","<<low[1]<<","<<low[2]<<endl;
		      	cout<<high[0]<<","<<high[1]<<","<<high[2]<<endl;*/


		return qs;

}
static int processEntry (MrfEntry *currEntry, char *targetName, int targetStart, int targetEnd) 
{
  int containment;

  containment = 0;
  containment += isContained (&currEntry->read1,targetName,targetStart,targetEnd);
  if (currEntry->isPairedEnd) {
    containment += isContained (&currEntry->read2,targetName,targetStart,targetEnd);
  }
  return containment;
}
static void processEntry (MrfEntry *currEntry, char *targetName, int targetStart, int targetEnd) 
{
  int containment;

  containment = 0;
  containment += isContained (&currEntry->read1,targetName,targetStart,targetEnd);
  if (currEntry->isPairedEnd) {
    containment += isContained (&currEntry->read2,targetName,targetStart,targetEnd);
  }
  if (containment != 0) {
    puts (mrf_writeEntry (currEntry));
  }
}
static void processEntry (MrfEntry *currEntry, int mode) 
{
  int containment;

  containment = 0;
  containment += isContained (&currEntry->read1);
  if (currEntry->isPairedEnd) {
    containment += isContained (&currEntry->read2);
  }
  if ((containment != 0 && mode == MODE_INCLUDE) ||
      (containment == 0 && mode == MODE_EXCLUDE)) {
    puts (mrf_writeEntry (currEntry));
  }
}
Exemple #6
0
uint64_t Block::findPhysicalAddress(uint64_t i_vaddr) const
{
    uint64_t paddr = -EFAULT;

    if(!isContained(i_vaddr))
    {
        return (iv_nextBlock ?
                iv_nextBlock->findPhysicalAddress(i_vaddr) : paddr);
    }

    ShadowPTE* pte = getPTE(i_vaddr);

    if (pte->isPresent() && pte->getPage() != 0)
    {
        paddr = pte->getPageAddr();
        paddr += i_vaddr % PAGESIZE;

        // If not a physically mapped block then add HRMOR
        if (!iv_mappedToPhysical)
        {
            paddr |= getHRMOR();
        }
    }

    return paddr;
}
Exemple #7
0
void Block::updateRefCount( uint64_t i_vaddr,
                            PageTableManager::UsageStats_t i_stats )
{
    // Check containment, call down chain if address isn't in this block.
    if (!isContained(i_vaddr))
    {
        if (iv_nextBlock)
        {
            iv_nextBlock->updateRefCount(i_vaddr, i_stats);
        }
        else
        {
            // No block owns this address.  Code bug.
            printk("updateRefCount> i_vaddr=0x%.lX\n", i_vaddr );
            kassert(iv_nextBlock);
        }
        return;
    }

    ShadowPTE* spte = getPTE(i_vaddr);

    // Adjust the LRU statistics
    if( i_stats.R )
    {
        spte->zeroLRU();
    }
    else
    {
        spte->incLRU();
    }
}
Exemple #8
0
	size_t string::find_first_not_of(const char* s, size_t pos, size_t n) const
	{
		for (size_t i = pos; i != size(); ++i)
		{
			if (!isContained((*this)[i], s, s + n))
				return i;
		}
		return npos;
	}
Exemple #9
0
	size_t string::find_last_not_of(const char* s, size_t pos, size_t n) const
	{
		for (size_t i = pos; i >= 0; --i)
		{
			if (!isContained((*this)[i], s, s + n))
				return i;
		}
		return npos;
	}
/*!
Add a new entity to the entities list, and increment the reference counter of the entity added.
If the entity is already contained don't add and return false

\param theNewEntity
Entity to add

\return
- true if the new entity has been added correctly
- false if theNewEntity is NULL
*/
bool GEOL_Container::addEntity(GEOL_Entity *theNewEntity) {
	if (!theNewEntity)
		return false;
	if (isContained(theNewEntity))
		return false;
	
	pEntityList.push_back(theNewEntity);
	((GEOL_Object*)theNewEntity) -> incRefCount();
	return true;
}
Exemple #11
0
static boolean haveContaining(struct psl *psl, struct psl *otherPsls)
/* check if psl is completely contained in an exon of any of otherPsls */
{
    struct psl *otherPsl;
    for (otherPsl = otherPsls; otherPsl != NULL; otherPsl = otherPsl->next)
    {
        if (isContained(psl, otherPsl))
            return TRUE;
    }
    return FALSE;
}
void Button::handleArmedUpdate(UpdateEventDetails* const e)
{
    if(isContained(getParentWindow()->getParentDrawingSurface()->getMousePosition()))
    {
        _ActionFireElps += e->getElapsedTime();
    }
    if(_ActionFireElps >= getActionOnMouseDownRate())
    {
        produceMousePressedActionPerformed();
        _ActionFireElps -= static_cast<Int32>(_ActionFireElps/getActionOnMouseDownRate()) * getActionOnMouseDownRate();
    }
}
Exemple #13
0
int Block::mmSetPermission(uint64_t i_va, uint64_t i_size,
                           uint64_t i_access_type)
{
    int l_rc = 0;

    // Need to align the page address and the size on a page boundary.
    uint64_t l_aligned_va = ALIGN_PAGE_DOWN(i_va);
    uint64_t l_aligned_size = ALIGN_PAGE(i_size);


    if(!isContained(l_aligned_va))
    {
        return (iv_nextBlock ?
                iv_nextBlock->mmSetPermission(i_va,i_size,i_access_type) :
                -EINVAL);
    }

    //printk("\n             aligned VA = 0x%.lX aligned size = %ld access_type = 0x%.lX\n", l_aligned_va,	l_aligned_size, i_access_type);

    // if i_size is zero we are only updating 1 page; increment the size to
    // one page.
    if (i_size == 0)
    {
        l_aligned_size+=PAGESIZE;
    }

    // loop through all the pages asked for based on passed aligned
    // Virtual address and passed in aligned size.
    for(uint64_t cur_page_addr = l_aligned_va;
        cur_page_addr < (l_aligned_va + l_aligned_size);
        cur_page_addr += PAGESIZE)
    {

        ShadowPTE* spte = getPTE(cur_page_addr);

        // if the page present need to delete the hardware
        // page table entry before we set permissions.
        if (spte->isPresent())
        {
            // delete the hardware page table entry
            PageTableManager::delEntry(cur_page_addr);
        }

        if (setPermSPTE(spte, i_access_type))
        {
            printkd("               SET PERMISSIONS.. FAILED \n");
            return -EINVAL;
        }
    }

    return l_rc;
}
/*!
Add a new container to the containers list, and increment the reference counter of the container added.
If the container is already contained or originates a cycle don't add and return false

\param theNewContainer
Container to add

\return
- true if the new container is added correctly
- false if theNewContainer is NULL
*/
bool GEOL_Container::addContainer(GEOL_Container *theNewContainer) {
	if (!theNewContainer)
		return false;
	if (isContained(theNewContainer))
		return false;
	
	pContainerList.push_back(theNewContainer);
	if (checkForContainmentCycles()) {
		pContainerList.remove(theNewContainer);
		return false;
	}
	else {
		((GEOL_Object*)theNewContainer) -> incRefCount();
	}
	
	return true;
}
Exemple #15
0
void Block::setPhysicalPage(uint64_t i_vAddr, uint64_t i_pAddr,
                              uint64_t i_access)
{
    // Check containment, call down chain if address isn't in this block.
    if (!isContained(i_vAddr))
    {
        if (iv_nextBlock)
        {
            iv_nextBlock->setPhysicalPage(i_vAddr, i_pAddr, i_access);
        }
        else
        {
            // No block owns this address.  Code bug.
            kassert(iv_nextBlock);
        }
        return;
    }

    // Create virtual to physical mapping.
    ShadowPTE* pte = getPTE(i_vAddr);
    if (i_pAddr != 0)
    {
        pte->setPageAddr(i_pAddr);
        pte->setPresent(true);

        // Modified an SPTE, clear the HPTE.
        PageTableManager::delEntry(i_vAddr);
    }
    // If the page is already present, we might be changing permissions, so
    // clear the HPTE.
    else if (pte->isPresent())
    {
        PageTableManager::delEntry(i_vAddr);
    }


    // make a call that sets the permssions on a
    // shadow page table entry
    if (setPermSPTE(pte, i_access))
    {
        kassert(false);
    }

}
void Button::handleArmedMouseReleased(MouseEventDetails* const e)
{
	if(e->getButton() == MouseEventDetails::BUTTON1)
    {
        _ArmedMouseReleasedConnection.disconnect();
        if(getEnableActionOnMouseDownTime())
        {
            _ArmedUpdateEventConnection.disconnect();
        }
        if(getParentWindow() &&
           getParentWindow()->getParentDrawingSurface())
	    {
		    Pnt2f MousePos = ViewportToDrawingSurface(e->getLocation(), getParentWindow()->getParentDrawingSurface(), e->getViewport());
            //If the Mouse is not within the button
            if(!isContained(MousePos))
            {
                _Armed = false;
            }
        }
	}
}
Exemple #17
0
bool Block::handlePageFault(task_t* i_task, uint64_t i_addr, bool i_store)
{
    // Check containment, call down chain if address isn't in this block.
    if (!isContained(i_addr))
    {
        return (iv_nextBlock ?
                    iv_nextBlock->handlePageFault(i_task, i_addr, i_store) :
                    false);
    }

    // Calculate page aligned virtual address.
    uint64_t l_addr_palign = (i_addr / PAGESIZE) * PAGESIZE;

    ShadowPTE* pte = getPTE(l_addr_palign);

    // If the page table entry has default permission settings
    if (getPermission(pte) == NO_ACCESS)
    {
      printkd("handle page fault.. Permission not set for addr =  0x%.lX\n",
              (uint64_t)l_addr_palign);
      // return false because permission have not been set.
      return false;
    }

    // Mark the page as dirty if this is a store to it.
    if (i_store)
    {
        if (pte->isWritable())
        {
            pte->setDirty(true);
        }
        else // Store to non-writable page!  This is a permission fault, so
             // return unhandled.
        {
            return false;
        }
    }

    if (!pte->isPresent())
    {
        if (this->iv_readMsgHdlr != NULL)
        {
            void* l_page = reinterpret_cast<void*>(pte->getPageAddr());
            //If the page data is zero, create the page
            if (pte->getPage() == 0)
            {
                l_page = PageManager::allocatePage();
                //Add to ShadowPTE
                pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            }


            this->iv_readMsgHdlr->sendMessage(MSG_MM_RP_READ,
                    reinterpret_cast<void*>(l_addr_palign),l_page,i_task);
            //Done(waiting for response)
            return true;
        }
        else if (pte->isAllocateFromZero())
        {
            void* l_page = PageManager::allocatePage();

            // set the permission of the physical address pte entry to
            // READ_ONLY now that we have handled the page fault and
            // have a SPTE entry for that VA.
            if (BaseSegment::mmSetPermission(reinterpret_cast<void*>(l_page),
                                             0, READ_ONLY))
            {
               // Did not set permission..
               printkd("handle page fault.. Set Permission failed for physical"
                       " addr =  0x%.lX\n", (uint64_t)l_page);
            }

            memset(l_page, '\0', PAGESIZE);

            pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            pte->setPresent(true);

        }
        else
        {
            return false;
        }
    }

    // Determine access type.
    uint64_t l_access = (iv_mappedToPhysical ? BYPASS_HRMOR : 0);
    if (pte->isExecutable())
    {
        l_access |= EXECUTABLE;
    }
    else if (pte->isWritable() && pte->isDirty())
    {
        l_access |= WRITABLE;
    }
    else
    {
        l_access |= READ_ONLY;
    }

    PageTableManager::addEntry(
            l_addr_palign,
            pte->getPage(),
            l_access);

    return true;

}
void BestOverlapGraph::scoreEdge(const OVSoverlap& olap) {

  if (isOverlapBadQuality(olap))
    return;

  //  Store edges from contained frags to help with unhappy mate
  //  splitting.
  //
  //  From Eli: These are contained, but close either way.  We're
  //  storing the non-containment edges for this fragment, plus a few
  //  containment edges that are "close" to being dovetails.  "I think
  //  there are cases when a change in the alignemtn (consensus) will
  //  change which one is contained and screw up the order, so having
  //  this 10 base fudge factor helps things work out."
  //
  if (isContained(olap.b_iid)) {
    if (((olap.dat.ovl.a_hang >= -10) && (olap.dat.ovl.b_hang <=  0)) ||
        ((olap.dat.ovl.a_hang >=   0) && (olap.dat.ovl.b_hang <= 10))) {
      BestContainment *c = &_bestC[olap.b_iid];
      if (c->olaps == NULL) {
        c->olaps    = new uint32 [c->olapsLen];
        c->olapsLen = 0;
      }
      c->olaps[c->olapsLen++] = olap.a_iid;
    }
    return;
  }

  //  Skip contained fragments.
  if (isContained(olap.a_iid) || isContained(olap.b_iid))
    return;

  //  Skip containment overlaps.  Can this happen?  Yup.  How?
  //  The overlap could be above our allowed error.
  //
  if (((olap.dat.ovl.a_hang >= 0) && (olap.dat.ovl.b_hang <= 0)) ||
      ((olap.dat.ovl.a_hang <= 0) && (olap.dat.ovl.b_hang >= 0)))
    return;

  uint64 newScr = scoreOverlap(olap);

  //  If the score is 0, the overlap doesn't pass the scoring
  //  criteria at all so don't store the overlap whether or not
  //  it's dovetailing or containment.

  if (newScr == 0)
    return;

  //  Dove tailing overlap
  bool             a3p     = AS_OVS_overlapAEndIs3prime(olap);
  BestEdgeOverlap *best    = getBestEdgeOverlap(olap.a_iid, a3p);
  uint64           score   = 0;

  // Store the overlap if:
  //   1.)  The score is better than what is already in the graph
  //   2.)  If the scores are identical, the one with the longer length
  //
  // Since the order of how the overlaps are read in from the overlap
  // store are by A's increasing uint32, by default, if the score and
  // length are the same, the uint32 of the lower value will be kept.

  if (a3p)
    score = _best3score[olap.a_iid];
  else
    score = _best5score[olap.a_iid];

  if (newScr > score) {
    best->set(olap);

    if (a3p)
      _best3score[olap.a_iid] = newScr;
    else
      _best5score[olap.a_iid] = newScr;
  }
}
void
beta::calculateBetas (parameters param)
{
  //calculating beta for order 2
  for (int i = 0; i < betas[0].size (); i++)
    {
      for (int j = 0; j < betas[0][i].size (); j++)
	{
	  if (betas[0][i][j].isConnection == false)
	    {
	      betas[0][i][j].beta = 0;
	      continue;
	    }
	  double lambdaTemp;
	  if (param.dist_flag == 0)
	    {
	      lambdaTemp = -log (1 - betas[0][i][j].prob) / param.teeUpdate;
	    }
	  else if (param.dist_flag == 1)
	    {
	      lambdaTemp = sqrt (2 * betas[0][i][j].prob) / param.teeUpdate;
	    }
	  betas[0][i][j].beta =
	    -param.theta - log (param.lambdaM / lambdaTemp - 1);
	}
    }
  //calculating beta for order 3
  for (int i = 0; maxOrder >= 3 && i < betas[1].size (); i++)
    {
      for (int j = 0; j < betas[1][i].size (); j++)
	{
	  if (betas[1][i][j].isConnection == false)
	    {
	      betas[1][i][j].beta = 0;
	      continue;
	    }
	  double lambdaTemp;
	  if (param.dist_flag == 0)
	    {
	      lambdaTemp = -log (1 - betas[1][i][j].prob) / param.teeUpdate;
	    }
	  else if (param.dist_flag == 1)
	    {
	      lambdaTemp = sqrt (2 * betas[1][i][j].prob) / param.teeUpdate;
	    }
	  //lambdaTemp = - log(1 - betas[1][i][j].prob) / param.teeUpdate;
	  double sigmaBetaSub = 0.0;
	  for (int k = 0; k < betas[1][i][j].parents.size (); k++)
	    {
	      int parent = betas[1][i][j].parents[k];
	      if (betas[0][i][parent - 1].delays[0] ==
		  betas[1][i][j].delays[k])
		sigmaBetaSub = sigmaBetaSub + betas[0][i][parent - 1].beta;
	    }
	  betas[1][i][j].beta =
	    -param.theta - sigmaBetaSub - log (param.lambdaM / lambdaTemp -
					       1);
	}
    }
#if 1
  //calculating beta for order 4 and above
  for (int k = 2; k < maxOrder - 1; k++)
    {
      for (int i = 0; i < betas[k].size (); i++)
	{
	  for (int j = 0; j < betas[k][i].size (); j++)
	    {
	      double lambdaTemp;
	      if (param.dist_flag == 0)
		{
		  lambdaTemp =
		    -log (1 - betas[k][i][j].prob) / param.teeUpdate;
		}
	      else if (param.dist_flag == 1)
		{
		  lambdaTemp =
		    sqrt (2 * betas[k][i][j].prob) / param.teeUpdate;
		}
	      //lambdaTemp = - log(1 - betas[k][i][j].prob) / param.teeUpdate;
	      double sigmaBetaSub = 0;
	      for (int m = 0; m < betas[k][i][j].parents.size (); m++)
		{
		  int parent = betas[k][i][j].parents[m];
		  if (betas[k][i][j].delays[m] ==
		      betas[0][i][parent - 1].delays[0])
		    sigmaBetaSub =
		      sigmaBetaSub + betas[0][i][parent - 1].beta;
		}
	      for (int low = 1; low < k; low++)
		{
		  for (int m = 0; m < betas[low][i].size (); m++)
		    {
		      if (isContained (betas[low][i][m], betas[k][i][j]))
			sigmaBetaSub = sigmaBetaSub + betas[low][i][m].beta;
		    }
		}
	      betas[k][i][j].beta =
		-param.theta - sigmaBetaSub -
		log (param.lambdaM / lambdaTemp - 1);
	    }
	}
    }
#endif

}