本文整理汇总了C++中Poly::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::size方法的具体用法?C++ Poly::size怎么用?C++ Poly::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conv
// Slow convolution, multiplying two polynomials.
// Complexity: O(nu * nv).
void conv(const Poly& u, const Poly& v, Poly& w) {
int nu = u.size(), nv = v.size();
w.assign(nu + nv - 1, 0.0);
for(int i = 0; i < nu; i++)
for(int j = 0; j < nv; j++)
w[i+j] += u[i] * v[j];
}
示例2: sub
// Add b to a or Subs b from a.
void sub(Poly& a, const Poly& b) {
if(a.size() < b.size())
a.resize(b.size(), 0);
for(int i = 0; i < b.size(); ++i)
a[i] ^= b[i];
tidy(a);
}
示例3: centerMass
Point centerMass( Poly &p ){
Point c( 0 , 0 ) ;
for( int i = 0; i < p.size(); i++ ) {
c.x += p[i].x ;/// (double)p.size();
c.y += p[i].y ;/// (double)p.size();
}
return c / (double) p.size();
}
示例4: naiveShiftRight
Poly naiveShiftRight(const Poly& p, int i) {
Poly res(p.size() - i);
for (unsigned j = i; j < p.size(); j++) {
res.setBit(j - i, p.bit(j));
}
res.computeDegree();
return res;
}
示例5: naiveShiftLeft
Poly naiveShiftLeft(const Poly& p, int i) {
Poly res(p.size() + i);
for (unsigned j = 0; j < p.size(); j++) {
res.setBit(i + j, p.bit(j));
}
res.computeDegree();
return res;
}
示例6: conv
// Slow convolution, multiplying two polynomials.
// Complexity: O(nu * nv).
void conv(const Poly& u, const Poly& v, Poly& w) {
if(u.empty() || v.empty()) {w.clear(); return;}
int nu = u.size(), nv = v.size();
w.assign(nu + nv - 1, 0);
for(int i = 0; i < nu; i++)
for(int j = 0; j < nv; j++)
w[i+j] ^= (u[i] & v[j]);
tidy(w);
}
示例7: points
vector<p2t::Point*> getP2Tpoints(const Poly &poly)
{
vector<p2t::Point*> points(poly.size());
for (uint i=0; i<poly.size(); i++) {
points[i] = new p2t::Point(poly.vertices[i].x(),
poly.vertices[i].y());
}
return points;
}
示例8: drawPoly
void drawPoly(const Poly poly) {
sf::VertexArray v(sf::Lines, 2);
v[0].color = v[1].color = sf::Color::Red;
for (size_t i = 0; i < poly.size(); i++) {
v[0].position = poly[i];
v[1].position = poly[(i + 1) % poly.size()];
window.draw(v);
}
}
示例9: integral
Poly integral(Poly const & p) {
Poly result;
result.reserve(p.size()+1);
result.push_back(0); // arbitrary const
for(unsigned i = 0; i < p.size(); i++) {
result.push_back(p[i]/(i+1));
}
return result;
}
示例10: res
Poly operator*(Poly p, ll k)
{
reduce(p);
Poly res(p.size());
for (auto i = 0; i < (int)p.size(); i++)
{
res[i] = (p[i] * k) % MOD;
}
reduce(res);
return res;
}
示例11: gcd
Poly gcd(Poly const &a, Poly const &b, const double tol) {
if(a.size() < b.size())
return gcd(b, a);
if(b.empty())
return a;
if(b.size() == 1)
return a;
Poly r;
divide(a, b, r);
return gcd(b, r);
}
示例12: derivative
Poly derivative(Poly const & p) {
Poly result;
if(p.size() <= 1)
return Poly(0);
result.reserve(p.size()-1);
for(unsigned i = 1; i < p.size(); i++) {
result.push_back(i*p[i]);
}
return result;
}
示例13: deconv
// Slow deconvolution, polynomial dividing.
// q returns the quotient, r returns the remainder.
void deconv(const Poly& u, const Poly& v, Poly& q, Poly& r) {
int n = u.size() - 1;
int nv = v.size() - 1;
q.assign(n+1, 0.0);
r = u;
for(int k = n-nv; k >= 0; k--) {
q[k] = r[nv+k] / v[nv];
for(int j = nv+k-1; j >= k; j--)
r[j] -= q[k] * v[j-k];
}
r.resize(nv);
}
示例14: deconv
// Slow deconvolution, polynomial dividing.
// q returns the quotient, r returns the remainder.
void deconv(const Poly& u, const Poly& v, Poly& q, Poly& r) {
int n = u.size() - 1;
int nv = v.size() - 1;
q.assign(n + 1, 0);
r = u;
for(int k = n-nv; k >= 0; k--) {
q[k] = r[nv+k];
for(int j = nv+k-1; j >= k; j--)
r[j] ^= (q[k] & v[j-k]);
}
r.resize(nv);
tidy(q);
tidy(r);
}
示例15: while
std::vector<cdouble >
laguerre(Poly p, const double tol) {
std::vector<cdouble > solutions;
//std::cout << "p = " << p << " = ";
while(p.size() > 1)
{
double x0 = 0;
bool quad_root = false;
cdouble sol = laguerre_internal_complex(p, x0, tol, quad_root);
//if(abs(sol) > 1) break;
Poly dvs;
if(quad_root) {
dvs.push_back((sol*conj(sol)).real());
dvs.push_back(-(sol + conj(sol)).real());
dvs.push_back(1.0);
//std::cout << "(" << dvs << ")";
//solutions.push_back(sol);
//solutions.push_back(conj(sol));
} else {
//std::cout << sol << std::endl;
dvs.push_back(-sol.real());
dvs.push_back(1.0);
solutions.push_back(sol);
//std::cout << "(" << dvs << ")";
}
Poly r;
p = divide(p, dvs, r);
//std::cout << r << std::endl;
}
return solutions;
}