Esempio n. 1
0
File: Vector.cpp Progetto: c4tnt/DLR
/*
=============
idVecX::ToString
=============
*/
const char *idVecX::ToString( int precision ) const {
	return idStr::FloatArrayToString( ToFloatPtr(), GetDimension(), precision );
}
Esempio n. 2
0
wxSizer*  wxSizerXmlHandler::Handle_wxGridSizer()
{
    return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
                           GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
}
Esempio n. 3
0
wxGridBagSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
{
    if ( !ValidateGridSizerChildren() )
        return NULL;
    return new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
}
Esempio n. 4
0
void DisassemblyView::paintSelection(QPainter& p)
{
  if (m_SelectionBegin == m_SelectionEnd)
    return;

  medusa::UserConfiguration UserCfg;
  QColor slctColor = QColor(QString::fromStdString(UserCfg.GetOption("color.selection")));

  medusa::u32 xSelectBeg, ySelectBeg, xSelectEnd, ySelectEnd;

  if (!_ConvertAddressOffsetToViewOffset(m_SelectionBegin, xSelectBeg, ySelectBeg))
  {
    xSelectBeg = _addrLen;
    ySelectBeg = 0;
  }

  if (static_cast<int>(xSelectBeg) < _addrLen)
    xSelectBeg = _addrLen;

  if (!_ConvertAddressOffsetToViewOffset(m_SelectionEnd, xSelectEnd, ySelectEnd))
    GetDimension(xSelectEnd, ySelectEnd);

  if (static_cast<int>(xSelectEnd) < _addrLen)
    xSelectEnd = _addrLen;

  int begSelect    = ySelectBeg;
  int endSelect    = ySelectEnd;
  int begSelectOff = xSelectBeg;
  int endSelectOff = xSelectEnd;
  int deltaSelect  = endSelect    - begSelect;
  int deltaOffset  = endSelectOff - begSelectOff;

  if (deltaSelect == 0 && deltaOffset == 0)
    return;

  // If the user select from the bottom to the top, we have to swap up and down
  if (deltaSelect < 0)
  {
    deltaSelect  = -deltaSelect;
    std::swap(begSelect, endSelect);
    std::swap(begSelectOff, endSelectOff);
  }

  if (deltaSelect)
    deltaSelect++;

  if (deltaSelect == 0)
  {
    if (deltaOffset < 0)
    {
      deltaOffset = -deltaOffset;
      std::swap(begSelectOff, endSelectOff);
    }
    int x = (begSelectOff - horizontalScrollBar()->value()) * _wChar;
    int y = (begSelect - verticalScrollBar()->value()) * _hChar;
    int w = deltaOffset * _wChar;
    int h = _hChar;
    QRect slctRect(x, y, w, h);
    p.fillRect(slctRect, slctColor);
  }

  // Draw selection background
  // This part is pretty tricky:
  // To draw the selection we use the lazy method by three passes.
  /*
     +-----------------+
     |     ############+ Part¹
     |#################+ Part²
     |#################+ Part²
     |####             | Part³
     +-----------------+
  */
  else if (deltaSelect > 0)
  {
    // Part¹
    int x = (begSelectOff - horizontalScrollBar()->value()) * _wChar;
    int y = (begSelect - verticalScrollBar()->value()) * _hChar;
    int w = (viewport()->width() - _addrLen) * _wChar;
    int h = _hChar;
    QRect slctRect(x, y, w, h);
    p.fillRect(slctRect, slctColor);

    // Part²
    if (deltaSelect > 2)
    {
      x = (_addrLen - horizontalScrollBar()->value()) * _wChar;
      y = slctRect.bottom();
      w = (viewport()->width() - _addrLen) * _wChar;
      h = (deltaSelect - 2) * _hChar;
      slctRect.setRect(x, y, w, h);
      p.fillRect(slctRect, slctColor);
    }

    // Part³
    x = (_addrLen - horizontalScrollBar()->value()) * _wChar;
    y = slctRect.bottom();
    w = (endSelectOff - _addrLen) * _wChar;
    h = _hChar;
    slctRect.setRect(x, y, w, h);
    p.fillRect(slctRect, slctColor);
  }
}
Esempio n. 5
0
bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
{
	int BlockX = m_CenterX + static_cast<int>((a_X - m_Width  / 2) * GetPixelWidth());
	int BlockZ = m_CenterZ + static_cast<int>((a_Z - m_Height / 2) * GetPixelWidth());

	int ChunkX, ChunkZ;
	cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);

	int RelX = BlockX - (ChunkX * cChunkDef::Width);
	int RelZ = BlockZ - (ChunkZ * cChunkDef::Width);

	ASSERT(m_World != nullptr);

	ColorID PixelData;
	m_World->DoWithChunk(ChunkX, ChunkZ, [&](cChunk & a_Chunk)
		{
			if (!a_Chunk.IsValid())
			{
				return false;
			}

			if (GetDimension() == dimNether)
			{
				// TODO 2014-02-22 xdot: Nether maps

				return false;
			}

			static const std::array<unsigned char, 4> BrightnessID = { { 3, 0, 1, 2 } };  // Darkest to lightest
			BLOCKTYPE TargetBlock;
			NIBBLETYPE TargetMeta;

			auto Height = a_Chunk.GetHeight(RelX, RelZ);
			auto ChunkHeight = cChunkDef::Height;
			a_Chunk.GetBlockTypeMeta(RelX, Height, RelZ, TargetBlock, TargetMeta);
			auto ColourID = BlockHandler(TargetBlock)->GetMapBaseColourID(TargetMeta);

			if (IsBlockWater(TargetBlock))
			{
				ChunkHeight /= 4;
				while (((--Height) != -1) && IsBlockWater(a_Chunk.GetBlock(RelX, Height, RelZ)))
				{
					continue;
				}
			}
			else if (ColourID == 0)
			{
				while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk.GetBlock(RelX, Height, RelZ))->GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
				{
					continue;
				}
			}

			// Multiply base color ID by 4 and add brightness ID
			const int BrightnessIDSize = static_cast<int>(BrightnessID.size());
			PixelData = ColourID * 4 + BrightnessID[static_cast<size_t>(Clamp<int>((BrightnessIDSize * Height) / ChunkHeight, 0, BrightnessIDSize - 1))];
			return false;
		}
	);

	SetPixel(a_X, a_Z, PixelData);

	return true;
}
Esempio n. 6
0
/** Returns the alignment */
GraphAlignedSegment* Graph::RetrieveAlignment()
{	
	GraphAlignedSegment* outAlign = new GraphAlignedSegment(m_IndexRef);
	size_t* curCoordinate = NULL;
	size_t* bestprevCoordinate = NULL;
	size_t* coordinate = NULL;
	
	int prevbestcost = -1, currcost;
	GraphCoordinateList listPrevCoordinates(GetDimension());
	size_t it;
	
	StartingCoordinates(listPrevCoordinates);
		
	GraphCoordinateListPosition i = listPrevCoordinates.GetBeginPosition();
	GraphCoordinateListPosition ei = listPrevCoordinates.GetEndPosition();
	
	while(i != ei)
	{
		if(coordinate && (bestprevCoordinate != coordinate) && (curCoordinate != coordinate))
			delete [] coordinate;
		
		coordinate = listPrevCoordinates.GetAt(i);
		currcost = m_MapCost->GetCostFor(coordinate);
		
		if(prevbestcost == -1)
		{
			prevbestcost = currcost;
			curCoordinate = coordinate;
		}
		else if(currcost < prevbestcost)
		{
            prevbestcost = currcost;
            curCoordinate = coordinate;
		}
			
		listPrevCoordinates.NextPosition(i);
	}
	
	while((bestprevCoordinate = GetBestCoordinateAndCost(curCoordinate)) != NULL)
	{
		GraphAlignedToken* aGraphAlignedToken = new GraphAlignedToken(GetDimension());
		Token* token;
		
		for(it=0; it<GetDimension(); ++it)
		{
			token = NULL;
			
			if(curCoordinate[it] != bestprevCoordinate[it])
			{
				token = m_TabVecHypRef[it][curCoordinate[it]];
			}

			aGraphAlignedToken->SetToken(it, token);
		}
		
		outAlign->AddFrontGraphAlignedToken(aGraphAlignedToken);
		
		//cerr << aGraphAlignedToken->ToString();
		
		for(it=0; it<GetDimension(); ++it)
		{
			curCoordinate[it] = bestprevCoordinate[it];
		}
		
		delete [] bestprevCoordinate;
	}
	
	// Start cleaning memory
	listPrevCoordinates.RemoveAll();
	
	if(coordinate)
		delete [] coordinate;
	
	if(curCoordinate && (curCoordinate != bestprevCoordinate) && (curCoordinate != coordinate))
		delete [] curCoordinate;
	// End cleaning memory
	
	return outAlign;
}
Esempio n. 7
0
/** Returns the best previous coordinate */
size_t* Graph::GetBestCoordinateAndCost(size_t* coordcurr)
{
	if(isEndingCoordinate(coordcurr))
		return NULL;
	
	GraphCoordinateList listPrevCoordinates(GetDimension());
	size_t* bestprev = NULL;
	int curcost;
	
	PreviousCoordinates(listPrevCoordinates, coordcurr);
	GraphCoordinateListPosition i = listPrevCoordinates.GetBeginPosition();
	GraphCoordinateListPosition ei = listPrevCoordinates.GetEndPosition();
	int prevbestcost = -1;
	size_t bestnumchg = 0;
	bool isCorrectSubs = false;
	
	while(i != ei)
	{
		size_t* coordinate = listPrevCoordinates.GetAt(i);
		curcost = m_MapCost->GetCostFor(coordinate) + GetTransitionCost(coordcurr, coordinate);

		if(prevbestcost == -1)
		{
			prevbestcost = curcost;
			
			if(bestprev)
				delete [] bestprev;
			
			bestprev = coordinate;
			
			bool bToken1 = false;
			bool bToken2 = false;
			size_t c=0;
			
			while( (c != GetDimension()) && !bToken2)
			{
				if(coordcurr[c] != coordinate[c])
				{
					if(!bToken1)
						bToken1 = true;
					else
						bToken2 = true;
				}
				
				++c;
			}
			
			isCorrectSubs = bToken2;
		}
		else
		{
			if(curcost < prevbestcost)
			{
				prevbestcost = curcost;
				
				if(bestprev)
					delete [] bestprev;
				
				bestprev = coordinate;
				
				bool bToken1 = false;
				bool bToken2 = false;
				size_t c=0;
				
				while( (c != GetDimension()) && !bToken2)
				{
					if(coordcurr[c] != /*prevcurr*/coordinate[c])
					{
						if(!bToken1)
							bToken1 = true;
						else
							bToken2 = true;
					}
					
					++c;
				}
				
				isCorrectSubs = bToken2;
			}
			else if( (m_HypRefStatus == 1) && (curcost == prevbestcost) && !isCorrectSubs)
			{
				bool bToken1 = false;
				bool bToken2 = false;
				size_t c=0;
				
				while( (c != GetDimension()) && !bToken2)
				{
					if(coordcurr[c] != coordinate[c])
					{
						if(!bToken1)
							bToken1 = true;
						else
							bToken2 = true;
					}
					
					++c;
				}
				
				if(bToken2)
				{
					prevbestcost = curcost;
					
					if(bestprev)
						delete [] bestprev;
					
					bestprev = coordinate;
					isCorrectSubs = bToken2;
				}
			}
			else if( (curcost == prevbestcost) && (m_HypRefStatus != 1) )
			{
				size_t numchg = NumberChanged(coordcurr, coordinate);
				
				if(numchg > bestnumchg)
				{
					prevbestcost = curcost;
					
					if(bestprev)
						delete [] bestprev;
					
					bestprev = coordinate;
					bestnumchg = numchg;
				}	
			}
		}
		
		listPrevCoordinates.NextPosition(i);
		
		if(coordinate && (bestprev != coordinate))
			delete [] coordinate;
	}
	
	// Start cleaning memory
	listPrevCoordinates.RemoveAll();

	// End cleaning memory
	
	return bestprev;
}
Esempio n. 8
0
/** List the previous coordinates */
void Graph::PreviousCoordinatesHypRef(GraphCoordinateList& listPrev, size_t* coord)
{
	listPrev.RemoveAll();
	
	if(isEndingCoordinate(coord))
		return;
	
	list<size_t>* tabPreviousIndexes = new list<size_t>[GetDimension()];
	list<size_t>::iterator l, le, m, me;
	size_t* prevcoordr = new size_t[GetDimension()];
	size_t* prevcoordh = new size_t[GetDimension()];
		
	for(size_t i=0; i<GetDimension(); ++i)
		if(coord[i]) // != 0
			PreviousIndexes(tabPreviousIndexes[i], i, coord[i]);
		
	// Change only one coordinate into the Refs and both
	for(size_t i=m_IndexRef; i<GetDimension(); ++i)
	{
		if(coord[i]) // != 0
		{
			l = tabPreviousIndexes[i].begin();
			le = tabPreviousIndexes[i].end();
			
			while(l != le)
			{
				for(size_t j=0; j<GetDimension(); ++j)
					prevcoordr[j] = coord[j];
				
				prevcoordr[i] = *l;
				
				if(ValidateTransitionInsertionDeletion(coord, prevcoordr))
					listPrev.AddFront(prevcoordr);
				
				for(size_t j=0; j<m_IndexRef; ++j)
				{
					if(coord[j]) // != 0
					{
						m = tabPreviousIndexes[j].begin();
						me = tabPreviousIndexes[j].end();
						
						while(m != me)
						{
							for(size_t k=0; k<GetDimension(); ++k)
								prevcoordh[k] = prevcoordr[k];
							
							prevcoordh[j] = *m;
							
							if(ValidateTransitionInsertionDeletion(coord, prevcoordh))
								listPrev.AddFront(prevcoordh);
							
							++m;
						}
					}
				}
				
				++l;
			}
		}
	}
	
	// Change only one coordinate into the Hyps
	for(size_t i=0; i<m_IndexRef; ++i)
	{
		if(coord[i]) // != 0
		{
			l = tabPreviousIndexes[i].begin();
			le = tabPreviousIndexes[i].end();
			
			while(l != le)
			{
				for(size_t j=0; j<GetDimension(); ++j)
					prevcoordr[j] = coord[j];
				
				prevcoordr[i] = *l;
				
				if(ValidateTransitionInsertionDeletion(coord, prevcoordr))
					listPrev.AddFront(prevcoordr);
				
				++l;
			}
			
			tabPreviousIndexes[i].clear();
		}
	}

	// Start cleaning memory
	for(size_t i=0; i<GetDimension(); ++i)
		if(coord[i]) // != 0
			tabPreviousIndexes[i].clear();
	
	delete [] prevcoordr;
	delete [] prevcoordh;
	delete [] tabPreviousIndexes;
	// End cleaning memory
}
Esempio n. 9
0
/** List the previous coordinates generic way to compute */
void Graph::PreviousCoordinatesGeneric(GraphCoordinateList& listPrev, size_t* coord)
{
	listPrev.RemoveAll();
	
	if(isEndingCoordinate(coord))
		return;
		
	size_t i, j;
	list<size_t>* tabPreviousIndexes = new list<size_t>[GetDimension()];
	list<size_t>::iterator* tabInteratorListBegin = new list<size_t>::iterator[GetDimension()];
	list<size_t>::iterator* tabInteratorListEnd = new list<size_t>::iterator[GetDimension()];
	list<size_t>::iterator* tabInteratorListCurrent = new list<size_t>::iterator[GetDimension()];
	
	
	for(i=0; i<GetDimension(); ++i)
	{
		PreviousIndexes(tabPreviousIndexes[i], i, coord[i]);
		tabPreviousIndexes[i].push_front(coord[i]);
		tabPreviousIndexes[i].unique();
	}
		
	for(i=0; i<GetDimension(); ++i)
	{
		tabInteratorListBegin[i] = tabPreviousIndexes[i].begin();
		tabInteratorListEnd[i] = tabPreviousIndexes[i].end();
		tabInteratorListCurrent[i] = tabPreviousIndexes[i].begin();
	}
		
	while(tabInteratorListCurrent[GetDimension()-1] != tabInteratorListEnd[GetDimension()-1])
	{
		j = 0;
		bool loopout = false;
		
		while(!loopout)
		{
			++(tabInteratorListCurrent[j]);
			
			if(tabInteratorListCurrent[j] == tabInteratorListEnd[j])
			{
				++j;
			}
			else
				loopout = true;
				
			if(j == GetDimension())
				loopout = true;
		}
				
		if(tabInteratorListCurrent[GetDimension()-1] != tabInteratorListEnd[GetDimension()-1])
		{
			size_t* startcoord = new size_t[GetDimension()];
			bool addit = true;
			
			for(i=0; i<GetDimension(); ++i)
			{
				if(tabInteratorListCurrent[i] != tabInteratorListEnd[i])
					startcoord[i] = *(tabInteratorListCurrent[i]);
				else
					addit = false;
			}
			
			if(addit)
			{
				if(/*ValidateTransitionInsertionDeletion(coord, startcoord)*/true)
					listPrev.AddFront(startcoord);
			}
			else
				delete [] startcoord;
		}
	}
	
	for(i=0; i<GetDimension(); ++i)
		tabPreviousIndexes[i].clear();
	
	delete [] tabPreviousIndexes;
	delete [] tabInteratorListBegin;
	delete [] tabInteratorListEnd;
	delete [] tabInteratorListCurrent;
}
Esempio n. 10
0
/** Constructor with the list of segments and the position of the first ref */
Graph::Graph(SegmentsGroup* _segmentsGroup, SpeakerMatch* _pSpeakerMatch, const int& _typeCost, const int& _costTrans, const int& _costIns, const int& _costOpt, const int& _costCorrectNonSpeaker, const int& _costAdaptive, const bool& _optRef, const bool& _optHyp, const bool& _bCompressedArray)
	: m_pSpeakerMatch(_pSpeakerMatch),
	m_typeCostModel(_typeCost),
	m_CostTransition(_costTrans),
	m_CostInsertion(_costIns),
	m_CostOptionally(_costOpt),
	m_CostCorrectNonSpeaker(_costCorrectNonSpeaker),
	m_CostAdaptive(_costAdaptive),
	m_useOptForRef(_optRef),
	m_useOptForHyp(_optHyp),
	m_bCompressedArray(_bCompressedArray)	
{
	m_HypRefStatus = (string("true").compare(Properties::GetProperty("align.genericmethod")) != 0);
	
//	m_NbThreads = static_cast<size_t>(atoi(Properties::GetProperty("threads.number").c_str()));
	
	if(m_typeCostModel == 2)
	{
		// Calculate the safe divider
		m_TimeBasedSafeDivider = min(min(min(m_CostTransition, m_CostInsertion), m_CostOptionally), m_CostCorrectNonSpeaker);
	}
	
	Token* curToken;
	size_t i, k, sizevector;
	
	SetDimension(_segmentsGroup->GetNumberOfReferences()+_segmentsGroup->GetNumberOfHypothesis());
	
	if(m_HypRefStatus)
		SetIndexRef(_segmentsGroup->GetNumberOfHypothesis());
	else
		SetIndexRef(0);
	
	m_TabDimensionDeep = new size_t[GetDimension()];
	m_TabVecHypRef = new vector<Token*>[GetDimension()];
	m_TabMapTokenIndex = new map<Token*, size_t>[GetDimension()];
	m_TabFirstTokens = new list<Token*>[GetDimension()];
	m_TabLastTokens = new list<Token*>[GetDimension()];
	   
	int minTimeSafeDividerToken = -1;
	
	// Planning each Segment and look for the last and first token
	for(i=0; i<GetDimension(); ++i)
	{
        vector<Segment*> temp_segs;
		
        if (i < _segmentsGroup->GetNumberOfHypothesis())
        {
            m_TabVecHypRef[i] = _segmentsGroup->ToTopologicalOrderedStructHyp(i);
            temp_segs = _segmentsGroup->GetHypothesis(i);
        }
        else
        {
            m_TabVecHypRef[i] = _segmentsGroup->ToTopologicalOrderedStructRef(i-_segmentsGroup->GetNumberOfHypothesis());
            temp_segs = _segmentsGroup->GetReference(i-_segmentsGroup->GetNumberOfHypothesis());
        }
		
		sizevector = m_TabVecHypRef[i].size();
		        				
		SetDimensionDeep(i, sizevector);
		
		for(k=0; k<sizevector; ++k)
		{
			curToken = m_TabVecHypRef[i][k];
			
			if(curToken != NULL)
			{
				if(m_typeCostModel == 2)
				{
					int TimeSafeDividerToken = curToken->TimeSafeDivider();
				
					if( (minTimeSafeDividerToken == -1) || (TimeSafeDividerToken < minTimeSafeDividerToken) )
						minTimeSafeDividerToken = TimeSafeDividerToken;
				}
				
				m_TabMapTokenIndex[i][curToken] = k;
				size_t prcs = 0;
				
				while( (prcs < (temp_segs.size()-1)) && (temp_segs[prcs]->isEmpty()) )
					++prcs;
				
				if(temp_segs[prcs]->isFirstToken(curToken))
                    m_TabFirstTokens[i].push_front(curToken);
				
				prcs = temp_segs.size()-1;
				
				while( (prcs > 0) && (temp_segs[prcs]->isEmpty()) )
					--prcs;
				
				if(temp_segs[prcs]->isLastToken(curToken))
                    m_TabLastTokens[i].push_front(curToken);
			}
		}
	}
	
	SetGraphOptimization();
	m_MaxDurationSegmentGroup = _segmentsGroup->GetTotalDuration();
	
	if(m_bCompressedArray)
	{
		LOG_DEBUG(logger, "Lenvenshtein Matrix Compression: ON");
		m_MapCost = new CompressedLevenshteinMatrix(GetDimension(), m_TabDimensionDeep);
	}
	else
	{
		LOG_DEBUG(logger, "Lenvenshtein Matrix Compression: OFF");
		m_MapCost = new ArrayLevenshteinMatrix(GetDimension(), m_TabDimensionDeep);
	}
	    
    // Creating cache container
    m_TabCacheDimPreviousIndex = new list<size_t>** [GetDimension()];
    
    for(i=0; i<GetDimension(); ++i)
    {
        m_TabCacheDimPreviousIndex[i] = new list<size_t>* [m_TabDimensionDeep[i]];
        
        for(k=0; k<m_TabDimensionDeep[i]; ++k)
            m_TabCacheDimPreviousIndex[i][k] = NULL;
    }
    
    if(m_typeCostModel == 2)
	{
		m_TimeBasedSafeDivider *= minTimeSafeDividerToken;
		char buffer [BUFFER_SIZE];
        sprintf(buffer, "Use Safe divider (%d)!", m_TimeBasedSafeDivider);
		LOG_DEBUG(logger, buffer);
	}
}
Esempio n. 11
0
/** Create the list of starting coordinates */
void Graph::StartingCoordinates(GraphCoordinateList& listStart)
{
	list<Token*>::iterator* tabInteratorListBegin = new list<Token*>::iterator[GetDimension()];
	list<Token*>::iterator* tabInteratorListEnd = new list<Token*>::iterator[GetDimension()];
	list<Token*>::iterator* tabInteratorListCurrent = new list<Token*>::iterator[GetDimension()];
	size_t curdim;
	bool inccurdim;
	size_t* startcoord = new size_t[GetDimension()];
	
	listStart.RemoveAll();
	
	for(size_t i=0; i<GetDimension(); ++i)
	{
		if(!isHypRefEmpty(i))
		{
			tabInteratorListBegin[i] = m_TabLastTokens[i].begin();
			tabInteratorListCurrent[i] = m_TabLastTokens[i].begin();
			tabInteratorListEnd[i] = m_TabLastTokens[i].end();
		}
	}
	
	do
	{
		for(size_t i=0; i<GetDimension(); ++i)
		{
			if(!isHypRefEmpty(i))
				startcoord[i] = m_TabMapTokenIndex[i][*(tabInteratorListCurrent[i])];
			else
				startcoord[i] = 0;
		}

		listStart.AddFront(startcoord);
	
		curdim = 0;
		
		do
		{
			if(!isHypRefEmpty(curdim))
			{
				++(tabInteratorListCurrent[curdim]);
				inccurdim = (tabInteratorListCurrent[curdim] == tabInteratorListEnd[curdim]);
			}
			else
			{
				inccurdim = true;
			}
			
			if(inccurdim)
			{
				tabInteratorListCurrent[curdim] = tabInteratorListBegin[curdim];
				++curdim;
				
				if(curdim == GetDimension())
					inccurdim = false;
			}
		}
		while(inccurdim);
	}
	while( curdim != GetDimension() );
		
	// Start cleaning memory
	delete [] tabInteratorListBegin;
	delete [] tabInteratorListEnd;
	delete [] tabInteratorListCurrent;
	delete [] startcoord;
	// End cleaning memory
}
Esempio n. 12
0
bool Graph::ValidateTransitionInsertionDeletion(size_t* coordcurr, size_t* coordprev)
{
	if(!m_bPruneOptimization && !m_bWordOptimization)
		return true;
	
	Token* pToken;
	size_t nrbchanged = NumberChanged(coordcurr, coordprev);
		
	if( (nrbchanged == 1) && m_bPruneOptimization )// Insertion or Deletion
	{
		size_t chgdim = 0;
		
		while( (chgdim<GetDimension()) && (coordcurr[chgdim] == coordprev[chgdim]) )
			++chgdim;
				
		pToken = m_TabVecHypRef[chgdim][coordcurr[chgdim]];
		
		int currentchgbegin;
		int currentchgend;
		
		if(pToken)
		{
			currentchgbegin = pToken->GetStartTime();
			
			if(currentchgbegin < 0)
			{
				currentchgbegin = pToken->GetParentSegment()->GetStartTime();
				
				if(currentchgbegin < 0)
					return true;
			}
			else
				return true;
				
			currentchgend = pToken->GetEndTime();
			
			if(currentchgend < 0)
			{
				currentchgend = pToken->GetParentSegment()->GetEndTime();
				
				if(currentchgend < 0)
					return true;
			}
			else
				return true;
		}
		else
			return true;

		int currentstaybegin;
		int currentstayend;
		
		for(size_t i=0; i<GetDimension(); ++i)
		{
			if(i != chgdim)
			{
				pToken = m_TabVecHypRef[i][coordcurr[i]];
				
				if(pToken)
				{
					currentstaybegin = pToken->GetStartTime();
					
					if(currentstaybegin < 0)
					{
						currentstaybegin = pToken->GetParentSegment()->GetStartTime();
						
						if(currentstaybegin < 0)
							return true;
					}
					
					currentstayend = pToken->GetEndTime();
					
					if(currentstayend < 0)
					{
						currentstayend = pToken->GetParentSegment()->GetEndTime();
						
						if(currentstayend < 0)
							return true;
					}
				}
				else
					return true;
				
				if(currentchgbegin < currentstaybegin)
				{
					int gap = 0;
			
					if(currentchgend < currentstaybegin)      // Change before Stay
					{
						gap = currentstaybegin - currentchgend;
					}
					else if(currentstayend < currentchgbegin) // Stay before Change
					{
						gap = currentchgbegin - currentstayend;
					}
					
					if(gap > m_PruneOptimizationThreshold)
						return false;
				}
			}
		}
		
		return true;
	}
	else if( (nrbchanged == 2) && m_bWordOptimization )//Subsitution or Correct
	{
		size_t coord1 = 0;
		size_t coord2 = 0;
		bool bcoord1 = false;
			
		for(size_t i=0; i<GetDimension(); ++i)
		{
			if(coordcurr[i] != coordprev[i])
			{
				if(!bcoord1)
				{
					bcoord1 = true;
					coord1 = i;
				}
				else
					coord2 = i;
			}
		}
		
		int start1 = m_TabVecHypRef[coord1][coordcurr[coord1]]->GetStartTime();
		
		if(start1 < 0)
			start1 = m_TabVecHypRef[coord1][coordcurr[coord1]]->GetParentSegment()->GetStartTime();
		
		int start2 = m_TabVecHypRef[coord2][coordcurr[coord2]]->GetStartTime();
		
		if(start2 < 0)
			start2 = m_TabVecHypRef[coord2][coordcurr[coord2]]->GetParentSegment()->GetStartTime();
		
		int end1 = m_TabVecHypRef[coord1][coordcurr[coord1]]->GetEndTime();
		
		if(end1 < 0)
			end1 = m_TabVecHypRef[coord1][coordcurr[coord1]]->GetParentSegment()->GetEndTime();
		
		int end2 = m_TabVecHypRef[coord2][coordcurr[coord2]]->GetEndTime();
		
		if(end2 < 0)
			end2 = m_TabVecHypRef[coord2][coordcurr[coord2]]->GetParentSegment()->GetEndTime();
			
		if( (start1 < 0) || (start2 < 0) || (end1 < 0) || (end2 < 0) )
			return true;
		
		int gap;
		
		if(end1 < start2)      // 1 before 2
		{
			gap = start2 - end1;
		}
		else if(end2 < start1) // 2 before 1
		{
			gap = start1 - end2;
		}
		else
		{
			gap = 0;
		}
		
		return(gap <= m_WordOptimizationThreshold);
	}
	
	return true;
}
Esempio n. 13
0
/*
=============
Vec4D::ToChars
=============
*/
const char *Vec4D::ToChars( int precision ) const {
	return String::FloatArrayToString( ToFloatPtr(), GetDimension(), precision );
}
Esempio n. 14
0
/*----------------------------------------------------------------------------------------------------------------------
|	Operator that allows access to this SquareMatrix object as if it were a two-dimensional array of doubles.
*/
double * SquareMatrix::operator[](
  unsigned i) const
	{
	PHYCAS_ASSERT(i < GetDimension());
	return m[i];
	}