Ejemplo n.º 1
0
void BufferedStreamingGrid::reset	(bool read,int minWindowSize)
{
	this->read=read;
	win=minWindowSize<rows() ? minWindowSize : rows();

	FreePointer( data );
	data = AllocPointer< byte >( rowSize() * win );
	if( !data ) fprintf( stderr , "[ERROR] Failed to allocate memory for BufferedStreamingGrid\n" ) , exit( 0 );
	sg->reset( read , 1 );
	if( read )
	{
		for(int w=0;w<win;w++)
		{
			Pointer( byte ) row = (*sg)[w];
			memcpy( data+w*rowSize() , row , rowSize() );
			sg->advance();
		}
	}
	current=0;
}
Ejemplo n.º 2
0
UpperMatrix<T>::UpperMatrix(const ParamMatrix<T>& matrix)
{
  int index = 0;
  int rowNum = 0;

  m_rowSize = matrix.rowSize();
  m_numRows = matrix.numRows();
  m_dataPtr = new T[m_numRows*(m_numRows+1)/2];

  for(int i = 0; i < theoSize(); i++)
  {
    if(i%rowSize() >= rowNum)
    {
      m_dataPtr[index] = matrix[i];
      index++;
    }

    if(i%rowSize() == rowSize()-1)
      rowNum++;
  }
}
Ejemplo n.º 3
0
void BufferedStreamingGrid::advance(void)
{
	if(read)
	{
		current++;
		if(current+win-1<rows())
		{
			sg->advance();
			memcpy( data + ((current+win-1)%win)*rowSize() , (*sg)[current+win-1] , rowSize() );
		}
	}
	else
	{
		if(current-win+1>=0)
		{
			memcpy( (*sg)[current-win+1] , data+((current-win+1)%win)*rowSize() , rowSize() );
			sg->advance();
		}
		current++;
	}
}
Ejemplo n.º 4
0
Pointer( byte ) BufferedStreamingGrid::operator[]	(int idx)
{
	return data+(idx%win)*rowSize();
}