当前位置: 首页>>代码示例>>C++>>正文


C++ Poly::size方法代码示例

本文整理汇总了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];
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:9,代码来源:p1478.cpp

示例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);
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:8,代码来源:p2707.cpp

示例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();
}
开发者ID:JoseMiguel,项目名称:icpc-training,代码行数:8,代码来源:uva920.cpp

示例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;
}
开发者ID:Kangz,项目名称:BooleanPoly,代码行数:8,代码来源:main.cpp

示例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;
}
开发者ID:Kangz,项目名称:BooleanPoly,代码行数:8,代码来源:main.cpp

示例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);
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:11,代码来源:p2707.cpp

示例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;
}
开发者ID:danielprint,项目名称:repsnapper,代码行数:9,代码来源:geometry.cpp

示例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);
	}
}
开发者ID:payload,项目名称:gorge,代码行数:9,代码来源:helper.cpp

示例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;

}
开发者ID:luzpaz,项目名称:scribus,代码行数:11,代码来源:poly.cpp

示例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;
}
开发者ID:kazunetakahashi,项目名称:atcoder,代码行数:11,代码来源:T.cpp

示例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);
}
开发者ID:luzpaz,项目名称:scribus,代码行数:11,代码来源:poly.cpp

示例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;
}
开发者ID:luzpaz,项目名称:scribus,代码行数:11,代码来源:poly.cpp

示例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);
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:14,代码来源:p1478.cpp

示例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);
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:16,代码来源:p2707.cpp

示例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;
}
开发者ID:AlterScribus,项目名称:ece15,代码行数:31,代码来源:poly-laguerre-solve.cpp


注:本文中的Poly::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。