Пример #1
0
//-----Início Operadores de Multplicação-----//
Matrix Matrix::operator *(Matrix Mat1)//Operador de Multiplicação Matriz Matriz
{

    float temp = 0;
    Matrix Ret(this->rows, Mat1.cols);

    try
    {
        if (this->cols != Mat1.rows)
        {
            throw "As dimensoes das matrizes nao batem, a multiplicacao nao e possivel";
            Ret.zeros(this->rows, Mat1.cols);
        }
        else
        {
            for(int i = 0; i < this->rows; i++)
            {
                for (int col = 0; col < Mat1.cols; col++)
                {
                    temp = 0;
                    for (int j = 0; j < this->cols; j++)
                        temp += this->Mat[i][j]*Mat1.Mat[j][col];
                    Ret.Mat[i][col] = temp;
                }

            }
            return Ret;
       }
    }
    catch(const char* msg)
    {
        cerr<<endl<<msg<<endl;
    }
    return Ret;
}
Пример #2
0
// Function to return the speed of each planet
// as an array of 2-D vectors.
vec2dN System::derX(vec2dN L){
    vec2dN Ret(nObj);
    for (int i = 0 ; i < nObj ; i++){
        Ret[i] = sys[i].relV + L[i];
    }
    return Ret;
}
Пример #3
0
        GeometryRayTestResult Intersects(const Sphere& Ball, const Ray& Cast)
        {
            // Code in this function is based on the equivalent in Ogre
            const Vector3 CastDir = Cast.GetNormal();
            const Vector3 CastOrigin = Cast.GetOrigin() - Ball.Center; // Makes math easier to do this in sphere local coordinates
            const Real Radius = Ball.Radius;

            // Build coefficients for our formula
            // t = (-b +/- sqrt(b*b + 4ac)) / 2a
            Real ACoEff = CastDir.DotProduct(CastDir);
            Real BCoEff = 2 * CastOrigin.DotProduct(CastDir);
            Real CCoEff = CastOrigin.DotProduct(CastOrigin) - ( Radius * Radius );

            // Get the Determinate
            Real Determinate = ( BCoEff * BCoEff ) - ( 4 * ACoEff * CCoEff );
            if( Determinate < 0 ) {
                return GeometryRayTestResult(false,Ray());
            }else{
                Real NearDist = ( -BCoEff - MathTools::Sqrt( Determinate ) ) / ( 2 * ACoEff );
                Real FarDist = ( -BCoEff + MathTools::Sqrt( Determinate ) ) / ( 2 * ACoEff );

                Ray Ret( Cast.GetOrigin() + (CastDir * NearDist), Cast.GetOrigin() + (CastDir * FarDist) );
                return GeometryRayTestResult(true,Ret);
            }
        }
Пример #4
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CTraceContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidTraceServerUID.iUid)
	 	{
	 		TExitType Exxit =ph.ExitType();
	 		if(Exxit == EExitPending)
	 		{
		  		Ret = ETrue;
		  		break;
	 		}
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Пример #5
0
Ret xround(T val, Ret ret = Ret()) {
    return static_cast<Ret>(
        (val >= 0) ?
        floor(val + (T)(.5)) :
        ceil( val - (T)(.5))
    );
}
Пример #6
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CExPolicy_Server::OkToAddToValDb(RDbDatabase& aDatabase,const TDesC& aCode,const TDesC8& aString)
{
	TBool Ret(ETrue);
	
	TFileName QueryBuffer;
	QueryBuffer.Copy(_L("SELECT * FROM "));
	QueryBuffer.Append(KtxtVallist);
	
	RDbView Myview;
	Myview.Prepare(aDatabase,TDbQuery(QueryBuffer));
	CleanupClosePushL(Myview);
	Myview.EvaluateAll();
	Myview.FirstL();
	
	QueryBuffer.Copy(aString);
		
	while(Myview.AtRow()) // Just delete one instance of the message           
	{	
		Myview.GetL();		
		
		if(QueryBuffer == Myview.ColDes(3)
		&& aCode == Myview.ColDes(2))
		{
			Ret = EFalse;
			break;	
		}
			
		Myview.NextL();
	} 
	
	CleanupStack::PopAndDestroy(1); // Myview
	
	return Ret;
}
/*
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
*/
TInt RExampleServerClient::GetItemL(TExampleItem& aItemBuffer)
{
	TInt Ret(KErrNone);
	
	TPckgBuf<TExampleItem> ItemBuffer(aItemBuffer);
	
#ifdef __SERIES60_3X__
	
	TIpcArgs args(&ItemBuffer);
	Ret = SendReceive(EExamplePServGetItem, args);
#else	
	TAny* messageParameters[KMaxMessageArguments];

    messageParameters[0] = static_cast<TAny*>(&ItemBuffer);
    
	Ret = SendReceive(EExamplePServGetItem, &messageParameters[0]);
#endif

	aItemBuffer.iName.Copy(ItemBuffer().iName);
    aItemBuffer.iExitCatogory.Copy(ItemBuffer().iExitCatogory);
    aItemBuffer.iProcess.Copy(ItemBuffer().iProcess);
    aItemBuffer.iExitType = ItemBuffer().iExitType;
    aItemBuffer.iExitReason = ItemBuffer().iExitReason;
    aItemBuffer.iTime = ItemBuffer().iTime;
    
	return Ret;	
}
Пример #8
0
        Nodecl::NodeclVisitor<void>::Ret AVX2StrideVisitorConv::unhandled_node(const Nodecl::NodeclBase& node) 
        {
            //printf("Unsupported %d: %s\n", _vector_num_elements, node.prettyprint().c_str()); 
            
            if (node.get_type().is_vector())
            {

                Nodecl::NodeclBase new_node = node.shallow_copy().as<Nodecl::NodeclBase>();

                new_node.set_type(TL::Type::get_int_type().get_vector_of_elements(
                            _vector_num_elements));

                // TODO better
                node.replace(new_node);

                Nodecl::NodeclBase::Children children = node.children();
                for(Nodecl::NodeclBase::Children::iterator it = children.begin();
                        it != children.end();
                        it ++)
                {
                    walk(*it);
                }
            }
            return Ret(); 
        }
Пример #9
0
 std::function<Ret (Param...)> bind_first(const std::function<Ret (P1, Param...)> &f, O&& o)
 {
   return std::function<Ret (Param...)>(
       [f, o](Param...param) -> Ret {
         return f(o, std::forward<Param>(param)...);
       });
 }
Пример #10
0
glm::vec4 Grid::Box( Actor const& Obj, double Dt )const
{
    Opt<IMoveComponent> moveC = Obj.Get<IMoveComponent>();
    float const MvX = moveC.IsValid() ? Dt * moveC->GetSpeedX() : 0.0f;
    float const MvY = moveC.IsValid() ? Dt * moveC->GetSpeedY() : 0.0f;

    double const Radius = Obj.Get<ICollisionComponent>()->GetRadius();
    Opt<IPositionComponent> const objPositionC = Obj.Get<IPositionComponent>();
    double const Ox = objPositionC->GetX() - mMin.x;
    double const Oy = objPositionC->GetY() - mMin.y;
    glm::vec4 Ret( Ox - Radius,
                   Oy - Radius,
                   Ox + Radius,
                   Oy + Radius );
    if( MvX < 0.0 )
    {
        Ret.x += MvX;
    }
    else
    {
        Ret.z += MvX;
    }
    if( MvY < 0.0 )
    {
        Ret.y += MvY;
    }
    else
    {
        Ret.w += MvY;
    }
    return Ret;
}
Пример #11
0
//Calc. the force from the sun when the sun is put
//Stationary at origo.
vec2dN System::SunInf(vec2dN K){
    vec2dN Ret(nObj);
    for (int i = 0 ; i < nObj ; i++){
        vec2d tmp = sys[i].relR + K[i];
        Ret[i] = -tmp/pow(tmp.norm(), 3);
    }
    return Ret;
}
//----Início Operador de Matriz Transposta-----//
Matrix Matrix::operator~()//Faz a transporta da Matriz
{
    Matrix temp = *this, Ret(this->cols, this->rows);
    for(int i = 0; i < this->cols; i++)
        for (int j = 0; j < this->rows; j++)
                Ret.Mat[i][j] = temp.Mat[j][i];
    return Ret;
}
Пример #13
0
FPooledRenderTargetDesc FRCPassPostProcessTestImage::ComputeOutputDesc(EPassOutputId InPassOutputId) const
{
	FPooledRenderTargetDesc Ret(FPooledRenderTargetDesc::Create2DDesc(GSceneRenderTargets.GetBufferSizeXY(), PF_B8G8R8A8, TexCreate_None, TexCreate_RenderTargetable, false));

	Ret.DebugName = TEXT("TestImage");

	return Ret;
}
Пример #14
0
color4i NormDataToColor(double const Value)
{
	int const Index = Clamp<int>((int) (Value * ION_ARRAYSIZE(ch20m151010)), 0, ION_ARRAYSIZE(ch20m151010) - 1);
	color3f r = ch20m151010[Index];
	color4f Ret(r[0], r[1], r[2], (float) Value);
	Ret.Alpha = (float) Value;
	return Ret;
}
FPooledRenderTargetDesc FRCPassPostProcessTestImage::ComputeOutputDesc(EPassOutputId InPassOutputId) const
{
	FPooledRenderTargetDesc Ret(FPooledRenderTargetDesc::Create2DDesc(FSceneRenderTargets::Get_FrameConstantsOnly().GetBufferSizeXY(), PF_B8G8R8A8, FClearValueBinding::None, TexCreate_None, TexCreate_RenderTargetable, false));

	Ret.DebugName = TEXT("TestImage");

	return Ret;
}
FPooledRenderTargetDesc FRCPassPostProcessScreenSpaceReflections::ComputeOutputDesc(EPassOutputId InPassOutputId) const
{
	FPooledRenderTargetDesc Ret(FPooledRenderTargetDesc::Create2DDesc(FSceneRenderTargets::Get_FrameConstantsOnly().GetBufferSizeXY(), PF_FloatRGBA, FClearValueBinding::None, TexCreate_None, TexCreate_RenderTargetable, false));

	Ret.DebugName = TEXT("ScreenSpaceReflections");

	return Ret;
}
FPooledRenderTargetDesc FRCPassPostProcessScreenSpaceReflections::ComputeOutputDesc(EPassOutputId InPassOutputId) const
{
	FPooledRenderTargetDesc Ret(FPooledRenderTargetDesc::Create2DDesc(GSceneRenderTargets.GetBufferSizeXY(), PF_FloatRGBA, TexCreate_None, TexCreate_RenderTargetable, false));

	Ret.DebugName = TEXT("ScreenSpaceReflections");

	return Ret;
}
Пример #18
0
        Nodecl::NodeclVisitor<void>::Ret NeonVectorBackend::unhandled_node(const Nodecl::NodeclBase& n)
        {
            internal_error("NEON Backend: Unknown node %s at %s.",
                    ast_print_node_type(n.get_kind()),
                    locus_to_str(n.get_locus()));

            return Ret();
        }
Пример #19
0
 std::function<Ret (Param...)> bind_first(Ret (Class::*f)(Param...), O&& o)
 {
   return std::function<Ret (Param...)>(
       [f, o](Param...param) -> Ret {
         return (get_pointer(o)->*f)(std::forward<Param>(param)...);
       }
     );
 }
Пример #20
0
 std::function<Ret (Param...)> bind_first(Ret (*f)(P1, Param...), O&& o)
 {
   return std::function<Ret (Param...)>(
       [f, o](Param...param) -> Ret {
         return f(std::forward<O>(o), std::forward<Param>(param)...);
       }
     );
 }
Пример #21
0
 Common::RefObjPtr<IFaces::IRawDataBuffer>
   LoadFileToBuffer(const std::string &fileName, const Common::ISynObj &syn)
 {
   Common::RefObjPtr<IFaces::IStream> Stream(OpenFileStream(fileName, false, syn));
   Common::RefObjPtr<IFaces::IStream> Ret(OpenMemoryStream(syn));
   IStreamHelper(Stream).CopyTo(Ret);
   return Common::RefObjQIPtr<IFaces::IRawDataBuffer>(Ret);
 }
Пример #22
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CExPolicy_Server::IsCodeOkL(const TDesC& aCode,const TDesC8& aString)
{
	TBool Ret(EFalse);
	
	if(aString.Length() && aCode.Length())
	{
		if(iIsThai)
		{
			Ret = iIsThai;
		}
		else
		{
			TFindFile PrivFolder(iFsSession);
			if(KErrNone == PrivFolder.FindByDir(KtxDatabaseName, KNullDesC))// finds the drive
			{
				TParsePtrC Hjelppp(PrivFolder.File());
				TFileName FilNammm;
				
				FilNammm.Copy(Hjelppp.Drive());
				FilNammm.Append(KtxValFileName);
			
				if(BaflUtils::FileExists(iFsSession,FilNammm))
				{
					RDbNamedDatabase ValDatabase;
					if(KErrNone == ValDatabase.Open(iFsSession,FilNammm))
					{
						if(OkToAddToValDb(ValDatabase,aCode,aString))
						{
							Ret = ETrue;
							AddToValDatabase(ValDatabase,aCode,aString);
						}
						
						ValDatabase.Close();
					}
				}
				else
				{
					// make sure folder exists in the path 
					BaflUtils::EnsurePathExistsL(iFsSession,FilNammm);
					
					RDbNamedDatabase ValDatabase;
					// no database exists so we make one
					User::LeaveIfError(ValDatabase.Create(iFsSession,FilNammm));     
					// and will create the onlt table needed for it
					CreateValTableL(ValDatabase);
					
					AddToValDatabase(ValDatabase,aCode,aString);
					
					ValDatabase.Close();
					
					Ret = ETrue;	
				}
			}
		}
	}

	return Ret;
}
    static int call_func(lua_State* L, std::index_sequence<I...>)
    {
        Ret(*func)(Args...) = static_cast<Ret(*)(Args...)>(lua_touserdata(L, lua_upvalueindex(1)));

        ValueConverter<Ret>::PushValue(L,
            func(ValueConverter<Args>::Unpack(L, I + 1)...));

        return 1;
    }
Пример #24
0
        Nodecl::NodeclVisitor<void>::Ret VectorizerVisitorFunction::unhandled_node(const Nodecl::NodeclBase& n) 
        { 
            std::cerr << "Function Visitor: Unknown node " 
                << ast_print_node_type(n.get_kind()) 
                << " at " << n.get_locus() 
                << std::endl;

            return Ret(); 
        }
Пример #25
0
	Ret operator() (METHOD_ARGS)
	{
		if (is_null()) return Ret();
		typename DelegatesList::iterator prevend = delegates.end();
		--prevend;
		for (typename DelegatesList::iterator it = delegates.begin(); it != prevend; ++it)		
			(*(*it))(ARGS);
		return (*(*prevend))(ARGS);
	}
Пример #26
0
//-----Início Operadores de Subtração-----//
Matrix Matrix::operator -(Matrix Mat1)//Operador de subtração Matriz Matriz
{
    Matrix Ret(this->rows, this->cols);

    for(int i = 0; i < this->rows; i++)
        for (int j = 0; j < this->cols; j++)
            Ret.Mat[i][j] = this->Mat[i][j] - Mat1.Mat[i][j];

    return Ret;
}
Пример #27
0
Matrix Matrix::operator -(float a)//Operador de subtração Escalar Matriz
{
    Matrix Ret(this->rows, this->cols);

    for(int i = 0; i < this->rows; i++)
        for (int j = 0; j < this->cols; j++)
            Ret.Mat[i][j] = this->Mat[i][j] - a;

    return Ret;
}
Пример #28
0
Matrix Matrix::operator *(float a)//Operador de multiplicação Escalar Matriz
{
    Matrix Ret(this->rows, this->cols);

    for(int i = 0; i < this->rows; i++)
        for (int j = 0; j < this->cols; j++)
            Ret.Mat[i][j] = a*this->Mat[i][j];

    return Ret;
}
Пример #29
0
TString UUIDToString(UUID const &Val) {
	TString Ret(40, NullTChar);
	Cardinal128 const &Value = (Cardinal128 const &)Val;
	int result = _sntprintf_s((PTCHAR)Ret.data(), 36 + 1, 36 + 1, _T("%08X-%04hX-%04hX-%02X%02X-%02X%02X%02X%02X%02X%02X"),
							  Value.U32[0], Value.U16[2], Value.U16[3],
							  Value.U8[8], Value.U8[9], Value.U8[10], Value.U8[11],
							  Value.U8[12], Value.U8[13], Value.U8[14], Value.U8[15]);
	if (result < 0)
		FAIL(_T("Converting from GUID to string failed with error code %d"), errno);
	return Ret;
}
Пример #30
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CExPolicy_Server::IsReadyForAction(void)
{
	TBool Ret(EFalse);
	
	if(iImei.Length())
	{
		Ret = ETrue;
	}
	
	return Ret;
}