本文整理汇总了C++中Polynomial::setCoefficient方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::setCoefficient方法的具体用法?C++ Polynomial::setCoefficient怎么用?C++ Polynomial::setCoefficient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::setCoefficient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Polynomial polyguy;
Polynomial polyguy2(123.4, 5);
cout << "Default constructor initial value:" << endl;
polyguy.Display();
polyguy.setCoefficient(4, 299.1);
cout << "Changed values using setCoefficient and set Power:" << endl;
polyguy.Display();
cout << "Default constructor with specified value:" << endl;
polyguy2.Display();
cout << "Test of getCoefficient: " << polyguy2.getCoefficient() << endl;
polyguy.addPolynomial(polyguy2);
cout << "Addition of the default and specified polynomials:" << endl;
polyguy.Display();
return 0;
}
示例2: com
void ContactAngle1::doFrame(int frame) {
StuntDouble* sd;
int i;
if (evaluator1_.isDynamic()) {
seleMan1_.setSelectionSet(evaluator1_.evaluate());
}
RealType mtot = 0.0;
Vector3d com(V3Zero);
RealType mass;
for (sd = seleMan1_.beginSelected(i); sd != NULL;
sd = seleMan1_.nextSelected(i)) {
mass = sd->getMass();
mtot += mass;
com += sd->getPos() * mass;
}
com /= mtot;
RealType dz = com.z() - solidZ_;
if (dz < 0.0) {
sprintf(painCave.errMsg,
"ContactAngle1: Z-center of mass of selection, %lf, was\n"
"\tlocated below the solid reference plane, %lf\n",
com.z(), solidZ_);
painCave.isFatal = 1;
painCave.severity = OPENMD_ERROR;
simError();
}
if (dz > dropletRadius_) {
values_.push_back(180.0);
} else {
RealType k = pow(2.0, -4.0/3.0) * dropletRadius_;
RealType z2 = dz*dz;
RealType z3 = z2 * dz;
RealType k2 = k*k;
RealType k3 = k2*k;
Polynomial<RealType> poly;
poly.setCoefficient(4, z3 + k3);
poly.setCoefficient(3, 8.0*z3 + 8.0*k3);
poly.setCoefficient(2, 24.0*z3 + 18.0*k3);
poly.setCoefficient(1, 32.0*z3 );
poly.setCoefficient(0, 16.0*z3 - 27.0*k3);
vector<RealType> realRoots = poly.FindRealRoots();
RealType ct;
vector<RealType>::iterator ri;
RealType maxct = -1.0;
for (ri = realRoots.begin(); ri !=realRoots.end(); ++ri) {
ct = *ri;
if (ct > 1.0) ct = 1.0;
if (ct < -1.0) ct = -1.0;
// use the largest magnitude of ct that it finds:
if (ct > maxct) {
maxct = ct;
}
}
values_.push_back( acos(maxct)*(180.0/M_PI) );
}
}