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


C++ Float类代码示例

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


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

示例1: SCAST_FLOAT

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

示例2: capi_rfloat_value

  double capi_rfloat_value(VALUE flt) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Handle* handle = Handle::from(flt);
    Float* f = c_as<Float>(handle->object());
    return f->to_double(env->state());
  }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:7,代码来源:float.cpp

示例3: flush_cached_rfloat

 void flush_cached_rfloat(NativeMethodEnvironment* env, Handle* handle) {
   if(handle->is_rfloat()) {
     Float* obj = c_as<Float>(handle->object());
     RFloat* rfloat = handle->as_rfloat(env);
     obj->value(rfloat->value);
   }
 }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:7,代码来源:float.cpp

示例4: AppLog

void  LocationMapForm::HandleJavaScriptRequestN (Tizen::Web::Json::IJsonValue *pArg)
{
	 AppLog("PathFinder:: HandleJavaScriptRequestN");
	 result r = E_SUCCESS;
	 JsonObject* pJsonObject = static_cast< JsonObject* >(pArg);
	 IJsonValue* pValue = null;
	 JsonString* pJsonStringValue = null;
	 String key(L"data");

	 r = pJsonObject->GetValue(&key, pValue);
	 pJsonStringValue = static_cast< JsonString* >(pValue);
	 const wchar_t* mapPointString = pJsonStringValue->GetPointer();

	 AppLog("data: %ls\n", mapPointString);

	 String *tmpString = new String(mapPointString);

	 Float x , y;

	 int idx = 0;


	 tmpString->IndexOf(' ' , 0 , idx);

	 String *tmpString2 = new String ( mapPointString + idx + 1 );

	 const wchar_t* tmpChar =  tmpString->GetPointer();
	 wchar_t* tmpChar3 = const_cast<wchar_t*>(tmpChar);
	 tmpChar3[idx] = '\0';
	 const wchar_t* tmpChar2 = tmpString2->GetPointer();

	 x.Parse(tmpChar3 , this->__latitude );
	 y.Parse(tmpChar2 , this->__longitude );
}
开发者ID:PassionJHack,项目名称:passion,代码行数:34,代码来源:LocationMapForm.cpp

示例5: norm

int norm(int type,Float& y)
{ // convert y to 1st quadrant angle, and return sign
    int s=PLUS;
    Float pi,w,t;
    if (y.sign()<0)
    {
        y.negate();
        if (type!=COS) s=-s;
    }
    pi=fpi();
    w=pi/2;
    if (fcomp(y,w)<=0) return s;
    w=2*pi;
    if (fcomp(y,w)>0)
    { // reduce mod 2.pi
        t=y/w;
        t=trunc(t);
        t*=w;
        y-=t;
    }
    if (fcomp(y,pi)>0) 
    {
        y-=pi;
        if (type!=TAN) s=(-s);
    }
    w=pi/2;
    if (fcomp(y,w)>0)
    {
        y=pi-y;
        if (type!=SIN) s=(-s);
    }
    return s;
}
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:33,代码来源:floating.cpp

示例6: negate

Variable* negate(Variable* A)
{
    if(A == NULL)
    {
        interpreter.error("Error: Void variable in negation.\n");
        return NULL;
    }
    TypeEnum a = A->getType();
    if(a == STRING || a == BOOL || a == MACRO || a == ARRAY || a == LIST || a == FUNCTION || a == PROCEDURE)
    {
        interpreter.error("Error: Negation not defined for type '%s'\n", getTypeString(a).c_str());
        return NULL;
    }
    if(a == INT)
    {
        Int* C = static_cast<Int*>(A);
        Int* R = new Int;
        R->setValue(-C->getValue());
        return R;
    }
    else if(a == FLOAT)
    {
        Float* C = static_cast<Float*>(A);
        Float* R = new Float;
        R->setValue(-C->getValue());
        return R;
    }
    return A;
}
开发者ID:TheProjecter,项目名称:pile-build,代码行数:29,代码来源:eve_operators.cpp

示例7: parse_datum

Int Column<Float>::find_one(const Datum &datum) const {
  // TODO: Choose the best index.
  Float value = parse_datum(datum);
  if (!value.is_na() && !indexes_.is_empty()) {
    return indexes_[0]->find_one(datum);
  }
  return scan(value);
}
开发者ID:groonga,项目名称:grnxx,代码行数:8,代码来源:float.cpp

示例8: test_dsvp_reduce

/**
   @brief Test if dual SVP reduction returns reduced basis.

   @param A              input lattice
   @param b              shortest dual vector
   @return
*/
template <class ZT> int test_dsvp_reduce(ZZ_mat<ZT> &A, IntVect &b)
{
  IntMatrix u;
  int d = A.get_rows();

  Float normb;
  if (dual_length(normb, A, b))
  {
    return 1;
  }

  int status =
      lll_reduction(A, u, LLL_DEF_DELTA, LLL_DEF_ETA, LM_WRAPPER, FT_DEFAULT, 0, LLL_DEFAULT);
  if (status != RED_SUCCESS)
  {
    cerr << "LLL reduction failed: " << get_red_status_str(status) << endl;
    return status;
  }

  IntMatrix empty_mat;
  MatGSO<Integer, Float> gso(A, empty_mat, empty_mat, GSO_INT_GRAM);
  LLLReduction<Integer, Float> lll_obj(gso, LLL_DEF_DELTA, LLL_DEF_ETA, LLL_DEFAULT);

  vector<Strategy> strategies;
  BKZParam dummy(d, strategies);
  BKZReduction<Float> bkz_obj(gso, lll_obj, dummy);
  bool clean = true;

  bkz_obj.svp_reduction_ex(0, d, dummy, clean, true);
  status = bkz_obj.status;
  if (status != RED_SUCCESS)
  {
    cerr << "Failure: " << get_red_status_str(status) << endl;
    return status;
  }

  Float norm_sol;
  Integer zero;
  zero = 0;
  IntVect e_n(d, zero);
  e_n[d - 1] = 1;
  if (dual_length(norm_sol, A, e_n))
  {
    return 1;
  }

  Float error;
  error = 1;
  error.mul_2si(error, -(int)error.get_prec());
  normb += error;
  if (norm_sol > normb)
  {
    cerr << "Last dual vector too long by more than " << error << endl;
    return 1;
  }

  return 0;
}
开发者ID:damons,项目名称:fplll,代码行数:65,代码来源:test_svp.cpp

示例9: Float

Number *Complex::ang(){
	Float *f = new Float();
	Float *real1 = SCAST_FLOAT(f->convert(real_));
	Float *imag1 = SCAST_FLOAT(f->convert(imag_));
	complex<double> a(real1->number_, imag1->number_);
	Float *result = new Float(arg(a));
	delete f, real1, imag1;
	return result;
}
开发者ID:Riolu,项目名称:Scheme,代码行数:9,代码来源:complex.cpp

示例10: get

void Column<Float>::unset(Int row_id) {
  Float value = get(row_id);
  if (!value.is_na()) {
    // Update indexes if exist.
    for (size_t i = 0; i < num_indexes(); ++i) {
      indexes_[i]->remove(row_id, value);
    }
    values_[row_id.raw()] = Float::na();
  }
}
开发者ID:groonga,项目名称:grnxx,代码行数:10,代码来源:float.cpp

示例11: GetFloat

//-----------------------------------------------------------------------------
float DataType::GetFloat() const
{
    HRESULT hr;
    Float f;
    
    hr = f.Cast( *this );
    if( FAILED(hr) )
        return 0;

    return f.Get();
}
开发者ID:Edenspuzzle,项目名称:EdensEngine,代码行数:12,代码来源:DataType.cpp

示例12: Float

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

示例13:

// Divide val n1 by Float instance n2 and return the quotient, unless
// Float instance n2 is equal to zero, then return a zero and send an
// error message
inline double operator/(const double n1, const Float& n2)
{
    double n = n1;
    if (n2.getReal() != 0.0f) {
        n /= n2.getReal();
    }
    else {
        std::cerr << "Float::operator/(): Divide by zero!" << std::endl;
        n = 0.0f;
    }
    return n;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例14: Complex

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

示例15: solve_linear_program2

//This function demostrate how to use SIX to compute maxmium solution.
void solve_linear_program2()
{
	/* Given system has 2 variable, x1, x2
	max = 2x1 - x2
	s.t.
		2x1 - x2 <= 2
		x1 - 5x2 <= -4

		x1,x2 >= 0
	*/
	Float v;

	//Init linear inequality.
	FloatMat leq(2,3);
	leq.sete(6,
				2.0, -1.0, 		2.0,
				1.0, -5.0, 		-4.0);

	//Init target function.
	FloatMat tgtf(1,3);
	tgtf.sete(3,
				2.0, -1.0, 0.0);

	//Init variable constrain.
	FloatMat vc(2,3);
	vc.sete(6,
				-1.0,	0.0,	0.0,
				0.0,	-1.0, 	0.0);

	FloatMat res, eq;
	SIX<FloatMat,Float> six;

	//Dump to check.
	tgtf.dumpf();
	vc.dumpf();
	leq.dumpf();

	/*
	maximum is 2
	solution is:
	   14/9(1.555556)       10/9(1.111111)        0
	*/
	if (SIX_SUCC == six.maxm(v,res,tgtf,vc,eq,leq)) {
		printf("\nmaxv is %f\n", v.f());
		printf("\nsolution is:\n"); res.dumpf();
	} else {
		printf("\nunbound");
	}
}
开发者ID:Dan-Wang,项目名称:xpoly,代码行数:50,代码来源:example.cpp


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