當前位置: 首頁>>代碼示例>>C++>>正文


C++ std::log10方法代碼示例

本文整理匯總了C++中std::log10方法的典型用法代碼示例。如果您正苦於以下問題:C++ std::log10方法的具體用法?C++ std::log10怎麽用?C++ std::log10使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在std的用法示例。


在下文中一共展示了std::log10方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: TEST

TEST(AgradFwdLog10,Fvar) {
  using stan::math::fvar;
  using std::log;
  using std::isnan;
  using std::log10;

  fvar<double> x(0.5,1.0);
  
  fvar<double> a = log10(x);
  EXPECT_FLOAT_EQ(log10(0.5), a.val_);
  EXPECT_FLOAT_EQ(1 / (0.5 * log(10)), a.d_);

  fvar<double> b = 2 * log10(x) + 4;
  EXPECT_FLOAT_EQ(2 * log10(0.5) + 4, b.val_);
  EXPECT_FLOAT_EQ(2 / (0.5 * log(10)), b.d_);

  fvar<double> c = -log10(x) + 5;
  EXPECT_FLOAT_EQ(-log10(0.5) + 5, c.val_);
  EXPECT_FLOAT_EQ(-1 / (0.5 * log(10)), c.d_);

  fvar<double> d = -3 * log10(x) + 5 * x;
  EXPECT_FLOAT_EQ(-3 * log10(0.5) + 5 * 0.5, d.val_);
  EXPECT_FLOAT_EQ(-3 / (0.5 * log(10)) + 5, d.d_);

  fvar<double> y(-0.5,1.0);
  fvar<double> e = log10(y);
  isnan(e.val_);
  isnan(e.d_);

  fvar<double> z(0.0,1.0);
  fvar<double> f = log10(z);
  isnan(f.val_);
  isnan(f.d_);
}
開發者ID:aseyboldt,項目名稱:math,代碼行數:34,代碼來源:log10_test.cpp

示例2: log

TEST(AgradFwdLog10,FvarFvarDouble) {
  using stan::math::fvar;
  using std::log;

  fvar<fvar<double> > x;
  x.val_.val_ = 0.5;
  x.val_.d_ = 1.0;

  fvar<fvar<double> > a = log10(x);

  EXPECT_FLOAT_EQ(log10(0.5), a.val_.val_);
  EXPECT_FLOAT_EQ(1 / (0.5 * log(10)), a.val_.d_);
  EXPECT_FLOAT_EQ(0, a.d_.val_);
  EXPECT_FLOAT_EQ(0, a.d_.d_);

  fvar<fvar<double> > y;
  y.val_.val_ = 0.5;
  y.d_.val_ = 1.0;

  a = log10(y);
  EXPECT_FLOAT_EQ(log10(0.5), a.val_.val_);
  EXPECT_FLOAT_EQ(0, a.val_.d_);
  EXPECT_FLOAT_EQ(1 / (0.5 * log(10)), a.d_.val_);
  EXPECT_FLOAT_EQ(0, a.d_.d_);
}
開發者ID:aseyboldt,項目名稱:math,代碼行數:25,代碼來源:log10_test.cpp

示例3: complex_number_examples

void complex_number_examples()
{
    Complex z1{0, 1};
    std::cout << std::setprecision(std::numeric_limits<typename Complex::value_type>::digits10);
    std::cout << std::scientific << std::fixed;
    std::cout << "Print a complex number: " << z1 << std::endl;
    std::cout << "Square it             : " << z1*z1 << std::endl;
    std::cout << "Real part             : " << z1.real() << " = " << real(z1) << std::endl;
    std::cout << "Imaginary part        : " << z1.imag() << " = " << imag(z1) << std::endl;
    using std::abs;
    std::cout << "Absolute value        : " << abs(z1) << std::endl;
    std::cout << "Argument              : " << arg(z1) << std::endl;
    std::cout << "Norm                  : " << norm(z1) << std::endl;
    std::cout << "Complex conjugate     : " << conj(z1) << std::endl;
    std::cout << "Projection onto Riemann sphere: " <<  proj(z1) << std::endl;
    typename Complex::value_type r = 1;
    typename Complex::value_type theta = 0.8;
    using std::polar;
    std::cout << "Polar coordinates (phase = 0)    : " << polar(r) << std::endl;
    std::cout << "Polar coordinates (phase !=0)    : " << polar(r, theta) << std::endl;

    std::cout << "\nElementary special functions:\n";
    using std::exp;
    std::cout << "exp(z1) = " << exp(z1) << std::endl;
    using std::log;
    std::cout << "log(z1) = " << log(z1) << std::endl;
    using std::log10;
    std::cout << "log10(z1) = " << log10(z1) << std::endl;
    using std::pow;
    std::cout << "pow(z1, z1) = " << pow(z1, z1) << std::endl;
    using std::sqrt;
    std::cout << "Take its square root  : " << sqrt(z1) << std::endl;
    using std::sin;
    std::cout << "sin(z1) = " << sin(z1) << std::endl;
    using std::cos;
    std::cout << "cos(z1) = " << cos(z1) << std::endl;
    using std::tan;
    std::cout << "tan(z1) = " << tan(z1) << std::endl;
    using std::asin;
    std::cout << "asin(z1) = " << asin(z1) << std::endl;
    using std::acos;
    std::cout << "acos(z1) = " << acos(z1) << std::endl;
    using std::atan;
    std::cout << "atan(z1) = " << atan(z1) << std::endl;
    using std::sinh;
    std::cout << "sinh(z1) = " << sinh(z1) << std::endl;
    using std::cosh;
    std::cout << "cosh(z1) = " << cosh(z1) << std::endl;
    using std::tanh;
    std::cout << "tanh(z1) = " << tanh(z1) << std::endl;
    using std::asinh;
    std::cout << "asinh(z1) = " << asinh(z1) << std::endl;
    using std::acosh;
    std::cout << "acosh(z1) = " << acosh(z1) << std::endl;
    using std::atanh;
    std::cout << "atanh(z1) = " << atanh(z1) << std::endl;
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:57,代碼來源:mpc_examples.cpp

示例4: log10

inline
quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>
log10(const quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y>& q)
{
    using std::log10;

    typedef quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(S), Y> quantity_type;

    return quantity_type::from_value(log10(q.value()));
}
開發者ID:TheForum,項目名稱:Earth-and-Beyond-server,代碼行數:10,代碼來源:cmath_boost_1_35.hpp

示例5: log10

 inline
 fvar<T>
 log10(const fvar<T>& x) {
   using std::log;
   using std::log10;
   using stan::math::NOT_A_NUMBER;
   if (x.val_ < 0.0)
     return fvar<T>(NOT_A_NUMBER, NOT_A_NUMBER);
   else
     return fvar<T>(log10(x.val_), x.d_ / (x.val_ * stan::math::LOG_10));
 }
開發者ID:alyst,項目名稱:math,代碼行數:11,代碼來源:log10.hpp

示例6: calculate_size

int calculate_size(const Eigen::VectorXd& x, 
                   const std::string& name,
                   const int digits,
                   std::ios_base::fmtflags& format) {
  using std::max;
  using std::ceil;
  using std::log10;
  
  double padding = 0;
  if (digits > 0)
    padding = digits + 1;

  double fixed_size = 0.0;
  if (x.maxCoeff() > 0)
    fixed_size = ceil(log10(x.maxCoeff()+0.001)) + padding;
  if (x.minCoeff() < 0)
    fixed_size = max(fixed_size, ceil(log10(-x.minCoeff()+0.01))+(padding+1));
  format = std::ios_base::fixed;
  if (fixed_size < 7) {
    return max(fixed_size,
               max(name.length(), std::string("-0.0").length())+0.0);
  }

  double scientific_size = 0;
  scientific_size += 4.0;   // "-0.0" has four digits
  scientific_size += 1.0;   // e
  double exponent_size = 0;
  if (x.maxCoeff() > 0)
    exponent_size = ceil(log10(log10(x.maxCoeff())));
  if (x.minCoeff() < 0)
    exponent_size = max(exponent_size,
                        ceil(log10(log10(-x.minCoeff()))));
  scientific_size += fmin(exponent_size, 3);
  format = std::ios_base::scientific;
  return scientific_size;
}
開發者ID:aflaxman,項目名稱:stan,代碼行數:36,代碼來源:print.cpp

示例7: operator

 inline T0
 operator()(const T0& arg1) const {
   return log10(arg1);
 }
開發者ID:aseyboldt,項目名稱:math,代碼行數:4,代碼來源:log10_test.cpp

示例8: WriteSpx


//.........這裏部分代碼省略.........

	if(NULL==SpexFile.Open((LPCTSTR)spxPath,CFile::modeCreate|CFile::modeWrite| CFile::typeBinary))
	{
		cstrMsg=_T("Can not create file:\r\n");
		cstrMsg=cstrMsg+spxPath;
		AfxMessageBox((LPCTSTR)cstrMsg);
		return FALSE;
	}

	FillMemory(buff,1024,0);
	SpexFile.Write(buff,444);
	//skip id
	SpexFile.Seek(64,CFile::begin);
	//write comments;
	SpexFile.Write((LPCTSTR)cstrComment,MY_MIN(64,cstrComment.GetLength()));
	//skip fl,dr
	SpexFile.Seek(176,CFile::begin);
	//write operator
	SpexFile.Write((LPCTSTR)cstrUserName,MY_MIN(16,cstrUserName.GetLength()));
	SpexFile.Seek(192,CFile::begin);
	//data length
	myint16=nDA;  
	SpexFile.Write(&myint16,sizeof(WORD));
	//scan num
	myint16=nSN;
	SpexFile.Write(&myint16,sizeof(WORD));
	//CF
	ftemp=(float)dCF;
	SpexFile.Write(&ftemp,sizeof(float));
	//SW
	ftemp=(float)dSW;
	SpexFile.Write(&ftemp,sizeof(float));
	//TM
	ftemp=(float)dTM;
	SpexFile.Write(&ftemp,sizeof(float));
	//FQ  
	ftemp=(float)dFQ;
	SpexFile.Write(&ftemp,sizeof(float));
	//RG
	ftemp=(float)dRG;
	SpexFile.Write(&ftemp,sizeof(float));
	//MA
	ftemp=(float)dMA;
	SpexFile.Write(&ftemp,sizeof(float));
	//MF
	ftemp=(float)dMF;
	SpexFile.Write(&ftemp,sizeof(float));
	//PW
	ftemp=(float)dPW;
	SpexFile.Write(&ftemp,sizeof(float));
	//TC
	ftemp=(float)dTC;
	SpexFile.Write(&ftemp,sizeof(float));
	//PH
	myint16=nPH;
	SpexFile.Write(&myint16,sizeof(WORD));
	//OF
	myint16=nOF;
	SpexFile.Write(&myint16,sizeof(WORD));
	//TE
	ftemp=(float)nTE;
	SpexFile.Write(&ftemp,sizeof(float));


	int np=0;
	COleDateTimeSpan pastTime(0L,0,0, (int)(dTM*np+0.5));
	COleDateTime curTime = startTime + pastTime;

	cstrDateTime.Format(_T("%02d-%02d-%04d %02d:%02d:%02d"),
		curTime.GetMonth(), curTime.GetDay(),
		curTime.GetYear (), curTime.GetHour(),
		curTime.GetMinute(),curTime.GetSecond());

	//DATE
	SpexFile.Write((LPCTSTR)cstrDateTime.Left(10),10);             //DATE
	//TIME
	SpexFile.Seek(6,CFile::current);
	SpexFile.Write((LPCTSTR)cstrDateTime.Right(8),8);             //DATE
	SpexFile.Seek(444,CFile::begin);

	for(int i=np*nDA;i<(np+1)*nDA;i++)
	{
		if(fpdata[i]>0)
			ntemp=(int)(fpdata[i]+0.5);
		else
			ntemp=(int)(fpdata[i]-0.5);
		SpexFile.Write(&ntemp,sizeof(int));
	}

	ntemp=int(MY_MAX(fmax,fabs(fmin))+0.5);
	ntemp=(int)((ceil)(log10((double)ntemp)/log10(2.0)));

	SpexFile.Seek(434,CFile::begin);
	SpexFile.Write(&ntemp,sizeof(int));

	SpexFile.Close();


  return TRUE;
};
開發者ID:znoop333,項目名稱:ConvertToSPEX,代碼行數:101,代碼來源:ConvertToSPEXDoc.cpp


注:本文中的std::log10方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。