本文整理汇总了C++中poly::size方法的典型用法代码示例。如果您正苦于以下问题:C++ poly::size方法的具体用法?C++ poly::size怎么用?C++ poly::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poly
的用法示例。
在下文中一共展示了poly::size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mprint
void mprint (poly &P) {
int mmax = 0;
int n = P.size();
cout<<n<<endl;
for (int i = 1; i < n; ++i ) {
if (mfunc(P[mmax], P[i])) {
mmax = i;
}
}
//cout<<mmax<<endl;
cout<<P[mmax].x<<" "<<P[mmax].y<<endl;
int i = (mmax-1+n)%n;
while(i != mmax) {
// cout<<i<<endl;
cout<<P[i].x<<" "<<P[i].y;
cout<<endl;
i = (i-1+n)%n;
}
}
示例2: closest_pair
double closest_pair (poly &P) {
int n = P.size();
double d = norma(P[0]-P[1]);
a = P[0].id; b = P[1].id;
set<point, bool(*)(point,point)> s(&ycmp);
sort(all(P));
for(int i=0,j=0 ; i<n ; i++) {
point lower(0, P[i].y - d) , upper(0, P[i].y + d);
while(P[i].x - P[j].x > d)
s.erase(P[j++]);
foreach(p, s.lower_bound(lower), s.upper_bound(upper))
/* os pontos mais proximos sao tirados de P[i] e *p */
if(d > norma(P[i] - *p)){
d = norma(P[i] - *p);
a = p->id;
b = P[i].id;
}
s.insert(P[i]);
}
return d;
}
示例3: invlogrev
poly<T> invlogrev(poly<T> const& p) {
size_t const d = p.size(); size_t i;
poly<T> s = p; s.pop_front();
poly<T> r(0,1);
r.push_back(T(-1)*s[0]);
poly<T> rinv, m = r;
for (size_t n=2; n<=d; n*=2) {
m.diff();
rinv = invert(r,2*n-1);
m *= rinv;
m += s;
m.first(2*n-1);
m *= T(-1);
for (i=0; i!=m.size(); ++i)
m[i] /= i+1;
m.push_front(T(1));
m *= r; m.first(2*n);
r = m;
}
r.first(d); r.rev(d-1);
return r;
}
示例4: is_inside
bool is_inside(const point & a, const poly & p) {
int i,n=p.size(),k=0;
point s, e (1001,1001);
double d;
bool tmp, nb_inter = true;
/* Manière propre, mais peu efficace,
de trouver un "bon" point en dehors du poly */
/*for (i = 0; i < n; i++) {
d = det(e-a, p[i]-a);
if (d == 0.) {
e.real()++;
i = 0;
}
}*/
for (i = 0; i < n; i++) {
tmp = interserct(a,e,p[i], p[(i+1) % n]);
nb_inter = (nb_inter != tmp);
if (tmp) k++;
}
cout << nb_inter;
cout << k << endl;
return nb_inter;
}
示例5: logrev
poly<T> logrev(poly<T> const& p, size_t const n) {
size_t const d = p.size()-1;
poly<T> c = p, b = p;
c.diff(); c.rev(d-1);
b.rev(d);
poly<T> b0 = invert(b, d);
c *= b0; c.first(d);
poly<T> out = c, newc;
for (size_t i=1; i <= n/d; ++i) {
newc = b;
newc *= c; newc.remove(d);
newc *= b0; newc.first(d);
newc *= T(-1);
c = newc;
//Improve efficiency by making this a member function and directly
//appending 'rep' here
newc *= poly<T>(d*i);
out += newc;
}
while (out.size() > n) out.pop_back();
while (out.size() < n) out.push_back(T(0));
return out;
}
示例6: subt
poly subt(poly p1,poly p2){
if(p1.size()>=p2.size()){
for(int i=0;i<p2.size();i++){
p1[i]-=p2[i];
}
return p1;
}
else{
for(int i=0;i<p1.size();i++){
p2[i]=p1[i]-p2[i];
}
for(int i=p1.size();i<p2.size();i++){
p2[i]=-p2[i];
}
return p2;
}
}
示例7: for
bool poly<T>::operator==(poly<T> const& rhs) const {
if (this->size() != rhs.size()) return false;
int i; for (i=0; i<=rhs.size(); ++i)
if ((*this)[i] != rhs[i]) return false;
return true;
}
示例8: eval
Double eval(const poly & p, Double x) {
Double res = 0;
for (int i = 0; i < (int)p.size(); i++)
res += p[i].first * powl(x, p[i].second);
return res;
}
开发者ID:nikhiljangam,项目名称:Algorithms-Anthology,代码行数:6,代码来源:4.6.1+Real+Root+Finding+(Differentiation).cpp
示例9: can_place
bool can_place(int x,int y,const poly &p)
{
for(int i=0;i<p.size();i++)
if(now[x+p[i].x][y+p[i].y]!='Z') return 0 ;
return 1 ;
}
示例10: equ
bool equ(const poly &v1,const poly &v2)
{
for(int i=0;i<v1.size();i++)
if(v1[i]!=v2[i]) return 0 ;
return 1 ;
}
示例11: printpoly
void printpoly(poly p){
for(int i=0;i<p.size();i++){
cout<<" + "<<p[i]<<"x^"<<i;
}
cout<<endl;
}
示例12: reduce
inline void reduce(poly &a){
int N = (int)a.size();
while (N > 0 && a[N - 1] == 0)a.pop_back(), N--;
}
示例13: printPol
void printPol(poly &a){
for (int i = 0; i < (int)a.size(); i++){
cout<<a[i]<<" ";
}
cout<<endl;
}