本文整理汇总了C++中Polynomial::qiudiao方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::qiudiao方法的具体用法?C++ Polynomial::qiudiao怎么用?C++ Polynomial::qiudiao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::qiudiao方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findAllRoots
static vector<long double> findAllRoots(const Polynomial & f)
{
vector<long double> ret;
Polynomial f_ = f.qiudiao();
long double minRoot = -200.0;
long double maxRoot = 200.0;
for (int iter = 0; iter <= 1000; ++iter)
{
//cout << iter << endl;
long double x0 = (long double) rand() / (long double) RAND_MAX;
x0 = minRoot + (maxRoot - minRoot) * x0;
long double root;
bool findRoot = newton_root(x0, f, f_, root);
if (findRoot)
{
bool newroot = true;
for (int i = 0; i < ret.size(); ++i)
if (fabs(ret[i] - root) < bigeps)
newroot = false;
if (newroot)
{
int multi = findRootMultiple(root, f);
vector<long double> newroots(multi, root);
ret.insert(ret.end(), newroots.begin(), newroots.end());
}
}
}
sort(ret.begin(), ret.end());
return ret;
}
示例2: findRootMultiple
// after we find a root of a polynomial, use this method to determine its multiple
static int findRootMultiple(long double x, const Polynomial & f)
{
int ret = 1;
Polynomial now = f;
double zeroeps = 1e-6;
while (true)
{
now = now.qiudiao();
if (now.coff.size() == 0) break;
long double nowf = now.func(x);
if (fabs(nowf) < zeroeps) ret++;
else break;
zeroeps *= 4;
}
return ret;
}