本文整理汇总了C++中Poly::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::push_back方法的具体用法?C++ Poly::push_back怎么用?C++ Poly::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::push_back方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: triangulate
vector<Poly> triangulate( const Poly &p ){
vector<Poly> res;
int n = p.size();
vector<int> l, r;
for( int i = 0; i < n; i++){
l.push_back( ( i - 1 + n) % n );
r.push_back( ( i + 1) % n );
}
int i = n - 1, cagao = 0;
while( res.size() < n - 2 ){
if ( cagao >= n ) return vector<Poly>();
i = r[i];
Poly tmp;
tmp.push_back( p[l[i]] );
tmp.push_back( p[i] );
tmp.push_back( p[r[i]] );
if ( can( tmp, p , l[i], i , r[i] ) ){
res.push_back( tmp );
l[ r[i] ] = l[i];
r[ l[i] ] = r[i];
cagao = 0;
}else cagao++;
}
return res;
}
示例3: main
int main(){
int runs;
scanf("%d",&runs );
while( runs-- ){
int n;
scanf("%d",&n);
Poly R;
double S = 0;
while( n--) {
double w, h, a, x , y;
Point c;
scanf("%lf%lf%lf%lf%lf", &c.x, &c.y, &w,&h,&a );
a = a * M_PI / 180.0;
S += w * h ;
w /= 2;
h /= 2;
R.push_back( c + rot( Point( w, h ) , a ) );
R.push_back( c + rot( Point( w, -h ) , a ) );
R.push_back( c + rot( Point( -w, h ) , a ) );
R.push_back( c + rot( Point( -w, -h ) , a ) );
}
double Total = area( convexHull( R ) );
printf("%.1lf %%\n", S/Total*100 );
}
return 0;
}
示例4: triangulate
// debe ser antihorario
vector<Poly> triangulate( const Poly &p ){
vector<Poly> res;
int n = p.size();
vector<int> l, r;
for( int i = 0; i < n; i++){
l.push_back( ( i - 1 + n) % n );
r.push_back( ( i + 1) % n ); // crea una lista doblemente enlazada
}
int i = n - 1, cagao = 0;
while( res.size() < n - 2 ){
if ( cagao >= n ) return vector<Poly>();
i = r[i]; // avanza tipo un i++
Poly tmp;
tmp.push_back( p[l[i]] );
tmp.push_back( p[i] );
tmp.push_back( p[r[i]] ); // crea un triangulo
if ( can( tmp, p , l[i], i , r[i] ) ){ // checa si sirve
res.push_back( tmp ); // guardamos la solucion
l[ r[i] ] = l[i];
r[ l[i] ] = r[i]; // con estas dos operaciones en O(1) borramos el punto del "medio" del triangulo
cagao = 0; // no fallo
}else cagao++; // se fue al carajo
}
return res;
}
示例5: main
int main(){
int runs;
cin >> runs;
for( int r = 1; r <= runs; r++){
string s;
cin >> s;
Point cur( 0, 0 );
Poly p;
for( int i = 0; i < s.size(); i++){
switch(s[i]){
case 'D':
cur = Point( cur.x - 1 , cur. y);
p.push_back( cur ) ;
break;
case 'U':
cur = Point( cur.x + 1 , cur. y);
p.push_back( cur ) ;
break;
case 'R':
cur = Point( cur.x , cur. y + 1);
p.push_back( cur ) ;
break;
case 'L':
cur = Point( cur.x , cur. y - 1);
p.push_back( cur ) ;
break;
}
}
printf("case %d: %.lf\n", r, area( p ));
}
return 0;
}
示例6: 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;
}
示例7: readTri
Poly readTri() {
Poly ret;
for (int i = 0; i < 3; ++i) {
Point p;
cin >> p.x >> p.y;
ret.push_back(p);
}
return convexHull(ret);
}
示例8: 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;
}
示例9: main
int main(){
char buff[ 50 ];
int runs;
scanf("%d\n",&runs);
bool t = 0;
while( runs--){
if ( t ) putchar( 10 );
t = 1;
Poly p;
while( gets(buff) && buff[0] ){
int x, y;
sscanf( buff, "%d %d",&x,&y);
p.push_back( Point ( x, y ));
}
printf( "%d\n", lining( p ) );
}
return 0;
}
示例10: main
int main(){
int runs;
scanf("%d",&runs);
while( runs--){
int n;
scanf("%d",&n);
int R[ n + 1 ];
Poly p;
for( int i = 0; i < n; i++){
int x , y;
scanf("%d %d",&x,&y);
p.push_back( Point( x, y ) );
}
sort( p.begin(), p.end() );
for( int i = 0; i < n ; i++ ) {
p[i].id = i ;
R[i] = i + 1;
}
int sig[ n + 1 ];
int id = 0;
for( int i = 0; i < n; i++){
int id = i + 1;
bool cagao = false;
for( int j = i + 1; j < n; j++){
if ( p[i].y < p[j].y ) cagao = true;
if ( p[j].y > p[id].y ) id = j;
}
if ( !cagao ) {
sig[i] = id;
}else{
sig[i] = -1;
}
}
Poly h;
for( int i = 0; i < n; i++){
if ( sig[i] != -1 ){
for( int pos = i ; pos != n; pos = sig[pos] ){
h.push_back( p[pos] );
}
break;
}
}
int s = 0;
if ( h[0].y < h[1].y) s++;
double res = 0.0;
for( int i = s; i < h.size()-1 ; i++){
// a = h[i], b = h[i+1], c es la interseccion de la recta a,R[a].id
// con el vector b(b.x+5, b.y)
Recta ac ( h[i+1], Point( h[i+1].x+5, h[i+1].y ));
Recta cb ( h[i], p[ R[ h[i].id ] ] );
bool paralelas = false;
Point c = ac.intersect( cb ,paralelas );
res += dist( h[i], c );
}
printf("%.2lf\n", res );
}
return 0;
}
示例11: next
// Generate from (x+1)^k to (x+1)^(k+1).
void next(Poly& B) {
for(int i = B.size() - 1; i >= 1; --i)
B[i] += B[i-1];
B.push_back(1);
}