本文整理汇总了C++中Polynomial::roots方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::roots方法的具体用法?C++ Polynomial::roots怎么用?C++ Polynomial::roots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::roots方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialise
/// Initialise the weights w and abscissas x.
void GaussLaguerre::initialise()
{
int i;
// Create Laguerre polynomial L_n of order n+1 using recurrence relation - L_{n+1} is required to calculate weights below
Array<complex<double>,1> one(2);
one = 1.0, -1.0;
Polynomial currL(one); // 1-x
Polynomial prevL; // 1
// 2n+1-x:
Polynomial two_n_plus_one_minus_x(one);
for (i=2;i<=n+1;i++) {
two_n_plus_one_minus_x += 2.0;
Polynomial tmp(currL);
tmp *= two_n_plus_one_minus_x;
prevL *= -(i-1.0);
tmp += prevL;
tmp *= 1.0/double(i);
prevL = currL;
currL = tmp; }
// Abscissas x are the roots of the Laguerre polynomial
const Array<complex<double>,1>& roots = prevL.roots();
for (i=1;i<=n;i++) x(i) = roots(i-1).real(); // note that indexing starts from 1, not 0 in this particular implementation
// Calculate weights w - using eq. 14 at http://mathworld.wolfram.com/Laguerre-GaussQuadrature.html
for (i=1;i<=n;i++) {
double tmp = (n+1)*currL(x(i)).real();
w(i) = x(i) / (tmp*tmp); }
}
示例2: func2
void func2()
{
/* Thread 2 */
auto valsGivingZero = p.roots();
}
示例3: func1
void func1()
{
/* Thread 1 */
auto rootsOfP = p.roots();
}