本文整理汇总了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_);
}
示例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_);
}
示例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;
}
示例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()));
}
示例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));
}
示例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;
}
示例7: operator
inline T0
operator()(const T0& arg1) const {
return log10(arg1);
}
示例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;
};