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


C++ Float::convert方法代码示例

本文整理汇总了C++中Float::convert方法的典型用法代码示例。如果您正苦于以下问题:C++ Float::convert方法的具体用法?C++ Float::convert怎么用?C++ Float::convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Float的用法示例。


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

示例1: Float

Number *Complex::expt(Number *number2){
	Complex *tmp = SCAST_COMPLEX(number2);
	Float *f = new Float();
	Float *real1 =SCAST_FLOAT(f->convert(real_));
	Float *imag1 = SCAST_FLOAT(f->convert(imag_));
	Float *real2 = SCAST_FLOAT(f->convert(tmp->real_));
	Float *imag2 = SCAST_FLOAT(f->convert(tmp->imag_));
	complex<double> a(real1->number_, imag1->number_), b(real2->number_, imag2->number_);
	complex<double> res = pow(a, b);
	Float *real = new Float(res.real()), *imag = new Float(res.imag());
	if (real->number_ == -0) real->number_ = 0;
	Complex *result = new Complex(real, imag);
	delete f, real1, imag1, real2, imag2, real, imag;
	return result;
}
开发者ID:Riolu,项目名称:Scheme,代码行数:15,代码来源:complex.cpp

示例2: acoss

Number* Rational::acoss()
{
    Float* res = new Float;
    Float* tmp = SCAST_FLOAT(res->convert(this));
    if (fabs(tmp->number_)<=1.0)
    {
        res->number_=asin(tmp->number_);
        delete tmp;
        return res;
    }
    else if (tmp->number_>0)
    {
        complex<double> c_a(tmp->number_,0.0);
        complex<double> c_res = asin(c_a);
        Complex* res = new Complex;
        res->exact_ = false;
        res->real_ = new Float(::real(c_res));
        res->imag_ = new Float(::imag(c_res));
        delete tmp;
        return res;
    }
    else
    {
        complex<double> c_a(fabs(tmp->number_),0.0);
        complex<double> c_res = asin(c_a);
        Complex* res = new Complex;
        res->exact_ = false;
        res->real_ = new Float(::real(c_res)+PI);
        res->imag_ = new Float(0.0-::imag(c_res));
        delete tmp;
        return res;
    }
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:33,代码来源:rational.cpp

示例3: atann

Number* Rational::atann()
{
    Float* res = new Float;
    Float* tmp2 = SCAST_FLOAT(res->convert(this));
    res->number_ = atan(tmp2->number_);
    delete tmp2;
    return res;
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:8,代码来源:rational.cpp

示例4: expp

Number* Rational::expp(Number* number2)
{
    Rational* rtmp2 = SCAST_RATIONAL(number2);
    if (num_==ZERO_ && rtmp2->num_==ZERO_) return new Float(1);
    else if (num_==ZERO_ && rtmp2->num_!=ZERO_) return new Float(0);
    if(num_.sgn_)
    {
        Complex* c = new Complex;
        c = SCAST_COMPLEX(c->convert(this));
        Complex* d = SCAST_COMPLEX(c->convert(rtmp2));
        return c->expp(d);
    }
    else
    {
        Float* tmpf = new Float;
        tmpf = SCAST_FLOAT(tmpf->convert(rtmp2));
        return new Float(pow(SCAST_FLOAT(tmpf->convert(this))->number_, tmpf->number_));
    }
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:19,代码来源:rational.cpp

示例5: expt

Number* Rational::expt(Number* obj){
    if(sgn()<0){
        Complex* c = new Complex();
        c = SCAST_COMPLEX(c->convert(this));
        Complex* d = SCAST_COMPLEX(c->convert(obj));
        return c->expt(d);
    }else{
        Float* tmpf = new Float();
        tmpf = SCAST_FLOAT(tmpf->convert(obj));
        return new Float(pow(double(*this), double(*SCAST_RATIONAL(obj))));
    }
}
开发者ID:yuchenlin,项目名称:SchemeCalc,代码行数:12,代码来源:rational.cpp

示例6: sqt

Number* Rational::sqt()
{
    if (!num_.sgn_) return new Float(sqrt((double)num_/(double)den_));
    else
    {
        Complex* resc = new Complex;
        Float* real = new Float(0.0);
        Float* imag = new Float(sqrt(fabs(SCAST_FLOAT(real->convert(this))->number_)));
        resc->real_ = real; resc->imag_ = imag; resc->exact_=false;
        return resc;
    }
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:12,代码来源:rational.cpp

示例7: logg

Number* Rational::logg()
{
    assert(num_!=ZERO_ && "undefined log0");
    if (!num_.sgn_)
    {
        Float* tmpf = new Float;
        tmpf = SCAST_FLOAT(tmpf->convert(this));
        return new Float(log(tmpf->number_));
    }
    else
    {
        Float* tmp = new Float;
        tmp = SCAST_FLOAT(tmp->convert(this));
        complex<double> c_x(tmp->number_,0.0);
        complex<double> c_res = log(c_x);
        Complex* res = new Complex;
        res->exact_ = false;
        res->real_ = new Float(::real(c_res));
        res->imag_ = new Float(::imag(c_res));
        delete tmp;
        return res;
    }
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:23,代码来源:rational.cpp

示例8: exttoinext

Number* Rational::exttoinext()
{
    Float* res = new Float;
    return res->convert(this);
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:5,代码来源:rational.cpp

示例9: expe

Number* Rational::expe()
{
    Float* tmpf = new Float;
    tmpf = SCAST_FLOAT(tmpf->convert(this));
    return new Float(exp(tmpf->number_));
}
开发者ID:elicassion,项目名称:MyScheme,代码行数:6,代码来源:rational.cpp


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