本文整理汇总了C++中Poly::getMonoPolyWithIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::getMonoPolyWithIndex方法的具体用法?C++ Poly::getMonoPolyWithIndex怎么用?C++ Poly::getMonoPolyWithIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::getMonoPolyWithIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
Poly Poly::operator()(const Poly& obj, string str) const
{
// Copy
Poly f; f = *this;
// get one of the highest term.
MonoPoly h0 = *(obj.getHighestTerm(str));
double h0_coeff = h0.getCoeff();
// calc.
// f - t + (t * h0_coeff / h0) * ((h0 - obj) / h0_coeff)
// where
// t = term including hterm
while (1) {
// search which includes hterm.
int index;
if ((index = f.searchIncludeDimMonoPoly(&h0)) == -1) { // if not break
break;
} else { // if any substitute
MonoPoly t = *(f.getMonoPolyWithIndex(index));
f = (f - t) + (t * h0_coeff / h0) * ((h0 - obj) / h0_coeff);
}
}
f.cleanPoly();
return f;
}
示例2: Poly
Poly Poly::operator+(const Poly& obj) const
{
Poly tmp = Poly(this->m_pi);
// This
for (int i = 0; i < this->getMonoPolyNum(); i++)
tmp.addMonoPoly(this->getMonoPolyWithIndex(i));
// obj
for (int i = 0; i < obj.getMonoPolyNum(); i++) {
int index;
if ((index = tmp.searchSameDimMonoPoly(obj.getMonoPolyWithIndex(i))) == -1) {
tmp.addMonoPoly(obj.getMonoPolyWithIndex(i));
} else {
tmp.setMonoPolyCoeffWithIndex(index,
tmp.getMonoPolyWithIndex(index)->getCoeff()
+ obj.getMonoPolyWithIndex(i) ->getCoeff());
}
}
tmp.cleanPoly();
return tmp;
}