当前位置: 首页>>代码示例>>C++>>正文


C++ Exp函数代码示例

本文整理汇总了C++中Exp函数的典型用法代码示例。如果您正苦于以下问题:C++ Exp函数的具体用法?C++ Exp怎么用?C++ Exp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Exp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void Parser::Expp()
{
	switch(look.kind)
	{
	case LT:
	case TIMES:
	case PLUS:
	case OR:
	case AND:
	case GT:
	case EQ:
	case MINUS:
	case DIV: Op();Exp();Expp();return;
	case LBRACK: Match(LBRACK);Exp();Match(RBRACK);Expp();return;
	case DOT: Match(DOT);
		switch(look.kind)
		{
		case LENGTH:Match(LENGTH);Expp();return;
		case ID: Id();Match(LPAREN);ExpList();Match(RPAREN);Expp();
		default: return;
		}
	case RPAREN:
	case SEMICOLON: return;	
	}
}
开发者ID:feimengspirit,项目名称:compiler,代码行数:25,代码来源:Parser.cpp

示例2: Consume

int ConstExpression::P()
{
    Operator *op;
    if(op=GetOperator(Next()->type_id(),1)) // unary
    {
        Consume();
        int q = op->prec;
        int t = Exp(q);
        return MakeNode(op,t,0);
    }
    else if(Next()->type_id()==TKN_L_PAREN)
    {
        Consume();
        int t = Exp(0);
        Expect(TKN_R_PAREN);
        return t;
    }
    else if(Next()->type_id()==TKN_NUMBER)
    {
        int t = atoi(Next()->get_text().c_str());
        Consume();
        return t;
    }
    else
        exit(0);

}
开发者ID:asmwarrior,项目名称:quexparser,代码行数:27,代码来源:ConstExpression.cpp

示例3: Exp

void EnvelopeGen::OnProcess(int voiceID, Synth* synth)
{
    EnvelopeGenVoiceData &data = mVoiceData[voiceID];

    Frame<SampleType> &output = mOutputs[0].frame;

    if (data.postRelease)
    {
        // release envelope
        for (size_t i = 0; i < synth->GetFrameSize(); i++)
        {
            output[i] = data.releaseVolume * Exp(-data.time * mReleaseInv);
            data.time += synth->GetSampleRateInv();
        }
    }
    else
    {
        for (size_t i = 0; i < synth->GetFrameSize(); i++)
        {
            if (data.time < mAttack) // attack envelope
                output[i] = 0.5 - 0.5 * Cos(data.time * mAttackInv * M_PI);
            else if (data.time > 0.0)
                output[i] = mSustain + (1.0f - mSustain) * Exp(-(data.time - mAttack) * mDecayInv);
            else
                output[i] = 0.0;

            data.time += synth->GetSampleRateInv();
        }

        data.lastValue = output[synth->GetFrameSize() - 1];
    }
}
开发者ID:Witek902,项目名称:mvPlugins,代码行数:32,代码来源:EnvelopeGen.cpp

示例4: mesher_

    Fdm2dBlackScholesOp::Fdm2dBlackScholesOp(
            const boost::shared_ptr<FdmMesher>& mesher,
            const boost::shared_ptr<GeneralizedBlackScholesProcess>& p1,
            const boost::shared_ptr<GeneralizedBlackScholesProcess>& p2,
            Real correlation,
            Time maturity,
            bool localVol,
            Real illegalLocalVolOverwrite)
    : mesher_(mesher),
      p1_(p1),
      p2_(p2),
      
      localVol1_((localVol) ? p1->localVolatility().currentLink()
                            : boost::shared_ptr<LocalVolTermStructure>()),
      localVol2_((localVol) ? p2->localVolatility().currentLink()
                            : boost::shared_ptr<LocalVolTermStructure>()),
                            
      x_((localVol) ? Array(Exp(mesher->locations(0))) : Array()),
      y_((localVol) ? Array(Exp(mesher->locations(1))) : Array()),

      opX_(mesher, p1, p1->x0(), localVol, illegalLocalVolOverwrite, 0),
      opY_(mesher, p2, p2->x0(), localVol, illegalLocalVolOverwrite, 1),
      
      corrMapT_(0, 1, mesher),
      corrMapTemplate_(SecondOrderMixedDerivativeOp(0, 1, mesher)
                      .mult(Array(mesher->layout()->size(), correlation))),
                      
      illegalLocalVolOverwrite_(illegalLocalVolOverwrite) { 
    }
开发者ID:brotchie,项目名称:quantlib,代码行数:29,代码来源:fdm2dblackscholesop.cpp

示例5: operator

 Spectrum operator()(float d2) const {
     Spectrum dpos = Sqrt(Spectrum(d2) + zpos * zpos);
     Spectrum dneg = Sqrt(Spectrum(d2) + zneg * zneg);
     Spectrum Rd = (1.f / (4.f * M_PI)) *
         ((zpos * (dpos * sigma_tr + Spectrum(1.f)) *
           Exp(-sigma_tr * dpos)) / (dpos * dpos * dpos) -
          (zneg * (dneg * sigma_tr + Spectrum(1.f)) *
           Exp(-sigma_tr * dneg)) / (dneg * dneg * dneg));
     return Rd.Clamp();
 }
开发者ID:ChiahungTai,项目名称:ray-hierarchy-,代码行数:10,代码来源:dipolesubsurface.cpp

示例6: Exact

static void Exact(PetscReal t,
                  PetscReal omega,PetscReal xi,PetscReal u0,PetscReal v0,
                  PetscReal *ut,PetscReal *vt)
{
#define Sin  PetscSinReal
#define Cos  PetscCosReal
#define Exp  PetscExpReal
#define Sqrt PetscSqrtReal
  PetscReal u,v;
  if (xi < 1) {
    PetscReal a  = xi*omega;
    PetscReal w  = Sqrt(1-xi*xi)*omega;
    PetscReal C1 = (v0 + a*u0)/w;
    PetscReal C2 = u0;
    u = Exp(-a*t) * (C1*Sin(w*t) + C2*Cos(w*t));
    v = (- a * Exp(-a*t) * (C1*Sin(w*t) + C2*Cos(w*t))
         + w * Exp(-a*t) * (C1*Cos(w*t) - C2*Sin(w*t)));
  } else if (xi > 1) {
    PetscReal w  = Sqrt(xi*xi-1)*omega;
    PetscReal C1 = (w*u0 + xi*u0 + v0)/(2*w);
    PetscReal C2 = (w*u0 - xi*u0 - v0)/(2*w);
    u = C1*Exp((-xi+w)*t) + C2*Exp((-xi-w)*t);
    v = C1*(-xi+w)*Exp((-xi+w)*t) + C2*(-xi-w)*Exp((-xi-w)*t);
  } else {
    PetscReal a  = xi*omega;
    PetscReal C1 = v0 + a*u0;
    PetscReal C2 = u0;
    u = (C1*t + C2) * Exp(-a*t);
    v = (C1 - a*(C1*t + C2)) * Exp(-a*t);
  }
  if (ut) *ut = u;
  if (vt) *vt = v;
}
开发者ID:firedrakeproject,项目名称:petsc,代码行数:33,代码来源:ex43.c

示例7: main

int main () 
{
    int k,p;
    float s;
    for ( k=0; k<100; k++){
        p= (2*(Exp (-1,k))*(Exp (3, 0.5-k)))/((2*k)+1);
        s=s+p;
    }
    printf ( " El valor de pi es:%.5f",s); 
    return 0;       
}
开发者ID:cslucano,项目名称:fcc201,代码行数:11,代码来源:pi.c

示例8: SE3

void GJointRevolute::update_short()
{
	if ( bReversed ) {
		T = SE3(Exp(-axis*coordinate.q), Vec3(0,0,0));
		inv_T = SE3(~T.GetRotation());
		S[0] = -axis[0]; S[1] = -axis[1]; S[2] = -axis[2];
	} else {
		T = SE3(Exp(axis*coordinate.q), Vec3(0,0,0));
		inv_T = SE3(~T.GetRotation());
		S[0] = axis[0]; S[1] = axis[1]; S[2] = axis[2];
	}
}
开发者ID:mrdeveloperdude,项目名称:OctoMY,代码行数:12,代码来源:gjoint_revolute.cpp

示例9: SaveTree

void Pdb::SetTree(const String& exp)
{
	SaveTree();
	tree.Clear();
	NamedVal nv;
	try {
		CParser p(exp);
		nv.val = Exp(p);
	}
	catch(CParser::Error) {
		return;
	}
	nv.name = exp;
	String n = exp;
	if(nv.val.type >= 0)
		n = GetType(nv.val.type).name;
	tree.SetRoot(Null, RawToValue(nv), n + '=' + Visualise(nv.val).GetString());
	if(nv.val.type >= 0) {
		String w = treetype.Get(n, Null);
		LOG("SetTree " << n << ' ' << w);
		tree.Open(0);
		CParser p(w);
		try {
			Point sc;
			sc.x = p.ReadInt();
			sc.y = p.ReadInt();
			int cursor = p.ReadInt();
			ExpandTreeType(0, p);
			tree.ScrollTo(sc);
			if(cursor >= 0)
				tree.SetCursor(cursor);
		}
		catch(CParser::Error) {}
	}
}
开发者ID:guowei8412,项目名称:upp-mirror,代码行数:35,代码来源:Data.cpp

示例10: DataMap

void Pdb::Explorer()
{
	VectorMap<String, Value> prev = DataMap(explorer);
	explorer.Clear();
	try {
		String x = ~expexp;
		if(!IsNull(x)) {
			CParser p(x);
			Val v = Exp(p);
			Vis(explorer, "=", prev, Visualise(v));
			if(v.type >= 0 && v.ref == 0 && !v.rvalue)
				Explore(v, prev);
			if(v.ref > 0 && GetRVal(v).address)
				for(int i = 0; i < 20; i++)
					Vis(explorer, Format("[%d]", i), prev, Visualise(DeRef(Compute(v, RValue(i), '+'))));
		}
	}
	catch(CParser::Error e) {
		Visual v;
		v.Cat(e, LtRed);
		explorer.Add("", RawPickToValue(v));
	}
	exback.Enable(exprev.GetCount());
	exfw.Enable(exnext.GetCount());
}
开发者ID:guowei8412,项目名称:upp-mirror,代码行数:25,代码来源:Data.cpp

示例11: entry

inline void
NewtonStep
( const DistMatrix<F>& X, DistMatrix<F>& XNew, Scaling scaling=FROB_NORM )
{
#ifndef RELEASE
    CallStackEntry entry("sign::NewtonStep");
#endif
    typedef BASE(F) Real;

    // Calculate mu while forming B := inv(X)
    Real mu;
    DistMatrix<Int,VC,STAR> p( X.Grid() );
    XNew = X;
    LU( XNew, p );
    if( scaling == DETERMINANT )
    {
        SafeProduct<F> det = determinant::AfterLUPartialPiv( XNew, p );
        mu = Real(1)/Exp(det.kappa);
    }
    inverse::AfterLUPartialPiv( XNew, p );
    if( scaling == FROB_NORM )
        mu = Sqrt( FrobeniusNorm(XNew)/FrobeniusNorm(X) );
    else if( scaling == NONE )
        mu = 1;
    else
        LogicError("Scaling case not handled");

    // Overwrite XNew with the new iterate
    const Real halfMu = mu/Real(2);
    const Real halfMuInv = Real(1)/(2*mu); 
    Scale( halfMuInv, XNew );
    Axpy( halfMu, X, XNew );
}
开发者ID:khalid-hasanov,项目名称:Elemental,代码行数:33,代码来源:Sign.hpp

示例12: Exp

/**
 * Return the path name of the UObject represented by the specified export.
 * (can be used with StaticFindObject)
 * 
 * @param	ExportIndex				index into the ExportMap for the resource to get the name for
 * @param	FakeRoot				Optional name to replace use as the root package of this object instead of the linker
 * @param	bResolveForcedExports	if true, the package name part of the return value will be the export's original package,
 *									not the name of the package it's currently contained within.
 *
 * @return	the path name of the UObject represented by the resource at ExportIndex
 */
FString FLinker::GetExportPathName(int32 ExportIndex, const TCHAR* FakeRoot,bool bResolveForcedExports/*=false*/)
{
	FString Result;

	bool bForcedExport = false;
	for ( FPackageIndex LinkerIndex = FPackageIndex::FromExport(ExportIndex); !LinkerIndex.IsNull(); LinkerIndex = Exp(LinkerIndex).OuterIndex )
	{ 
		const FObjectExport Export = Exp(LinkerIndex);

		// don't append a dot in the first iteration
		if ( Result.Len() > 0 )
		{
			// if this export is not a UPackage but this export's Outer is a UPackage, we need to use subobject notation
			if ((Export.OuterIndex.IsNull() || GetExportClassName(Export.OuterIndex) == NAME_Package)
			  && GetExportClassName(LinkerIndex) != NAME_Package)
			{
				Result = FString(SUBOBJECT_DELIMITER) + Result;
			}
			else
			{
				Result = FString(TEXT(".")) + Result;
			}
		}
		Result = Export.ObjectName.ToString() + Result;
		bForcedExport = bForcedExport || Export.bForcedExport;
	}

	if ( bForcedExport && FakeRoot == NULL && bResolveForcedExports )
	{
		// Result already contains the correct path name for this export
		return Result;
	}

	return (FakeRoot ? FakeRoot : LinkerRoot->GetPathName()) + TEXT(".") + Result;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:46,代码来源:Linker.cpp

示例13: ASSERT

BOOL COXTreeItem::Expand(UINT nCode,COXTreeCtrl *pCtrl)
{

	ASSERT(pCtrl!=NULL);

	BOOL bWasVisible=IsVisible();

	switch(nCode)
	{
		case TVE_TOGGLE:
			m_bExpand = !m_bExpand;
			break;

		case TVE_COLLAPSE:
			if(!m_bExpand)
			{
				TRACE(_T("COXTreeItem::Expand: the item is already in collapsed state!\n"));
				return TRUE;
			}
			m_bExpand = FALSE;
			break;

		case TVE_EXPAND:
			if(m_bExpand)
			{
				TRACE(_T("COXTreeItem::Expand: the item is already in expanded state!\n"));
				return TRUE;
			}
			m_bExpand = TRUE;
			break;
		
		case TVE_COLLAPSERESET:
			pCtrl->DeleteChildrenItems(this);
			m_bExpand=FALSE;
			m_bExpandedOnce=FALSE;
			m_tvi.cChildren=0;
			return TRUE;
		
		default:
			TRACE(_T("COXTreeItem::Expand: unexpected case found!\n"));
			return FALSE;
	}
	
	if(m_bExpand)
		m_bExpandedOnce=TRUE;

	if(!bWasVisible && !m_bExpand)
		return TRUE;

	if(!IsVisible() && m_bExpand)
	{
		COXTreeItem* xtiParent=pxParent;
		ASSERT(xtiParent!=NULL && xtiParent!=&pCtrl->m_xtiRoot);
		xtiParent->Expand(TVE_EXPAND,pCtrl);
	}
	else
		Exp(pCtrl);
	
	return TRUE;
}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:60,代码来源:OXTreeItem.cpp

示例14: assert

void CNE6SSM_high_scale_constraint<Two_scale>::update_scale()
{
   assert(model && "CNE6SSM_high_scale_constraint<Two_scale>::"
          "update_scale(): model pointer is zero.");

   const double currentScale = model->get_scale();
   const CNE6SSM_soft_parameters beta_functions(model->calc_beta());

   const auto g1 = MODELPARAMETER(g1);
   const auto g2 = MODELPARAMETER(g2);
   const auto beta_g1 = BETAPARAMETER(g1);
   const auto beta_g2 = BETAPARAMETER(g2);

   scale = currentScale*Exp((-g1 + g2)/(BETA(g1) - BETA(g2)));


   if (errno == ERANGE) {
#ifdef ENABLE_VERBOSE
      ERROR("CNE6SSM_high_scale_constraint<Two_scale>: Overflow error"
            " during calculation of high scale: " << strerror(errno) << '\n'
            << "   current scale = " << currentScale << '\n'
            << "   new scale = " << scale << '\n'
            << "   resetting scale to " << get_initial_scale_guess());
#endif
      scale = get_initial_scale_guess();
      errno = 0;
   }


}
开发者ID:dylan-harries,项目名称:CNE6SSM-Spectrum,代码行数:30,代码来源:CNE6SSM_two_scale_high_scale_constraint.cpp

示例15: MakeDiscreteFourier

inline void
MakeDiscreteFourier( DistMatrix<Complex<R>,U,V>& A )
{
#ifndef RELEASE
    CallStackEntry entry("MakeDiscreteFourier");
#endif
    typedef Complex<R> F;

    const int m = A.Height();
    const int n = A.Width();
    if( m != n )
        throw std::logic_error("Cannot make a non-square DFT matrix");

    const R pi = 4*Atan( R(1) );
    const F nSqrt = Sqrt( R(n) );
    const int localHeight = A.LocalHeight();
    const int localWidth = A.LocalWidth();
    const int colShift = A.ColShift();
    const int rowShift = A.RowShift();
    const int colStride = A.ColStride();
    const int rowStride = A.RowStride();
    for( int jLocal=0; jLocal<localWidth; ++jLocal )
    {
        const int j = rowShift + jLocal*rowStride;
        for( int iLocal=0; iLocal<localHeight; ++iLocal )
        {
            const int i = colShift + iLocal*colStride;
            A.SetLocal( iLocal, jLocal, Exp(-2*pi*i*j/n)/nSqrt );

            const R theta = -2*pi*i*j/n;
            const Complex<R> alpha( Cos(theta), Sin(theta) );
            A.SetLocal( iLocal, jLocal, alpha/nSqrt );
        }
    }
}
开发者ID:ahmadia,项目名称:Elemental-1,代码行数:35,代码来源:DiscreteFourier.hpp


注:本文中的Exp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。