Ejemplo n.º 1
0
/**
 * Replans the path.
 *
 * @return  bool   solution found
 */
bool Planner::replan()
{
	_path.clear();
	
	bool result = _compute();
	
	// Couldn't find a solution
	if ( ! result)
	  return false;

	Map::Cell* current = _start;
	_path.push_back(current);

	// Follow the path with the least cost until goal is reached
	while (current != _goal)
	{
		if (current == NULL || _g(current) == Math::INF)
			return false;

		current = _min_succ(current).first;

		_path.push_back(current);
	}

	return true;
}
Ejemplo n.º 2
0
    void compute() final {
        if (is_computed)
            return;

        timer.tic();
        _compute(_result);
        timer.toc();
        is_computed = true;
    }
Ejemplo n.º 3
0
wstring Sha1Sum::ComputeforFile()
{
	_compute();
	g_log.Log(L"Sha1Sum::ComputeforFile for %s returns %s", (wchar_t *) m_file.c_str(), (wchar_t *) m_sum.c_str());
	return m_sum;
}
Ejemplo n.º 4
0
void strsm_llnu_lu( unsigned int SPE_id, LS_ShaderInfo *info, Operation_t *myop, Functions_t *funcs )
{
	_DBGP_UINT( 1 );

	// Make room for python meta data
	PyArrayObject *A     = (PyArrayObject *)info->LS_shaderMemory;
	PyArrayObject *B     = (PyArrayObject *)info->LS_shaderMemory+sizeof( PyArrayObject );
	PyArrayObject *alpha = (PyArrayObject *)info->LS_shaderMemory+sizeof( PyArrayObject )*2;
	PyArrayObject *cb    = (PyArrayObject *)info->LS_shaderMemory+sizeof( PyArrayObject )*3;

	// Get meta data
	_GetPyArrayMetaData( myop->obj[0], A, 0 );
	_GetPyArrayMetaData( myop->obj[1], B, 0 );
	_GetPyArrayMetaData( myop->scalar[0], alpha, 0 );
	_GetPyArrayMetaData( myop->scalar[1], cb, 0 );
	_Wait(0); // WAIT!!!

	_DBGP_UINT( 2 );

	// Make room for data block arrays
	char **blocks_A     = (char**)( ( (unsigned int)( cb + sizeof( PyArrayObject )) + 127 ) &~ 127 );
	char **blocks_B     = (char**)( blocks_A     + _Pad16bytes( A->numberOfBlocks ) );
	char **blocks_alpha = (char**)( blocks_B     + _Pad16bytes( B->numberOfBlocks ) );
	char **blocks_cb    = (char**)( blocks_alpha + _Pad16bytes( alpha->numberOfBlocks ) );

	// Local vars
	unsigned int idx = 0, nextidx;
	unsigned int i, j, k, l, row, col;

//	unsigned int c = 0;
//
//	unsigned int Afourth  = A->blockSize / 4;
//	unsigned int xfourth  = x->blockSize / 4;
//	unsigned int AAfourth = A->blockSize*A->blockSize / 4;
//	unsigned int t = 0;

	// Uploadet scalars
	float alpha_f, beta_f;
	unsigned int CB;
	_GetScalar( alpha, blocks_alpha, &alpha_f, 1 );
	_GetScalar( cb, blocks_cb, &CB, 1 );

	_DBGP_UINT( 3 );

	vector float alphav = spu_splats(alpha_f);

	// Fetch pointers to first __ datablocks for vectors
	_GetBlockPointers( B, blocks_B, B->numberOfBlocks, _BTAG );
	_GetBlockPointers( A, blocks_A, A->numberOfBlocks, _BTAG );
	_Wait(_BTAG);

	vector float *BKJ, *BIJ, aik;
	float *AIK;

	unsigned int x;

	int ain, ain2;

	_DBGP_UINT( 4000 );
	_DBGP_UINT( CB );

	// Same A, get it once
	_GetBlock( blocks_A, info->LS_blockDataArea[1], CB*A->numberOfBlocksXDim+CB, A->blockSize*A->blockSize, idx );


	_Wait(idx);
	_DBGP_UINT( CB*B->numberOfBlocksXDim+1+CB+SPE_id );

	// Get first block of B
	_GetBlock( blocks_B, info->LS_blockDataArea[0], CB*B->numberOfBlocksXDim+1+CB+SPE_id, B->blockSize*B->blockSize, idx );

	_Wait(idx);
	_DBGP_UINT( 5000 );

	//funcs->printuint(CB + SPE_id + 1);
	//funcs->printuint(B->numberOfBlocksXDim-myop->num_SPES);

	// For each block column
	// BLOCK >
	for( col = CB + SPE_id + 1 ; col < B->numberOfBlocksXDim-myop->num_SPES ; col += myop->num_SPES )
	{
		_DBGP_UINT( 100000 + col );

		nextidx = idx ^ 1;

		//funcs->printuint(CB*A->numberOfBlocksXDim+col+myop->num_SPES);
		_GetBlock( blocks_B, info->LS_blockDataArea[nextidx*3], CB*B->numberOfBlocksXDim+col+myop->num_SPES, B->blockSize*B->blockSize, nextidx );

		_Wait( idx );

		for( l = 1 ; l < B->blockSize ; l++ )
		{
			_DBGP_UINT( 200000 + l );

			BKJ = (vector float*)( info->LS_blockDataArea[idx*3] + (l-1) % B->blockSize * B->blockSize * 4 );

			// BIJ[i] = BIJ[i] - BKJ[i] * aik;
			_compute( B->blockSize, l, l-1, BKJ, (float*)info->LS_blockDataArea[idx*3], (float*)info->LS_blockDataArea[1] );
			//_compute2( B->blockSize, l, l-1, BKJ, (float*)info->LS_blockDataArea[idx*3], (float*)info->LS_blockDataArea[1], funcs );
		}


		// Return the result to the PPE
		_PutAsync( (unsigned int)blocks_B[CB*A->numberOfBlocksXDim+col], B->blockSize * B->blockSize * 4, info->LS_blockDataArea[idx*3], idx );

		idx = nextidx;
	}

	_DBGP_UINT( 100000 + col );

	_Wait( idx );

	for( l = 1 ; l < B->blockSize ; l++ )
	{
		BKJ = (vector float*)( info->LS_blockDataArea[idx*3] + (l-1) % B->blockSize * B->blockSize * 4 );
		//_compute2( B->blockSize, l, l-1, BKJ, (float*)info->LS_blockDataArea[idx*3], (float*)info->LS_blockDataArea[1], funcs );
		_compute( B->blockSize, l, l-1, BKJ, (float*)info->LS_blockDataArea[idx*3], (float*)info->LS_blockDataArea[1] );
	}

	//funcs->printuint( 678 );
	//_PrintMatrix( B, info->LS_blockDataArea[idx*3], funcs );


	// Return the result to the PPE
	_PutAsync( (unsigned int)blocks_B[CB*A->numberOfBlocksXDim+col], B->blockSize * B->blockSize * 4, info->LS_blockDataArea[idx*3], idx );

}
Ejemplo n.º 5
0
double MathSolver::_compute(TiXmlNode *node)
{
	if(!node)
		qDebug() << "The node is null";

	TiXmlNode *child = node->FirstChild();

	QString type = child->Value();
	qDebug() << "The node type is:" << type;

	/********************************************************/
	// if numerical type, return the scalar

	if("cn" == type){
		TiXmlNode *text = child->FirstChild();
		if(!text)
			return 0;

		QString t = child->FirstChild()->Value();
		return t.toDouble();
	}
	// TODO: make the regex available somewhere else to reduce
	// avoid multiple object creation
	QRegExp re("^[0-9]+\.?[0-9]*");
	if(type.contains(re))
		return type.toDouble(); // in this case type is the scalar

	/********************************************************/
	// if function, process it

	if("apply" == type){
		return MathSolver::_compute(child);
	}

	/********************************************************/

	if("power" == type){
		double base = _compute(child->NextSibling());
		double exp = _compute(child->NextSibling()->NextSibling());
		return qPow(base, exp);
	}

	// can process as many arguments as possible
	if("plus" == type){
		double sum = 0;
		for(TiXmlNode *summand=child->NextSibling();
			summand; summand=summand->NextSibling())
		{
			sum += MathSolver::_compute(summand);
		}

		return sum;
	}

	// can process as many arguments as possible
	if("times" == type){
		double multiplication = 1;
		for(TiXmlNode *multarg=child->NextSibling();
			multarg; multarg=multarg->NextSibling())
		{
			multiplication *= MathSolver::_compute(multarg);
		}

		return multiplication;
	}

	return 0;
}